Add more debugging for job loading and timestamp handling
- Print if jobs.json exists and file path - Show timestamp conversion details for each job - Print sorted jobs count and first job status - Help diagnose why new jobs aren't appearing
This commit is contained in:
1 parent
c60d6673db
commit
27a6b637c5
1 file changed
+9
-2
@@ -311,6 +311,7 @@ def cleanup_temp_files():
|
|||||||
def load_jobs():
|
def load_jobs():
|
||||||
"""Load jobs from JSON file."""
|
"""Load jobs from JSON file."""
|
||||||
print(f"Loading jobs from {JOBS_FILE}")
|
print(f"Loading jobs from {JOBS_FILE}")
|
||||||
|
print(f"Jobs file exists: {os.path.exists(JOBS_FILE)}")
|
||||||
if os.path.exists(JOBS_FILE):
|
if os.path.exists(JOBS_FILE):
|
||||||
try:
|
try:
|
||||||
with open(JOBS_FILE, 'r') as f:
|
with open(JOBS_FILE, 'r') as f:
|
||||||
@@ -322,9 +323,13 @@ def load_jobs():
|
|||||||
try:
|
try:
|
||||||
# Handle the format: "2025-11-05 09:10:23.730974"
|
# Handle the format: "2025-11-05 09:10:23.730974"
|
||||||
job['timestamp'] = datetime.strptime(job['timestamp'], '%Y-%m-%d %H:%M:%S.%f')
|
job['timestamp'] = datetime.strptime(job['timestamp'], '%Y-%m-%d %H:%M:%S.%f')
|
||||||
except (ValueError, TypeError):
|
print(f"Converted timestamp for job {job_id}: {job['timestamp']}")
|
||||||
|
except (ValueError, TypeError) as e:
|
||||||
|
print(f"Failed to convert timestamp for job {job_id}: {job['timestamp']} - {e}")
|
||||||
# If conversion fails, keep as string
|
# If conversion fails, keep as string
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
print(f"Job {job_id} has timestamp type: {type(job.get('timestamp'))} value: {job.get('timestamp')}")
|
||||||
print(f"Processed {len(jobs)} jobs")
|
print(f"Processed {len(jobs)} jobs")
|
||||||
return jobs
|
return jobs
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -439,7 +444,9 @@ def jobs():
|
|||||||
print(f"Loaded {len(jobs)} jobs: {list(jobs.keys())}")
|
print(f"Loaded {len(jobs)} jobs: {list(jobs.keys())}")
|
||||||
# Sort jobs by timestamp, newest first
|
# Sort jobs by timestamp, newest first
|
||||||
sorted_jobs = sorted(jobs.values(), key=lambda x: str(x.get('timestamp', '')), reverse=True)
|
sorted_jobs = sorted(jobs.values(), key=lambda x: str(x.get('timestamp', '')), reverse=True)
|
||||||
print(f"Sorted jobs: {[j.get('id', 'no-id') for j in sorted_jobs[:5]]}") # First 5
|
print(f"Sorted jobs count: {len(sorted_jobs)}")
|
||||||
|
if sorted_jobs:
|
||||||
|
print(f"First job: {sorted_jobs[0].get('id')} status: {sorted_jobs[0].get('status')}")
|
||||||
return render_template('jobs.html', jobs=sorted_jobs, user_info=get_user_info())
|
return render_template('jobs.html', jobs=sorted_jobs, user_info=get_user_info())
|
||||||
|
|
||||||
@app.route('/job/<job_id>')
|
@app.route('/job/<job_id>')
|
||||||
|
|||||||
Reference in new issue
Block a user