-
Notifications
You must be signed in to change notification settings - Fork 4
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
[PB-1429]: Feat/max storage days limit #278
Draft
apsantiso
wants to merge
7
commits into
master
Choose a base branch
from
feat/max-storage-days-limit
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3d8ac6e
to
57bde83
Compare
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR enforces the limit for the storage days in the trash.
What it includes:
Some considerations:
Cron jobs with multiple instances running: nestjs cron jobs are in memory, every instance is going to try to run the cron job. There are some ways to handle this, having a table in a shared db so the first instance that tries to run the job writes to the DB with the current timestamp (it sounds kind of a race condition I don't like it) or using redis.
Folders use deleteAt and files use updatedAt. Should we index both? Should we update "updatedAt" for both when they are trashed?
Why is there a raw query inside the query for listing trashed/expired items? Actually, I tried to use the ORM at its max extend without writing raw SQL (they are too troublesome to maintain 😴 and people sometimes don't check them before changing models). This was my original query:
However, Sequelize seems to have a known bug when you try to nest models with many to many relations sometimes. Basically, the query works if I do not add the
limit
at the end to just get a X number of records OR if I do not ask for thelimitModel
while limiting the results. It creates a sort of subquery and introduces the limit = 1000 inside that subquery and it fails.Of course, I do not want to get the entire database of expired trashed items, so that's the reason of the raw query being there.