-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add lastAccessed field to map table #296
Add lastAccessed field to map table #296
Conversation
Please don't forget to generate the migration file for this, see https://github.com/b310-digital/teammapper/blob/main/teammapper-backend/README.md. |
please also add the use of this field to the delete handler in the service ( |
I'm working on that right now, it's just that I need to restructure the queries a bit to work with the new field, so it'll take some time. |
For documentation purposes:
|
ok there are actually >300 maps on our server, that do not have any nodes. Interestingly, all these maps are not old but were created in September - so there seems to be a bug not creating the root node or deleting the root node. But this is a bug for a different issue. However, we should still include this case, that a map does not contain any nodes. => The following test cases are the most relevant:
|
@@ -152,6 +208,33 @@ describe('MapsController', () => { | |||
expect(await nodesRepo.findOne({ where: { id: node.id } })).not.toBeNull() | |||
}) | |||
|
|||
it('deletes a map which has outdated nodes and outdated lastAccess', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also add a test (if not given, can't find it right now): Outdated modifedAt, recent nodes => do not delete. This is how its working right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is covered by it('does not delete a map that contains a recent node')
, where lastAccessed is set to 2019 but the node is set to today using new Date()
.
@@ -233,19 +239,9 @@ export class MapsService { | |||
'lastmodifiednode.nodeMapid = map.id' | |||
) | |||
.where( | |||
// delete all maps that have nodes that were last updated after afterDays | |||
"(lastmodifiednode.lastUpdatedAt + (INTERVAL '1 day' * :afterDays)) < :today", | |||
"(GREATEST(map.lastAccessed, map.lastModified, lastmodifiednode.lastUpdatedAt) + (INTERVAL '1 day' * :afterDays)) < :today", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thats a cool discovery that this takes more than 2 arguments, makes it way easier 👍
Dates are now set explicitly in every test, in addition to the following format changes: An old date is always set to If we're testing recent dates, system time will always be set exactly to the same date. |
looks good, I also tested everything locally with cross running every minute and 1 day as delete threshold. Could not find any problems. |
closes #286