-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix-optimization-status.sql
More file actions
56 lines (49 loc) · 1.43 KB
/
fix-optimization-status.sql
File metadata and controls
56 lines (49 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
-- Fix Optimization Status for Records Marked as FAILED Due to Email Errors
-- This script identifies and fixes optimizations that were marked as FAILED
-- only because email sending failed, but the CV optimization itself succeeded.
-- Step 1: Identify optimizations that have output files but are marked as FAILED
-- These are likely cases where CV optimization succeeded but email failed
SELECT
id,
user_id,
status,
output_cv_path,
cover_letter_path,
error_message,
created_at
FROM optimizations
WHERE status = 'FAILED'
AND output_cv_path IS NOT NULL
AND cover_letter_path IS NOT NULL
ORDER BY created_at DESC;
-- Step 2: Update these records to SUCCEEDED status
-- Uncomment the following lines to execute the fix:
/*
UPDATE optimizations
SET
status = 'SUCCEEDED',
error_message = NULL
WHERE status = 'FAILED'
AND output_cv_path IS NOT NULL
AND cover_letter_path IS NOT NULL;
*/
-- Step 3: Verify the fix
-- Uncomment to check the updated records:
/*
SELECT
id,
user_id,
status,
output_cv_path,
cover_letter_path,
created_at
FROM optimizations
WHERE output_cv_path IS NOT NULL
AND cover_letter_path IS NOT NULL
ORDER BY created_at DESC
LIMIT 10;
*/
-- Note: This fix is safe because:
-- 1. If output_cv_path and cover_letter_path exist, the CV optimization succeeded
-- 2. The FAILED status was likely due to email sending failure
-- 3. With the new code, this won't happen anymore