mirror of
https://github.com/R0m1k3/Priceflow.git
synced 2026-10-11 17:29:14 +02:00
Merge pull request #48 from R0m1k3/antigravity
feat: Introduce item API endpoints for CRUD, category management, pri…
This commit is contained in:
2 files changed
+27
No files matched your search
@@ -69,3 +69,21 @@ def check_item(
|
||||
|
||||
background_tasks.add_task(process_item_check, item_id)
|
||||
return {"message": "Check triggered"}
|
||||
|
||||
|
||||
@router.get("/{item_id}/price-history", response_model=list[schemas.PriceHistoryResponse])
|
||||
def get_price_history(item_id: int, db: Session = Depends(database.get_db)):
|
||||
"""Get price history for a specific item"""
|
||||
item = db.query(models.Item).filter(models.Item.id == item_id).first()
|
||||
if not item:
|
||||
raise HTTPException(status_code=404, detail="Item not found")
|
||||
|
||||
# Get price history sorted by timestamp descending (most recent first)
|
||||
price_history = (
|
||||
db.query(models.PriceHistory)
|
||||
.filter(models.PriceHistory.item_id == item_id)
|
||||
.order_by(models.PriceHistory.timestamp.desc())
|
||||
.all()
|
||||
)
|
||||
|
||||
return price_history
|
||||
@@ -48,6 +48,15 @@ class ItemResponse(ItemCreate):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
class PriceHistoryResponse(BaseModel):
|
||||
id: int
|
||||
price: float
|
||||
timestamp: datetime
|
||||
price_confidence: float | None = None
|
||||
in_stock_confidence: float | None = None
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
class SettingsUpdate(BaseModel):
|
||||
key: str
|
||||
value: str
|
||||
|
||||
Reference in new issue
Block a user