Delegate price persistence to PriceRepository

- Add create() method to PriceRepository
- Update PriceService to use repository.create() instead of direct db operations
This commit is contained in:
counterweight 2025-12-25 18:51:24 +01:00
parent 280c1e5687
commit 4cb561d54f
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
2 changed files with 16 additions and 4 deletions

View file

@ -56,3 +56,18 @@ class PriceRepository:
)
)
return result.scalar_one_or_none()
async def create(self, record: PriceHistory) -> PriceHistory:
"""
Create a new price history record.
Args:
record: PriceHistory instance to persist
Returns:
Created PriceHistory record (refreshed from database)
"""
self.db.add(record)
await self.db.commit()
await self.db.refresh(record)
return record