* Reduce database queries to necessary labels
* Set columns for other queries
* skip creating model instances
---------
Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>
* Store camera labels in dict and other optimizations
* Add max on timeout so it is at least 60
* Ensure db timeout is at least 60
* Update list once a day to ensure new labels are cleaned up
* Formatting
* Insert recordings as bulk instead of individually.
* Fix
* Refactor event and timeline cleanup
* Remove unused
* "Refactor storage stats calculation to use powers of 2 for more accurate values"
* replace 1000000 to 2^20
* Refactor storage unit size display to use binary prefixes
This commit updates the display of storage unit sizes in both the camera storage stats and the Storage component in the web UI to use binary prefixes (MiB and GiB) instead of decimal prefixes (MB and GB). This provides more accurate and consistent representation of storage sizes
* Enable auto vacuums
* Enable auto vacuum
* Fix separator
* Fix separator and remove incorrect log
* Limit to 1 row since that is all that is used
* Add index on camera + segment_size
* Formatting
* Increase timeout and cache_size
* Set DB mode to NORMAL synchronous level
* Formatting
* Vacuum every 2 weeks
* Remove fstring
* Use string
* Use consts
* Add isort and ruff linter
Both linters are pretty common among modern python code bases.
The isort tool provides stable sorting and grouping, as well as pruning
of unused imports.
Ruff is a modern linter, that is very fast due to being written in rust.
It can detect many common issues in a python codebase.
Removes the pylint dev requirement, since ruff replaces it.
* treewide: fix issues detected by ruff
* treewide: fix bare except clauses
* .devcontainer: Set up isort
* treewide: optimize imports
* treewide: apply black
* treewide: make regex patterns raw strings
This is necessary for escape sequences to be properly recognized.
* Get storage output stats for each camera
* Add storage route
* Add storage route
* Add storage page
* Cleanup
* Add stats and show more storage
* Add tests for mb abbrev util fun
* Rewrite storage logic to use storage maintainer and segment sizes
* Include storage maintainer for http
* Use correct format
* Remove utils
* Fix tests
* Remove total from equation
* Multiply by 100 to get percent
* Add basic storage info
* Fix storage stats
* Fix endpoint and ui
* Fix formatting
* Add field and migration for segment size
* Store the segment size in db
* Add comment
* Add default
* Fix size parsing
* Include segment size in recordings endpoint
* Start adding storage maintainer
* Add storage maintainer and calculate average sizes
* Update comment
* Store segment and hour avg sizes per camera
* Formatting
* Keep track of total segment and hour averages
* Remove unused files
* Cleanup 2 hours of recordings at a time
* Formatting
* Fix bug
* Round segment size
* Cleanup some comments
* Handle case where segments are not deleted on initial run or is only retained segments
* Improve cleanup log
* Formatting
* Fix typo and improve logging
* Catch case where no recordings exist for camera
* Specifically define sort
* Handle edge case for cameras that only record part time
* Increase definition of part time recorder
* Remove warning about not supported storage based retention
* Add note about storage based retention to recording docs
* Add tests for storage maintenance calculation and cleanup
* Format tests
* Don't run for a camera with no recording segments
* Get size of file from cache
* Rework camera stats to be more efficient
* Remove total and other inefficencies
* Rewrite storage cleanup logic to be much more efficient
* Fix existing tests
* Fix bugs from tests
* Add another test
* Improve logging
* Formatting
* Set back correct loop time
* Update name
* Update comment
* Only include segments that have a nonzero size
* Catch case where camera has 0 nonzero segment durations
* Add test to cover zero bandwidth migration case
* Fix test
* Incorrect boolean logic
* Formatting
* Explicity re-define iterator