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

loaddata: Fix random_datetime() edge case #7156

Merged
merged 1 commit into from May 1, 2024
Merged

Conversation

legoktm
Copy link
Member

@legoktm legoktm commented Apr 30, 2024

Status

Ready for review

Description of Changes

Instead of generating month and day separately, generate them at the same time by randomly selecting a day in the year, and then calculating the month and date based on that.

This should avoid randomly generating invalid dates like February 30th.

Fixes #7155.

Testing

  • Visual review
  • CI passes

Deployment

Any special considerations for deployment? n/a

Checklist

If you made changes to the server application code:

  • Linting (make lint) and tests (make test) pass in the development container

If you made non-trivial code changes:

  • I have written a test plan and validated it for this PR

Choose one of the following:

  • These changes do not require documentation

@legoktm legoktm requested a review from a team as a code owner April 30, 2024 19:02
@cfm cfm self-assigned this May 1, 2024
@cfm cfm mentioned this pull request May 1, 2024
2 tasks
Instead of generating month and day separately, generate them at the
same time by randomly selecting a day in the year, and then calculating
the month and date based on that.

This should avoid randomly generating invalid dates like February 30th.

Fixes #7155.
Copy link
Member

@cfm cfm left a comment

Choose a reason for hiding this comment

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

Looks good after rebasing from develop after #7157. Ordinarily I'd want us to add a test case for a bug like this, but I concede it's probably not worth it for a development/test script.

@cfm cfm merged commit af5a574 into develop May 1, 2024
17 checks passed
@legoktm legoktm deleted the loaddata-valid-dates branch May 2, 2024 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Tests failed because random_datetime generated invalid date on April 30
2 participants