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

fix(server): regular version check #7620

Merged
merged 1 commit into from Mar 4, 2024

Conversation

rovo89
Copy link
Contributor

@rovo89 rovo89 commented Mar 4, 2024

dt.diffNow() equals dt.diff(DateTime.now()), so it returns a negative number when dt is in the past (which it always is in this case).

Therefore we could only get over the condition during startup (when this.releaseVersionCheckedAt isn't set yet), effectively breaking update notifications while the server is running.

There are different ways to write this, e.g.

1: DateTime.now().diff(this.releaseVersionCheckedAt).as('minutes') < 60
2: -this.releaseVersionCheckedAt.diffNow().as('minutes') < 60
3: Math.abs(this.releaseVersionCheckedAt.diffNow().as('minutes')) < 60
4: this.releaseVersionCheckedAt.diffNow().as('minutes') > -60

I prefer the first one because it feels most readable. Second is basically reversing the timestamps, third does the same (assuming that time only moves forward). I don't like the fourth way, hard to read from my point of view.

`dt.diffNow()` equals `dt.diff(DateTime.now())`, so it returns a
negative number when `dt` is in the past (which it always is in this
case).

Therefore we could only get over the condition during startup (when
`this.releaseVersionCheckedAt` isn't set yet), effectively breaking
update notifications while the server is running.
Copy link
Member

@danieldietzler danieldietzler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I think this is the best solution

@alextran1502 alextran1502 merged commit de71d8e into immich-app:main Mar 4, 2024
24 of 25 checks passed
@rovo89 rovo89 deleted the version_check branch March 4, 2024 14:46
@jrasm91
Copy link
Contributor

jrasm91 commented Mar 5, 2024

Thanks for fixing this, but I noticed you didn't add any unit tests. Would that be something you would be able to do in a follow up PR?

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

Successfully merging this pull request may close these issues.

None yet

5 participants