mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 08:51:13 -05:00
Fix retry flashing and reloading
This commit is contained in:
@@ -262,20 +262,7 @@ serve(async (req) => {
|
||||
dependencyMap.set(item.id, entityId);
|
||||
}
|
||||
|
||||
// Update item status
|
||||
const { error: updateError } = await supabase
|
||||
.from('submission_items')
|
||||
.update({
|
||||
status: 'approved',
|
||||
approved_entity_id: entityId,
|
||||
updated_at: new Date().toISOString()
|
||||
})
|
||||
.eq('id', item.id);
|
||||
|
||||
if (updateError) {
|
||||
throw new Error(`Failed to update item status: ${updateError.message}`);
|
||||
}
|
||||
|
||||
// Store result for batch update later
|
||||
approvalResults.push({
|
||||
itemId: item.id,
|
||||
entityId,
|
||||
@@ -300,19 +287,61 @@ serve(async (req) => {
|
||||
error: error instanceof Error ? error.message : 'Unknown error',
|
||||
isDependencyFailure: isDependencyError
|
||||
});
|
||||
|
||||
// Mark item as rejected in submission_items
|
||||
const { error: markRejectedError } = await supabase
|
||||
}
|
||||
}
|
||||
|
||||
// Batch update all approved items
|
||||
const approvedItemIds = approvalResults.filter(r => r.success).map(r => r.itemId);
|
||||
if (approvedItemIds.length > 0) {
|
||||
const approvedUpdates = approvalResults
|
||||
.filter(r => r.success)
|
||||
.map(r => ({
|
||||
id: r.itemId,
|
||||
status: 'approved',
|
||||
approved_entity_id: r.entityId,
|
||||
updated_at: new Date().toISOString()
|
||||
}));
|
||||
|
||||
for (const update of approvedUpdates) {
|
||||
const { error: batchApproveError } = await supabase
|
||||
.from('submission_items')
|
||||
.update({
|
||||
status: 'rejected',
|
||||
rejection_reason: error instanceof Error ? error.message : 'Unknown error',
|
||||
updated_at: new Date().toISOString()
|
||||
status: update.status,
|
||||
approved_entity_id: update.approved_entity_id,
|
||||
updated_at: update.updated_at
|
||||
})
|
||||
.eq('id', item.id);
|
||||
.eq('id', update.id);
|
||||
|
||||
if (markRejectedError) {
|
||||
console.error(`Failed to mark item ${item.id} as rejected:`, markRejectedError);
|
||||
if (batchApproveError) {
|
||||
console.error(`Failed to approve item ${update.id}:`, batchApproveError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Batch update all rejected items
|
||||
const rejectedItemIds = approvalResults.filter(r => !r.success).map(r => r.itemId);
|
||||
if (rejectedItemIds.length > 0) {
|
||||
const rejectedUpdates = approvalResults
|
||||
.filter(r => !r.success)
|
||||
.map(r => ({
|
||||
id: r.itemId,
|
||||
status: 'rejected',
|
||||
rejection_reason: r.error || 'Unknown error',
|
||||
updated_at: new Date().toISOString()
|
||||
}));
|
||||
|
||||
for (const update of rejectedUpdates) {
|
||||
const { error: batchRejectError } = await supabase
|
||||
.from('submission_items')
|
||||
.update({
|
||||
status: update.status,
|
||||
rejection_reason: update.rejection_reason,
|
||||
updated_at: update.updated_at
|
||||
})
|
||||
.eq('id', update.id);
|
||||
|
||||
if (batchRejectError) {
|
||||
console.error(`Failed to reject item ${update.id}:`, batchRejectError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user