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):
|
class EntryType(str, Enum):
|
||||||
PERIOD = "period"
|
PERIOD = "period"
|
||||||
OVULATION = "ovulation"
|
OVULATION = "ovulation"
|
||||||
@@ -384,6 +390,34 @@ async def get_health_insights(
|
|||||||
return [HealthInsightResponse.model_validate(insight) for insight in 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}")
|
@app.delete("/api/v1/entries/{entry_id}")
|
||||||
async def delete_calendar_entry(
|
async def delete_calendar_entry(
|
||||||
entry_id: int,
|
entry_id: int,
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class BaseModel(Base):
|
|||||||
|
|
||||||
id = Column(Integer, primary_key=True, index=True)
|
id = Column(Integer, primary_key=True, index=True)
|
||||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
|
||||||
is_active = Column(Boolean, default=True)
|
is_active = Column(Boolean, default=True)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user