openfoodfacts / openfoodfacts-hungergames

One click Mini-Games for Open Food Facts for: categories, labels, weight, brands, logos… We'd need to port and improve nutrition and ingredients from the old version.
9 stars 14 forks source link

fix: no questions remaining fixed with pagination #416

Open sumana2001 opened 2 years ago

sumana2001 commented 2 years ago

What

Closes #394

Screenshot

Currently deployed version: Link: https://hunger.openfoodfacts.org/questions?country=en%3Aunited-states&type=brand&sorted=true

https://user-images.githubusercontent.com/63084088/161840028-c9c68eb7-1f5b-4d6e-8e11-51ddfcda65aa.mov

Fix:

https://user-images.githubusercontent.com/63084088/161840228-187fcac3-8722-4fb5-b0ee-435c5f19c0f2.mov

Fixes bug(s)

sumana2001 commented 2 years ago

Notice that you do not always need to increase page, because if the user answers questions these questions are replaced by new ones in the next API call

Hey @alexfauquette, I am not sure what you meant by this. Could you elaborate on when I should increase the page number?

sumana2001 commented 2 years ago
  • page out of range

@alexfauquette While trying to add the out of range checks, I came across this error and am not able to figure out why it is happening. In the following URL, https://hunger.openfoodfacts.org/questions?type=brand&sorted=true it is showing no questions remaining even though there are more than 90000 questions left. But when I did console log in localhost, I found the URL it is sending a request to which is https://robotoff.openfoodfacts.org/api/v1/questions/popular?count=10&lang=en&insight_types=brand When you open the link you can see the questions actually there.

Could you please help me understand why the questions are not getting displayed in the hunger games website? I am attaching some screenshots for reference

Screenshot 2022-05-17 at 12 15 35 PM Screenshot 2022-05-17 at 12 15 51 PM
alexfauquette commented 2 years ago

For the question about "out of range but server send ack questions". I think it is related to the fact non of those questions contains a source_image_url field

See https://github.com/openfoodfacts/openfoodfacts-hungergames/issues/394#issuecomment-1060893247

About when to increase the page number:

Increasing page number

I assume that as long as robotoff.questions(..., page) returns question that have never been seen, nor are in the buffer, we can stay on this page. Products are renewed because the user is answering questions, wich decrease the stack

Reseting page number

When the filter parameters are modified, the page should go back to the beginning

Disabling pagination

If the sorting is random, it is not necessary to increase the page

No remaining

Instead of the following dummy verification I did, we could chack when page is the last one (count/pageSize >= page) after fetching the page, add the NO_QUESTION_LEFT to the batch because after this page there is not more questions

https://github.com/alexfauquette/openfoodfacts-hungergames-1/blob/23ca2a0797e914497f04ef360f5e0a48a7944f46/src/views/QuestionView.vue#L238-L243

sumana2001 commented 2 years ago

Hey @alexfauquette Thank you for dividing the issue into smaller parts and explaining each of them. It really made the entire issue very clear. I tried implementing all the pointers. Please have a look and let me know the changes. Here are the pointers: