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: do not load historic in memory in clean_old_history command #735

Merged
merged 1 commit into from
Nov 12, 2020

Conversation

vied12
Copy link
Contributor

@vied12 vied12 commented Nov 6, 2020

uses query.count() instead of len(query) to count entries to be deleted

Description

clean_old_history command used to count entries to delete with len(). This loads in memory all the entries and can lead to crash in case memory limit is reached. Using a sql query to count to entries is faster and safer.

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 Nov 6, 2020

Codecov Report

Merging #735 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #735   +/-   ##
=======================================
  Coverage   97.44%   97.44%           
=======================================
  Files          18       18           
  Lines         980      980           
  Branches      148      148           
=======================================
  Hits          955      955           
  Misses         12       12           
  Partials       13       13           
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 71a2ebc...d97b12b. Read the comment docs.

Copy link
Collaborator

@ThePumpingLemma ThePumpingLemma left a comment

Choose a reason for hiding this comment

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

Good catch!

@ThePumpingLemma ThePumpingLemma merged commit c05255c into jazzband:master Nov 12, 2020
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