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

Fixes day calculation for grace_period #77

Merged
merged 1 commit into from
May 17, 2024
Merged

Fixes day calculation for grace_period #77

merged 1 commit into from
May 17, 2024

Conversation

laugmanuel
Copy link
Member

I'm not sure if this bug existed all the time or if it is caused by Ruby changes.

See the following example:

[32] pry(main)> host.expired_on
=> Fri, 10 May 2024 22:00:00.000000000 UTC +00:00

[33] pry(main)> host.expired_on - Setting['notify1_days_before_host_expiry'].to_i
=> Fri, 10 May 2024 21:59:53.000000000 UTC +00:00

[34] pry(main)> host.expired_on - Setting['notify1_days_before_host_expiry'].to_i.days
=> Fri, 03 May 2024 22:00:00.000000000 UTC +00:00

@laugmanuel
Copy link
Member Author

mind having a look @ekohl ?

@ekohl
Copy link
Member

ekohl commented May 10, 2024

I wonder if expired_on used to be a Date and is now a Datetime. db/migrate/20230112104438_change_expired_on_type.rb at least changes the DB type, so that could be the cause. It was introduced in 5bf6333 which doesn't really describe the change.

In most places it's used there's some .to_date code so perhaps that should also be done here? I don't really know the codebase so hard to say what's right here.

@laugmanuel
Copy link
Member Author

I wonder if expired_on used to be a Date and is now a Datetime. db/migrate/20230112104438_change_expired_on_type.rb at least changes the DB type, so that could be the cause. It was introduced in 5bf6333 which doesn't really describe the change.

This might be the reason behind the different behaviour. I also don't know any reason behind this. Maybe @kamils-iRonin ?

In most places it's used there's some .to_date code so perhaps that should also be done here? I don't really know the codebase so hard to say what's right here.

I've also added .to_date for the relevant line. However, being explicit with .days sounds like a valid way to me.

@ekohl
Copy link
Member

ekohl commented May 13, 2024

I have a Python background. Explicit is good

@laugmanuel
Copy link
Member Author

Who can have a final look at this? As far as I understand, expire hosts is currently somewhat broken due to this bug.

@ekohl ekohl merged commit 2765128 into theforeman:master May 17, 2024
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants