Discrepancy between statistics and place's feedback page

User story: From @danveg, the difference in kg has been observed in their Luxemburg instance. It’s been confirmed elsewhere

Issue at #2738 - Discrepancy between statistics and place's feedback page - karrot/karrot-frontend - Codeberg.org

Complexity: pages do different queries and the one on stats is quite complex

Outcomes (or what needs to be done to move forward): investigate the queries?

Ok, I did an investigation! I found a few things:

  1. both queries have some errors, just different errors
  2. the one at the top of the place feedback page does not exclude disabled activities when looking at the feedback count and weight
  3. the one on the statistics page does a little bit of double counting due to missing distinct arguments
  4. there is feedback for disabled activities, and I don’t know how this is possible

I’ve got some fixes to the queries which I think will make them give the same answers, and I’ll be writing a test to cover the cases I know about.

What I am confused about is why there is ever feedback for disabled activities. I cannot recreate this on the dev site, for disabled activities that I joined, there is no option to give feedback.

It looks like the API might accept it, I couldn’t see a check there, but still, I don’t think people are using the API to give feedback… but the most recent case I can see is from february last year… so maybe it got fixed…

@danveg if you want to check if you also have feedback for disabled activities, here is a bit of python you can run in a django shell - it shows the most recent 10:

for a in Activity.objects.annotate(fc=Count('feedback')).filter(fc__gt=0).filter(is_disabled=True).order_by('-date')[:10]:
  print('-----------------------')
  print(a)
  print()
  for h in a.history_set.order_by('date'):
    print('  ', h.id, h)
  print()
  for f in a.feedback_set.order_by('created_at'):
    print('  ', f.created_at, f)
  print()

Thanks for looking into this to both of you! :+1:

there is feedback for disabled activities, and I don’t know how this is possible

Thanks for the Python bit! Looking at the data on our instance, I noticed that the feedback for disabled activities is only available at places that are not active anymore. Maybe, they are retroactively marked as disabled when the status of the place is set to inactive?

We do mark them as disabled if the place gets archived:

… which looked promising, but in the cases I’m looking at, the place is not archived, and the activity got disabled before the feedback was created :thinking:

Still investigating…

Although still need to decide how to handle the case of feedback for disabled activities. My general thinking it should not include that data (the only activities marked disabled when archiving are ones that haven’t been done yet, not completed ones).

… although I’d still like to unravel the mystery first if I can.

Ah, only archived places! This is also not the case for the examples I had looked at.

I had another look at these data on our instance. We also have examples of places that are still active. Looking at these feedback entries in more detail, I see that some people wrote that the activity was cancelled while others wrote that it happened and indicated even weights. How did you find out the date when the activity was disabled?

I saw you created a first fix, yay! :clap:

Hmm, yes something curious there.

I think it’s worth getting my two PRs merged and deployed, and then see where we are at:

The frontend PR ensures the data from the query will always match the selected filters - which addresses something I wrote in a comment over at #2738 - Discrepancy between statistics and place's feedback page - karrot/karrot-frontend - Codeberg.org (our discussion is a bit scattered!) - the current version has the possibility that the displayed data is not the right data for the selected filters, due to race conditions with the slow queries (that was basically the only place in Karrot that didn’t use vue-query for data fetching, which solves that aspect).

Let’s see how it looks then… :crossed_fingers:

I have to do a release first, but that’s my main task at the moment! (also will include polls and collaborative docs feature!)

Thanks for your fixes! :+1:

When checking the statistics page in the “archived” Foodsharing Luxembourg group on karrot.world, I got a 504 gateway timeout on that specific request with “Forever” as time period. Unfortunately, we did not write down the amount before the fix was deployed. :sweat_smile:

I will get back with more feedback once I updated our instance.

Yes, sad, I think my fixes to make the query fixed also made it slower. I’m thinking a quick fix is just to increase the timeouts, which I think I might be able to do with the new instance options UI :slight_smile:

Oh, actually I think you were saying you got the timeouts before the update. And, me updating the timeouts on karrot.world won’t help you on your instance :slight_smile:

I think I have been unclear. Sorry about that! :slightly_smiling_face:

Actually, after the update on karrot.world, the request with time period set to “Forever” in the “archived” Foodsharing Luxembourg group times out, so I think your idea might solve this issue. Feel free to apply to this group to have a look yourself.

I did the update on our instance, and everything runs fine. I am still waiting for a feedback by two others from my group who are working with the data.

(By the way, it is the first time I did activate the browser notifications; This requires still some testing.)

1 Like