Skip to content

Commit

Permalink
Flush to db after entering reading
Browse files Browse the repository at this point in the history
  • Loading branch information
Buried-In-Code committed Dec 22, 2023
1 parent f015eb2 commit 1c37794
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion freyr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from freyr.console import CONSOLE

__version__ = "0.4.0"
__version__ = "0.4.1"


def get_cache_root() -> Path:
Expand Down
5 changes: 3 additions & 2 deletions freyr/routers/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from decimal import Decimal

from fastapi import APIRouter
from pony.orm import db_session
from pony.orm import db_session, flush
from pydantic import BaseModel

from freyr.constants import constants
Expand Down Expand Up @@ -37,4 +37,5 @@ def add_reading(reading: NewReading): # noqa: ANN202
temperature=reading.temperature,
humidity=reading.humidity,
)
constants.cache[device.name] = reading.to_model()
flush()
constants.cache[device.id] = reading.to_model()

0 comments on commit 1c37794

Please sign in to comment.