MESH-Research / humcore

A library-quality repository for sharing, discovering, retrieving, and archiving digital work.
7 stars 3 forks source link

Correct issue with deposit download counts #196

Closed bjr70 closed 11 months ago

bjr70 commented 2 years ago

Originally from @ericknappe on this issue:

These deposit download counts have been corrected. Typically there are a few problems every few days. However, something different happened in the past week and there were over 500 that needed correction.

The bad behavior is that a count gets reset to 0, and that count starts incrementing from there. The count correction is done by taking the starting count at the beginning of the month and adding it to the current value for any counts that are lower than the beginning month count. Not a perfect recovery in all possible cases.

            <$total_downloads = get_post_meta( $deposit_post_id, $downloads_meta_key, true ) + 1; // Downloads counted at file level.
            if ( bp_loggedin_user_id() != $post_data->post_author && ! humcore_is_bot_user_agent() ) {
                    $post_meta_id = update_post_meta( $deposit_post_id, $downloads_meta_key, $total_downloads );
            }>

The get_post_meta may be failing silently. Short term we should add diagnostics to see if the DB or cache read is getting an error. This issue should get a development ticket to redo the count accumulation logic.

bjr70 commented 11 months ago

Closing will reconsider in light of Invenio implementation.