This commit is contained in:
@@ -26,6 +26,12 @@ app.add_middleware(
|
||||
)
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
async def health_check():
|
||||
"""Health check endpoint"""
|
||||
return {"status": "healthy", "service": "calendar_service"}
|
||||
|
||||
|
||||
class EntryType(str, Enum):
|
||||
PERIOD = "period"
|
||||
OVULATION = "ovulation"
|
||||
@@ -384,6 +390,34 @@ async def get_health_insights(
|
||||
return [HealthInsightResponse.model_validate(insight) for insight in insights]
|
||||
|
||||
|
||||
@app.get("/api/v1/calendar/entries", response_model=List[CalendarEntryResponse])
|
||||
async def get_all_calendar_entries(
|
||||
start_date: Optional[date] = None,
|
||||
end_date: Optional[date] = None,
|
||||
entry_type: Optional[EntryType] = None,
|
||||
current_user: User = Depends(get_current_user),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
limit: int = Query(100, ge=1, le=500),
|
||||
):
|
||||
"""Get all calendar entries for the current user"""
|
||||
|
||||
query = select(CalendarEntry).filter(CalendarEntry.user_id == current_user.id)
|
||||
|
||||
if start_date:
|
||||
query = query.filter(CalendarEntry.entry_date >= start_date)
|
||||
if end_date:
|
||||
query = query.filter(CalendarEntry.entry_date <= end_date)
|
||||
if entry_type:
|
||||
query = query.filter(CalendarEntry.entry_type == entry_type)
|
||||
|
||||
query = query.order_by(CalendarEntry.entry_date.desc()).limit(limit)
|
||||
|
||||
result = await db.execute(query)
|
||||
entries = result.scalars().all()
|
||||
|
||||
return [CalendarEntryResponse.model_validate(entry) for entry in entries]
|
||||
|
||||
|
||||
@app.delete("/api/v1/entries/{entry_id}")
|
||||
async def delete_calendar_entry(
|
||||
entry_id: int,
|
||||
|
||||
Reference in New Issue
Block a user