Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetching 5 random products appears to present many repeats #33

Open
CloCkWeRX opened this issue Jul 3, 2019 · 1 comment
Open

Fetching 5 random products appears to present many repeats #33

CloCkWeRX opened this issue Jul 3, 2019 · 1 comment

Comments

@CloCkWeRX
Copy link

CloCkWeRX commented Jul 3, 2019

image

I feel like this is a combination of:

  • Selects from API use only a "first page" of results or similar
  • Asynchronous writes are slower than the subsequent calls to the API; so results are double presented
  • The API call/writes appear to be causing moderate load - doing a few batches of answers can result in ~30 loading time. Unclear if its just this app or other overnight processes happening.

Edit;

@CloCkWeRX
Copy link
Author

I think this might be the offending approach:

  const edit = annotation => {
    axios.post(
      'https://robotoff.openfoodfacts.org/api/v1/insights/annotate',
      new URLSearchParams(
        `insight_id=${
          questions[0].insight_id
        }&annotation=${annotation}&update=1`,
      ),
    ); // The status of the response is not displayed so no need to wait the response
    setQuestions(questions.filter((_, i) => i)); // remove first question
  };

If multiple annotation requests (A, B) are sent off before the annotation request has posted, but request B finishes before request A; we end up with something like:

setQuestions([a, b, c] - b);
setQuestions([a, b, c] - a); // Question B magically reappears in the collection.

I think simply updating the array of questions before we even do the post request might make this much less of an issue; particularly if we're not fussed about the request success or failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant