Handling of total amount in shopping events
This commit is contained in:
@@ -200,7 +200,7 @@ def create_shopping_event(event: schemas.ShoppingEventCreate, db: Session = Depe
|
||||
|
||||
@app.get("/shopping-events/", response_model=List[schemas.ShoppingEventResponse])
|
||||
def read_shopping_events(skip: int = 0, limit: int = 100, db: Session = Depends(get_db)):
|
||||
events = db.query(models.ShoppingEvent).offset(skip).limit(limit).all()
|
||||
events = db.query(models.ShoppingEvent).order_by(models.ShoppingEvent.created_at.desc()).offset(skip).limit(limit).all()
|
||||
return [build_shopping_event_response(event, db) for event in events]
|
||||
|
||||
@app.get("/shopping-events/{event_id}", response_model=schemas.ShoppingEventResponse)
|
||||
|
||||
@@ -53,7 +53,7 @@ class Shop(ShopBase):
|
||||
class GroceryInEvent(BaseModel):
|
||||
grocery_id: int
|
||||
amount: float = Field(..., gt=0)
|
||||
price: float = Field(..., gt=0) # Price at the time of this shopping event
|
||||
price: float = Field(..., ge=0) # Price at the time of this shopping event (allow free items)
|
||||
|
||||
class GroceryWithEventData(BaseModel):
|
||||
id: int
|
||||
|
||||
Reference in New Issue
Block a user