mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 10:11:13 -05:00
Improve image handling, optimize hooks, and add rate limiting
This commit introduces several improvements: - Enhances `RideModelCard` by safely accessing and displaying ride count and image data, preventing potential errors. - Refactors `useEntityVersions` and `useSearch` hooks to use `useCallback` and improve performance and prevent race conditions. - Introduces a `MAX_MAP_SIZE` and cleanup mechanism for the rate limiting map in `detect-location` Supabase function to prevent memory leaks. - Adds robust error handling and cleanup for image uploads in `uploadPendingImages`. - Modifies `ManufacturerModels` to correctly map and display ride counts. - Includes error handling for topological sort in `process-selective-approval` Supabase function. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 39bb006b-d046-477f-a1f9-b7821836f3a1 Replit-Commit-Checkpoint-Type: intermediate_checkpoint
This commit is contained in:
@@ -170,7 +170,22 @@ serve(async (req) => {
|
||||
const submitterId = submission.user_id;
|
||||
|
||||
// Topologically sort items by dependencies
|
||||
const sortedItems = topologicalSort(items);
|
||||
let sortedItems;
|
||||
try {
|
||||
sortedItems = topologicalSort(items);
|
||||
} catch (sortError) {
|
||||
const errorMessage = sortError instanceof Error ? sortError.message : 'Failed to sort items';
|
||||
console.error('Topological sort failed:', errorMessage);
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error: 'Invalid submission structure',
|
||||
message: errorMessage,
|
||||
details: 'The submission contains circular dependencies or missing required items'
|
||||
}),
|
||||
{ status: 400, headers: { ...corsHeaders, 'Content-Type': 'application/json' } }
|
||||
);
|
||||
}
|
||||
|
||||
const dependencyMap = new Map<string, string>();
|
||||
const approvalResults: Array<{
|
||||
itemId: string;
|
||||
|
||||
Reference in New Issue
Block a user