Reduce overhead to store context ids in the database (#88942)

This commit is contained in:
J. Nick Koston 2023-03-08 14:51:45 -10:00 committed by GitHub
parent 386533a16f
commit 170a13302c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 676 additions and 160 deletions

View file

@ -159,7 +159,7 @@ async def test_get_events(
hass.states.async_set("light.kitchen", STATE_ON, {"brightness": 400})
await hass.async_block_till_done()
context = core.Context(
id="ac5bd62de45711eaaeb351041eec8dd9",
id="01GTDGKBCH00GW0X276W5TEDDD",
user_id="b400facee45711eaa9308bfd3d19e474",
)
@ -239,7 +239,7 @@ async def test_get_events(
"id": 5,
"type": "logbook/get_events",
"start_time": now.isoformat(),
"context_id": "ac5bd62de45711eaaeb351041eec8dd9",
"context_id": "01GTDGKBCH00GW0X276W5TEDDD",
}
)
response = await client.receive_json()
@ -448,7 +448,7 @@ async def test_get_events_with_device_ids(
hass.states.async_set("light.kitchen", STATE_ON, {"brightness": 400})
await hass.async_block_till_done()
context = core.Context(
id="ac5bd62de45711eaaeb351041eec8dd9",
id="01GTDGKBCH00GW0X276W5TEDDD",
user_id="b400facee45711eaa9308bfd3d19e474",
)
@ -1262,7 +1262,7 @@ async def test_subscribe_unsubscribe_logbook_stream(
]
context = core.Context(
id="ac5bd62de45711eaaeb351041eec8dd9",
id="01GTDGKBCH00GW0X276W5TEDDD",
user_id="b400facee45711eaa9308bfd3d19e474",
)
automation_entity_id_test = "automation.alarm"
@ -1300,7 +1300,7 @@ async def test_subscribe_unsubscribe_logbook_stream(
assert msg["type"] == "event"
assert msg["event"]["events"] == [
{
"context_id": "ac5bd62de45711eaaeb351041eec8dd9",
"context_id": "01GTDGKBCH00GW0X276W5TEDDD",
"context_user_id": "b400facee45711eaa9308bfd3d19e474",
"domain": "automation",
"entity_id": "automation.alarm",
@ -1313,7 +1313,7 @@ async def test_subscribe_unsubscribe_logbook_stream(
"context_domain": "automation",
"context_entity_id": "automation.alarm",
"context_event_type": "automation_triggered",
"context_id": "ac5bd62de45711eaaeb351041eec8dd9",
"context_id": "01GTDGKBCH00GW0X276W5TEDDD",
"context_message": "triggered by state of binary_sensor.dog_food_ready",
"context_name": "Mock automation",
"context_source": "state of binary_sensor.dog_food_ready",
@ -1365,7 +1365,7 @@ async def test_subscribe_unsubscribe_logbook_stream(
"context_domain": "automation",
"context_entity_id": "automation.alarm",
"context_event_type": "automation_triggered",
"context_id": "ac5bd62de45711eaaeb351041eec8dd9",
"context_id": "01GTDGKBCH00GW0X276W5TEDDD",
"context_message": "triggered by state of binary_sensor.dog_food_ready",
"context_name": "Mock automation",
"context_source": "state of binary_sensor.dog_food_ready",
@ -1395,7 +1395,7 @@ async def test_subscribe_unsubscribe_logbook_stream(
"context_domain": "automation",
"context_entity_id": "automation.alarm",
"context_event_type": "automation_triggered",
"context_id": "ac5bd62de45711eaaeb351041eec8dd9",
"context_id": "01GTDGKBCH00GW0X276W5TEDDD",
"context_message": "triggered by state of binary_sensor.dog_food_ready",
"context_name": "Mock automation",
"context_source": "state of binary_sensor.dog_food_ready",
@ -1990,7 +1990,7 @@ async def test_logbook_stream_match_multiple_entities(
hass.states.async_set("binary_sensor.should_not_appear", STATE_ON)
hass.states.async_set("binary_sensor.should_not_appear", STATE_OFF)
context = core.Context(
id="ac5bd62de45711eaaeb351041eec8dd9",
id="01GTDGKBCH00GW0X276W5TEDDD",
user_id="b400facee45711eaa9308bfd3d19e474",
)
hass.bus.async_fire(