review stats do not update on moderation or removal of reviews

Bug #708841 reported by Michael Vogt
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Ratings and Reviews server
Fix Released
High
Michael Nelson

Bug Description

When a review is flagged for moderation or removed permanently the review stats are not updated.

E.g.
$ w3m -dump https://reviews.staging.ubuntu.com/reviews/api/1.0/review-stats/

    {
        "ratings_total": 7,
        "ratings_average": "4.00",
        "app_name": "7zip",
        "package_name": "p7zip-full"
    },

But all of those are in moderation (they are test review entries and removed).

Notes:
The stats should be updated whenever a review is hidden or un-hidden. When a review is initially flagged, it will be hidden. But if it is flagged again after already having been approved via moderation, it will not be hidden.

Tags: kb-task

Related branches

Michael Vogt (mvo)
summary: - review stats do update on moderation or removal of reviews
+ review stats do not update on moderation or removal of reviews
Revision history for this message
Michael Nelson (michael.nelson) wrote :

Just noting that I'm not sure whether we're talking about a feature or a bug here. That is, we wanted to ensure that the views behind the stats URLs would only ever be hit when their cache timed out (very heavily cached).

It obviously looks wrong when the example stats only contain one package, but when it contains 10k we can't be clearing the cache for this url each time a review is flagged.

It was because this request will potentially be so heavy on the server that we enabled tho /review-stats/last-[1,3,7]-days/ urls, on the assumption that clients would be requesting updated stats at *most* once-per-day.

From memory, we had a conversation along the lines of the USC client updating its local copy for individual packages when the user adds a review, or flags a review etc. (so at least their own modifications look consistent).

{{{
12:16 * noodles is confused about the stats bug - I thought the whole point was that url should be very heavily cached?
12:17 < noodles> (ie. the cache for the stats should not be cleared every time a moderation is flagged etc.)
12:25 < achuni> noodles: right, but even after cache has expired, stats never go away
12:26 * achuni checks the stats bug
12
:27 < achuni> yup
12:27 < noodles> Oh? OK.
12:28 < achuni> noodles: ie, flagging a stat should decrease the stats for the software item (or moderating the flag, at the latest)
12:29 < noodles> achuni: flagging a review? I don't see how that's possible while heavily caching that url (as the client downloads *complete* stats)
12:29 < noodles> (ie. we wanted to be able to write the file out regularly and just server the static file, from memory)
}}}

Revision history for this message
Michael Vogt (mvo) wrote :

Thanks Michael for your reply. The problem that this bug describes is that even after the cache expired the data is still wrong (or appears to be wrong). It looks like a review in moderation is not affecting the stats. I did a moderation request on the reviews for 2vcard yesterday (~24h ago) and all of them are in the moderation queue currently. But the stats still count them today:
$ w3m -dump https://reviews.staging.ubuntu.com/reviews/api/1.0/review-stats/|grep -B4 -A1 2vcard
    {
        "ratings_total": 8,
        "ratings_average": "3.75",
        "app_name": "",
        "package_name": "2vcard"
    },

I agree that we need to provide the caching and that the client will have to do tricks in order ot update its data (its doing that to some extend already).

Revision history for this message
Anthony Lenton (elachuni) wrote :

@noodles, as mvo points out, what we should ensure is that eventually (after some caching period) the results should be consistent again. In other words, our database should be kept consistent, even though caching may produce (temporarily) inconsistent data. At the moment our data loses consistency when a review is flagged or deleted.

Revision history for this message
Michael Nelson (michael.nelson) wrote :

Ah right - thanks guys. achuni did mention that in the irc conv., but I missed that on the bug.

Changed in rnr-server:
assignee: nobody → Michael Nelson (michael.nelson)
importance: Undecided → High
status: New → In Progress
tags: added: kb-task
Changed in rnr-server:
status: In Progress → Fix Committed
Dave Morley (davmor2)
description: updated
description: updated
Revision history for this message
Dave Morley (davmor2) wrote :

Passes on production.

Changed in rnr-server:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.