develop #25
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
# nuzlocke-tracker-cftf
|
||||||
|
title: Filter out routes with no encounters for active game
|
||||||
|
status: completed
|
||||||
|
type: task
|
||||||
|
priority: normal
|
||||||
|
created_at: 2026-02-14T14:38:05Z
|
||||||
|
updated_at: 2026-02-14T14:38:19Z
|
||||||
|
---
|
||||||
|
|
||||||
|
Route orders are per version group, so both games in a pair share the same route list. Routes with no encounters for the active game should be filtered out in the list_game_routes endpoint.
|
||||||
@@ -169,7 +169,11 @@ async def list_game_routes(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if flat:
|
if flat:
|
||||||
return [route_to_dict(r) for r in all_routes]
|
return [
|
||||||
|
route_to_dict(r)
|
||||||
|
for r in all_routes
|
||||||
|
if any(re.game_id == game_id for re in r.route_encounters)
|
||||||
|
]
|
||||||
|
|
||||||
# Build hierarchical structure
|
# Build hierarchical structure
|
||||||
# Group children by parent_route_id
|
# Group children by parent_route_id
|
||||||
@@ -180,16 +184,24 @@ async def list_game_routes(
|
|||||||
if route.parent_route_id is None:
|
if route.parent_route_id is None:
|
||||||
top_level_routes.append(route)
|
top_level_routes.append(route)
|
||||||
else:
|
else:
|
||||||
children_by_parent.setdefault(route.parent_route_id, []).append(
|
# Only include children that have encounters for this game
|
||||||
route_to_dict(route)
|
if any(re.game_id == game_id for re in route.route_encounters):
|
||||||
)
|
children_by_parent.setdefault(route.parent_route_id, []).append(
|
||||||
|
route_to_dict(route)
|
||||||
|
)
|
||||||
|
|
||||||
# Build response with nested children
|
# Build response with nested children
|
||||||
|
# Only include top-level routes that have their own encounters or remaining children
|
||||||
response = []
|
response = []
|
||||||
for route in top_level_routes:
|
for route in top_level_routes:
|
||||||
route_dict = route_to_dict(route)
|
children = children_by_parent.get(route.id, [])
|
||||||
route_dict["children"] = children_by_parent.get(route.id, [])
|
has_own_encounters = any(
|
||||||
response.append(route_dict)
|
re.game_id == game_id for re in route.route_encounters
|
||||||
|
)
|
||||||
|
if has_own_encounters or children:
|
||||||
|
route_dict = route_to_dict(route)
|
||||||
|
route_dict["children"] = children
|
||||||
|
response.append(route_dict)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user