This commit is contained in:
@@ -34,6 +34,64 @@ async def health_check():
|
||||
"""Health check endpoint"""
|
||||
return {"status": "healthy", "service": "calendar_service"}
|
||||
|
||||
@app.get("/debug/entries")
|
||||
async def debug_entries(db: AsyncSession = Depends(get_db)):
|
||||
"""Debug endpoint for entries without auth"""
|
||||
# Получить последние 10 записей из БД для отладки
|
||||
query = select(CalendarEntry).limit(10)
|
||||
result = await db.execute(query)
|
||||
entries = result.scalars().all()
|
||||
|
||||
# Преобразовать в словари для ответа
|
||||
entries_list = []
|
||||
for entry in entries:
|
||||
entry_dict = {
|
||||
"id": entry.id,
|
||||
"user_id": entry.user_id,
|
||||
"entry_date": str(entry.entry_date),
|
||||
"entry_type": entry.entry_type,
|
||||
"note": entry.notes,
|
||||
"symptoms": entry.symptoms,
|
||||
"flow_intensity": entry.flow_intensity,
|
||||
"mood": entry.mood,
|
||||
"created_at": str(entry.created_at)
|
||||
}
|
||||
entries_list.append(entry_dict)
|
||||
|
||||
return entries_list
|
||||
|
||||
@app.get("/debug/add-entry")
|
||||
async def debug_add_entry(db: AsyncSession = Depends(get_db)):
|
||||
"""Debug endpoint to add a test entry without auth"""
|
||||
try:
|
||||
# Создаем тестовую запись
|
||||
new_entry = CalendarEntry(
|
||||
user_id=29, # ID пользователя
|
||||
entry_date=date.today(),
|
||||
entry_type="period",
|
||||
flow_intensity="medium",
|
||||
period_symptoms=["cramps", "headache"],
|
||||
mood="neutral",
|
||||
symptoms=["headache", "cramps"],
|
||||
notes="Test entry added via debug endpoint",
|
||||
is_predicted=False
|
||||
)
|
||||
|
||||
db.add(new_entry)
|
||||
await db.commit()
|
||||
await db.refresh(new_entry)
|
||||
|
||||
return {
|
||||
"message": "Test entry added successfully",
|
||||
"entry_id": new_entry.id,
|
||||
"user_id": new_entry.user_id,
|
||||
"entry_date": str(new_entry.entry_date),
|
||||
"entry_type": new_entry.entry_type
|
||||
}
|
||||
except Exception as e:
|
||||
await db.rollback()
|
||||
return {"error": str(e)}
|
||||
|
||||
|
||||
# Используем классы из schemas
|
||||
|
||||
|
||||
Reference in New Issue
Block a user