Justyns purge old data#2059
Merged
Merged
Conversation
Issue home-assistant#1337 When purge_days is set under the history component, recorder.py will delete all events and states that are older than purge_days days ago. Currently, this is only done once at start up. A vacuum command is also run to free up the disk space sqlite would still use after deleting records.
CONF_PURGE_DAYS so it can be changed easier later. Use 'recorder' domain instead of 'history' domain. Pass purge_days config directly into Recorder object instead of passing the config object around.
| self.hass.stop() | ||
| recorder._INSTANCE.block_till_done() | ||
|
|
||
| def _add_test_states(self): |
There was a problem hiding this comment.
- D401: First line should be in imperative mood ('Add', not 'Adds')
Contributor
Author
There was a problem hiding this comment.
358 occurrences of add, 9 of adds. Our style seems to be more add then adds...
Contributor
Author
There was a problem hiding this comment.
So its in the comment not the code.. fixed
Contributor
Author
|
Code clean up of #1681 which can be closed once this gets merged. |
Contributor
|
Thanks for finishing this up, @infamy! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description: Auto purge data older the configured time on startup of hass.
Each time HASS starts, the recorder component will run
_purge_old_data()before going into the event loop._purge_old_data()will delete records from the events and states tables older than X days. After deleting those records,VACUUMis run on the database to free up disk space taken by the deleted records.This also adds a
purge_daysconfig option to the history component. By default it is set to -1 which means no old records will be deleted.Started by @justyns, this is just a clean up and some fixes to hopefully allow us to merge it soon.
Related issue (if applicable): #1681
Example entry for
configuration.yaml(if applicable):Checklist:
If code communicates with devices:
toxrun successfully. Your PR cannot be merged unless tests passREQUIREMENTSvariable (example).requirements_all.txtby runningscript/gen_requirements_all.py..coveragerc.If the code does not interact with devices:
toxrun successfully. Your PR cannot be merged unless tests pass