Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions api/routers/journal_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,22 @@ async def delete_entry(entry_id: str, entry_service: EntryService = Depends(get_
TODO: Implement this endpoint to delete a specific journal entry

Steps to implement:
1. Check if the entry exists first
2. Delete the entry using entry_service
3. Return appropriate response
4. Return 404 if entry not found

Hint: Look at how the update_entry endpoint checks for existence
"""
raise HTTPException(status_code=501, detail="Not implemented - complete this endpoint!")
# 1. Check if the entry exists first
entry_to_delete = await entry_service.get_entry(entry_id)

# 4. Return 404 if entry not found
if not entry_to_delete:
raise HTTPException(status_code=404, detail="Entry not found")

# 2. Delete the entry using entry_service
await entry_service.delete_entry(entry_id)

# 3. Return appropriate response
return {"detail": f"Entry with ID {entry_id} deleted"}

# Hint: Look at how the update_entry endpoint checks for existence
# raise HTTPException(status_code=501, detail="Not implemented - complete this endpoint!")

@router.delete("/entries")
async def delete_all_entries(entry_service: EntryService = Depends(get_entry_service)):
Expand Down