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:
parent
280c1e5687
commit
4cb561d54f
2 changed files with 16 additions and 4 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue