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

Added a Clean old history command to clean older history entries by cron/task #675

Merged

Conversation

PauloPeres
Copy link
Contributor

Description

I'm only doing 30 days of History as default, but it's a parameters that can be changed.
Creating this command/task to be able to have it on a cron to clean old Historical Entries

Related Issue

Fixing #198 Properly
Also #313

Motivation and Context

Had to create a script to clean the old history because it was causing a too large database on my project, this prevents databases to grow larger than necessary

How Has This Been Tested?

Tested with the databases of my projects and worked, also wrote the coverage tests based on the clean_duplicate_history test bed

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.

@codecov
Copy link

codecov bot commented Jun 16, 2020

Codecov Report

Merging #675 into master will increase coverage by 0.11%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #675      +/-   ##
==========================================
+ Coverage   97.11%   97.23%   +0.11%     
==========================================
  Files          17       18       +1     
  Lines         936      976      +40     
  Branches      140      147       +7     
==========================================
+ Hits          909      949      +40     
  Misses         13       13              
  Partials       14       14              
Impacted Files Coverage Δ
...e_history/management/commands/clean_old_history.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 922f6ce...9670fa4. Read the comment docs.

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.

@PauloPeres thanks for submitting this feature. Just looked through with first round of comments

docs/utils.rst Outdated Show resolved Hide resolved
CHANGES.rst Outdated Show resolved Hide resolved
docs/utils.rst Outdated Show resolved Hide resolved
docs/utils.rst Outdated Show resolved Hide resolved
docs/utils.rst Outdated Show resolved Hide resolved
from ...exceptions import NotHistoricalModelError


class Command(populate_history.Command):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't love inheriting from another command here. Would prefer you refactor the shared functions into a shared commands utils.py

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm kinda Following the same pattern made to clean_duplicate_history.py, it also inherit from populate_history.Command

simple_history/management/commands/clean_old_history.py Outdated Show resolved Hide resolved
simple_history/management/commands/clean_old_history.py Outdated Show resolved Hide resolved
simple_history/management/commands/clean_old_history.py Outdated Show resolved Hide resolved
PauloPeres and others added 3 commits June 19, 2020 12:38
fixing misspeling

Co-authored-by: Ross Mechanic <[email protected]>
Accepting @rossmechanic changes

Co-authored-by: Ross Mechanic <[email protected]>
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

@rossmechanic rossmechanic merged commit 785deba into jazzband:master Jun 19, 2020
@PauloPeres PauloPeres deleted the feature/clean_old_history_command branch June 19, 2020 18:21
@PauloPeres
Copy link
Contributor Author

Thx Guys!

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