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

@ -52,12 +52,9 @@ class PriceService:
price=price_value,
timestamp=timestamp,
)
self.db.add(record)
try:
await self.db.commit()
await self.db.refresh(record)
return record
return await self.price_repo.create(record)
except IntegrityError:
# Duplicate timestamp - return the existing record
await self.db.rollback()