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

feat: add default_date optional parameter for bulk create and update #687

Merged
merged 2 commits into from
Aug 6, 2020

Conversation

sbor23
Copy link
Contributor

@sbor23 sbor23 commented Jul 15, 2020

Add default_date parameter for bulk creating and updating historical entries.

Description

This change adds a keyword argument default_date to the bulk_history_create() method on the HistoryManager, as well as the utility functions bulk_create_with_history() and bulk_update_with_history().
If provided, the created or updated history entries will have the field history_date set to this date.

Related Issue

#686

Motivation and Context

It provides an easy way to set the history_date when dealing with bulk operations.

How Has This Been Tested?

Unittests have been added.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have run the make format command to format my code
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have added my name and/or github handle to AUTHORS.rst
  • I have added my change to CHANGES.rst
  • All new and existing tests passed.

@rossmechanic
Copy link
Collaborator

Hi @sbor23 not sure what happened with the hooks for travis. Can you try repushing this so I can see tests?

@sbor23
Copy link
Contributor Author

sbor23 commented Aug 5, 2020

Hi @sbor23 not sure what happened with the hooks for travis. Can you try repushing this so I can see tests?

Sure, did that :)

Copy link
Collaborator

@rossmechanic rossmechanic left a comment

Choose a reason for hiding this comment

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

just one change otherwise looks good to me

Comment on lines 130 to 131
history_date=default_date
or getattr(instance, "_history_date", timezone.now()),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would prefer that this follow the pattern of _history_user, such that _history_date takes precedence over default_date

Copy link
Contributor Author

@sbor23 sbor23 Aug 6, 2020

Choose a reason for hiding this comment

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

Ah true, _history_date gives more fine-grained control so it should take precedence. Haven't really used it yet. :)

Copy link
Collaborator

@rossmechanic rossmechanic left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @sbor23

@rossmechanic rossmechanic merged commit 8bbcf56 into jazzband:master Aug 6, 2020
@sbor23 sbor23 deleted the feat-default-date branch August 26, 2020 15:20
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.

None yet

2 participants