fix(server): fix person pagination when deleting #6707
Merged
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.
Description
We delete all people when running face detection or facial recognition with "All". This is handled by fetching paginated lists of people and deleting them in batches. The issue is that as we're deleting rows from this table, the SKIP value in the pagination query becomes outdated. Once it exceeds the size of the table - the pagination size (1000), the pagination stops early and half of the table remains.
This PR sets the skip value to 0 since we delete all rows in each fetched page, meaning the next batch begins at row 0.
How Has This Been Tested?
I removed the foreign key constraints to the person table and added 20000 randomly generated rows to it. I then started an "All" job for facial recognition and immediately paused it and observed that it deleted all rows in the table, 1000 at a time.