@@ -115,7 +115,7 @@ class LocationsResponse(BaseModel):
115115# API Endpoints
116116
117117
118- @router .post ("/generate" , response_model = GenerateMemoriesResponse )
118+ @router .post ("/generate" )
119119def generate_memories (
120120 location_radius_km : float = Query (
121121 5.0 , ge = 0.1 , le = 100 , description = "Location clustering radius in km"
@@ -143,13 +143,15 @@ def generate_memories(
143143 images = db_get_all_images_for_memories ()
144144
145145 if not images :
146- return GenerateMemoriesResponse (
147- success = True ,
148- message = "No images found" ,
149- memory_count = 0 ,
150- image_count = 0 ,
151- memories = [],
152- )
146+ return {
147+ "data" : {
148+ "memory_count" : 0 ,
149+ "image_count" : 0 ,
150+ "memories" : [],
151+ },
152+ "success" : True ,
153+ "message" : "No images found" ,
154+ }
153155
154156 logger .info (f"Processing { len (images )} images" )
155157
@@ -170,20 +172,22 @@ def generate_memories(
170172 f"Generated { len (memories )} memories (location: { location_count } , date: { date_count } )"
171173 )
172174
173- return GenerateMemoriesResponse (
174- success = True ,
175- message = f"{ len (memories )} memories ({ location_count } location, { date_count } date)" ,
176- memory_count = len (memories ),
177- image_count = len (images ),
178- memories = memories ,
179- )
175+ return {
176+ "data" : {
177+ "memory_count" : len (memories ),
178+ "image_count" : len (images ),
179+ "memories" : memories ,
180+ },
181+ "success" : True ,
182+ "message" : f"{ len (memories )} memories ({ location_count } location, { date_count } date)" ,
183+ }
180184
181185 except Exception :
182186 logger .error ("Error generating memories" , exc_info = True )
183187 raise HTTPException (status_code = 500 , detail = "Failed to generate memories" )
184188
185189
186- @router .get ("/timeline" , response_model = TimelineResponse )
190+ @router .get ("/timeline" )
187191def get_timeline (
188192 days : int = Query (365 , ge = 1 , le = 3650 , description = "Number of days to look back" ),
189193 location_radius_km : float = Query (
@@ -224,15 +228,18 @@ def get_timeline(
224228 images = db_get_images_by_date_range (start_date , end_date )
225229
226230 if not images :
227- return TimelineResponse (
228- success = True ,
229- date_range = {
230- "start" : start_date .isoformat (),
231- "end" : end_date .isoformat (),
231+ return {
232+ "data" : {
233+ "date_range" : {
234+ "start" : start_date .isoformat (),
235+ "end" : end_date .isoformat (),
236+ },
237+ "memory_count" : 0 ,
238+ "memories" : [],
232239 },
233- memory_count = 0 ,
234- memories = [] ,
235- )
240+ "success" : True ,
241+ "message" : "No images found in date range" ,
242+ }
236243
237244 logger .info (f"Found { len (images )} images in date range" )
238245
@@ -245,19 +252,25 @@ def get_timeline(
245252
246253 memories = clustering .cluster_memories (images )
247254
248- return TimelineResponse (
249- success = True ,
250- date_range = {"start" : start_date .isoformat (), "end" : end_date .isoformat ()},
251- memory_count = len (memories ),
252- memories = memories ,
253- )
255+ return {
256+ "data" : {
257+ "date_range" : {
258+ "start" : start_date .isoformat (),
259+ "end" : end_date .isoformat (),
260+ },
261+ "memory_count" : len (memories ),
262+ "memories" : memories ,
263+ },
264+ "success" : True ,
265+ "message" : f"Found { len (memories )} memories" ,
266+ }
254267
255268 except Exception :
256269 logger .error ("Error getting timeline" , exc_info = True )
257270 raise HTTPException (status_code = 500 , detail = "Failed to get timeline" )
258271
259272
260- @router .get ("/on-this-day" , response_model = OnThisDayResponse )
273+ @router .get ("/on-this-day" )
261274def get_on_this_day ():
262275 """
263276 Get photos taken on this date in previous years.
@@ -339,20 +352,23 @@ def parse_captured_at(img):
339352
340353 all_images .sort (key = parse_captured_at , reverse = True )
341354
342- return OnThisDayResponse (
343- success = True ,
344- today = today .strftime ("%B %d" ),
345- years = sorted (years_found , reverse = True ),
346- image_count = len (all_images ),
347- images = all_images ,
348- )
355+ return {
356+ "data" : {
357+ "today" : today .strftime ("%B %d" ),
358+ "years" : sorted (years_found , reverse = True ),
359+ "image_count" : len (all_images ),
360+ "images" : all_images ,
361+ },
362+ "success" : True ,
363+ "message" : f"Found { len (all_images )} images from { len (years_found )} years" ,
364+ }
349365
350366 except Exception :
351367 logger .error ("Error getting 'On This Day'" , exc_info = True )
352368 raise HTTPException (status_code = 500 , detail = "Failed to get 'On This Day'" )
353369
354370
355- @router .get ("/locations" , response_model = LocationsResponse )
371+ @router .get ("/locations" )
356372def get_locations (
357373 location_radius_km : float = Query (
358374 5.0 , ge = 0.1 , le = 100 , description = "Location clustering radius in km"
@@ -387,7 +403,11 @@ def get_locations(
387403 images = db_get_images_with_location ()
388404
389405 if not images :
390- return LocationsResponse (success = True , location_count = 0 , locations = [])
406+ return {
407+ "data" : {"location_count" : 0 , "locations" : []},
408+ "success" : True ,
409+ "message" : "No images with location data" ,
410+ }
391411
392412 logger .info (f"Found { len (images )} images with location data" )
393413
@@ -434,9 +454,14 @@ def get_locations(
434454 # Sort by image count (most photos first)
435455 locations .sort (key = lambda loc : loc .image_count , reverse = True )
436456
437- return LocationsResponse (
438- success = True , location_count = len (locations ), locations = locations
439- )
457+ return {
458+ "data" : {
459+ "location_count" : len (locations ),
460+ "locations" : locations ,
461+ },
462+ "success" : True ,
463+ "message" : f"Found { len (locations )} locations" ,
464+ }
440465
441466 except Exception :
442467 logger .error ("Error getting locations" , exc_info = True )
0 commit comments