Commit graph

963 commits

Author SHA1 Message Date
Erik Montnemery
6921e053e4
Move recorder data migration implementation to migrators (#122045) 2024-07-17 10:59:58 +02:00
Erik Montnemery
9970b7eece
Refactor recorder data migration (#121009)
* Refactor recorder data migration

* Fix stale docstrings

* Don't store a session object in BaseRunTimeMigration instances

* Simplify logic in EntityIDMigration.migration_done

* Fix tests
2024-07-16 21:50:19 +02:00
Erik Montnemery
a22e12dac9
Refactor function recorder.migration._apply_update (#122023)
* Refactor function recorder.migration._apply_update

* Remove _SchemaVersionMigrators dict
2024-07-16 20:28:03 +02:00
Erik Montnemery
d8440e809a
Avoid mutating database schema definitions during schema migration (#122012)
* Avoid mutating database schema definitions during schema migration

* Adjust test when using mysql

* Address review comment
2024-07-16 20:27:49 +02:00
Erik Montnemery
dbe68ca057
Minor adjustment of recorder migration (#122020) 2024-07-16 14:20:23 +02:00
J. Nick Koston
73f6e3c07b
Narrow sqlite database corruption check to ensure disk image is malformed (#121947)
* Narrow sqlite database corruption check to ensure disk image is malformed

The database corruption check would also replace the database when it
locked externally instead of only when its malformed.

This was discovered in https://github.com/home-assistant/core/issues/121909#issuecomment-2227409124
when a user did a manual index creation while HA was online

* tweak

* tweak

* fix

* fix
2024-07-14 23:23:07 +02:00
J. Nick Koston
19d2d023ab
Ensure states table rebuild still happens if the event_id index was removed (#121938)
* Ensure states table rebuild still happens if the event_id index was removed

If ix_states_event_id was removed by the foreign key still
exists, the states table would not get rebuilt. This should
not happen under normal circumstances and seems to only be
possible if the index was removed manually or Home
Assistant was restarted forcefully in the middle
of a previous migration from years ago.

* cover

* fix tests

* mysql wont allow at that point but thats ok as long as its gone at the end
2024-07-14 23:20:52 +02:00
J. Nick Koston
8a52ffb967
Use a listcomp for more history results (#121830) 2024-07-12 16:10:21 +02:00
J. Nick Koston
ebd50d327b
Log add/remove index complete at the same level as when it starts (#121852) 2024-07-12 15:54:38 +02:00
J. Nick Koston
43596f22a4
Fix recorder max backlog calculation being too small (#121739) 2024-07-11 09:09:35 +02:00
J. Nick Koston
c81d5a1ac2
Handle empty entity_id in the recorder filter (#121681)
fixes #111745
2024-07-10 09:53:38 -05:00
epenet
bff663b3c1
Improve type hints in recorder result_processor (#121593) 2024-07-09 21:12:03 +02:00
J. Nick Koston
89ffee9ad5
Update ulid-transform to 0.10.1 (#121321) 2024-07-05 14:07:39 -05:00
Erik Montnemery
6eeb70151d
Use BIGINT SQL type for ID columns (#121025) 2024-07-05 10:42:39 -05:00
Erik Montnemery
61f1c8d963
Fix leak of SQLAlchemy engine objects in recorder (#121085) 2024-07-03 12:17:52 -05:00
Erik Montnemery
e26b4554e6
Improve logic when retrying establishing database connection (#121047) 2024-07-03 16:22:21 +02:00
Erik Montnemery
a4d889e958
Remove BaseTableManager active attribute (#121020) 2024-07-02 18:29:12 -05:00
Erik Montnemery
5b39989869
Fix typo in post_schema_migration (#121017) 2024-07-02 15:52:54 +02:00
Marc Mueller
ca55986057
Import Generator from collections.abc (1) (#120914) 2024-07-01 11:51:51 +02:00
J. Nick Koston
c5804d362c
Remove legacy foreign key constraint from sqlite states table (#120779) 2024-06-29 07:50:53 -05:00
J. Nick Koston
852bb19223
Cleanup db_schema from_event constructors (#120803) 2024-06-29 07:49:16 -05:00
J. Nick Koston
0dfb5bd7d9
Fix unneeded dict values for MATCH_ALL recorder attrs exclude (#120804)
* Small cleanup to handling MATCH_ALL recorder attrs exclude

* Fix unneeded dict values for MATCH_ALL recorder attrs exclude

The exclude is a set so the dict values were not needed

* Fix unneeded dict values for MATCH_ALL recorder attrs exclude

The exclude is a set so the dict values were not needed

* Fix unneeded dict values for MATCH_ALL recorder attrs exclude

The exclude is a set so the dict values were not needed
2024-06-29 07:42:08 +02:00
J. Nick Koston
b03c10647e
Fix stale docstring in recorder queries (#120763) 2024-06-28 16:29:12 -05:00
Marc Mueller
b798d76706
Update mypy-dev to 1.11.0a9 (#120289) 2024-06-24 09:57:15 +02:00
G Johansson
753ab08b5e
Add capability to exclude all attributes from recording (#119725) 2024-06-22 19:30:28 +02:00
Marc Mueller
f0452e9ba0
Update mypy dev 1.11.0a8 (#120032) 2024-06-21 13:15:18 +02:00
dontinelli
0dd5391cd7
Add Siemes and Millisiemens as additional units of conductivity and enable conversion between conductivity units (#118728) 2024-06-21 11:10:15 +02:00
J. Nick Koston
a642454e6f
Bump sqlalchemy to 2.0.31 (#119951) 2024-06-19 08:09:04 +02:00
J. Nick Koston
9082dc2a79
Reduce recorder overhead when entity filter is empty (#119631) 2024-06-14 08:43:51 +02:00
Erik Montnemery
8c27214dc9
Use statistic tables' duration attribute instead of magic numbers (#119356) 2024-06-11 15:12:20 +02:00
J. Nick Koston
3308f07d4b
Speed up generating large stats results (#119210)
* Speed up generating large stats results

* naming

* fix type

* fix type

* tweak

* tweak

* delete unused code
2024-06-10 21:22:59 -04:00
Erik Montnemery
def9d5b101
Fix statistic_during_period after core restart (#119323) 2024-06-10 21:44:55 +02:00
karwosts
aa419686cb
Fix statistic_during_period wrongly prioritizing ST statistics over LT (#115291)
* Fix statistic_during_period wrongly prioritizing ST statistics over LT

* comment

* start of a test

* more testcases

* fix sts insertion range

* update from review

* remove unneeded comments

* update logic

* min/mean/max testing
2024-06-10 20:23:21 +02:00
J. Nick Koston
7065c0993d
Reduce overhead to reduce statistics (#119187) 2024-06-09 18:33:10 +02:00
J. Nick Koston
909df675e0
Use a listcomp for history results (#119188) 2024-06-09 18:32:33 +02:00
Marc Mueller
fe21e2b8ba
Import Generator from typing_extensions (1) (#118986) 2024-06-06 17:02:13 +02:00
J. Nick Koston
35a1ecea27
Speed up statistics_during_period websocket api (#118672) 2024-06-03 18:08:46 -05:00
J. Nick Koston
588380392d
Small speed up to read-only database sessions (#118674) 2024-06-03 19:50:05 +02:00
J. Nick Koston
099ad77078
Migrate recorder instance to use HassKey (#118673) 2024-06-03 11:19:00 -05:00
J. Nick Koston
134088e1f6
Revert "Add websocket API to get list of recorded entities (#92640)" (#118644)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2024-06-03 10:11:24 +02:00
J. Nick Koston
51ed4f89ec
Use more efficient chunked_or_all for recorder table managers (#118646) 2024-06-02 13:04:53 -05:00
Marc Mueller
dbb27755a4
Update mypy-dev to 1.11.0a5 (#118519) 2024-06-02 15:28:24 +02:00
J. Nick Koston
0888233f06
Make Recorder dialect_name a cached_property (#117922) 2024-05-29 09:23:40 +02:00
Jan Bouwhuis
c616fc036e
Move recorder chunk utils to shared collection utils (#118065) 2024-05-24 12:49:39 -10:00
Marc Mueller
dd22ee3dac
Improve annotation styling (#118032) 2024-05-24 15:05:53 +02:00
Sid
c2b3bf3fb9
Enable Ruff RET502 (#115139) 2024-05-21 22:19:33 +02:00
Marc Mueller
bc2ee96cae
Remove quotes surrounding annotations (#117817) 2024-05-20 22:06:58 +02:00
J. Nick Koston
5a609c34bb
Fix blocking I/O in the event loop when loading timezones (#117721) 2024-05-20 11:06:03 +02:00
Marc Mueller
eedce95bc9
Use PEP 695 for class annotations (2) (#117776) 2024-05-20 10:43:59 +02:00
Marc Mueller
26a599ad11
Use PEP 695 for function annotations (1) (#117658) 2024-05-18 11:45:54 +02:00