[kitsune] Fix resuming feature #80
Merged
+114
−146
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The backend used the parameter 'offset' to retrieve new data. When an offset is given, the backend considers it as the number of questions that will discard before getting new data, because in the last run it retrieved up to that number of questions.
For example, if on a first retrieval there were 10 questions, the offset will be 10. When the backend runs again using 10 as offset, it will discard the 10 first questions that were updated during that time and, retrieve questions from there.
This approach is totally wrong because there could have been questions updated but discarded. Using the previous example, if after the first retrieval, 10 new questions were created and 10 more were updated, the backend will only fetch 10 and not 20, which were the number of updated questions.
To fix this issue we use the filter 'from_date', that will retrieve those questions updated after a given date.
Notice that the item's field 'updated' on each question is not updated when a new answer is added/updated. For that reason, we need to look for the maximum date in the question and its answers to set the correct metadata value 'updated_on'.