diff --git a/app.py b/app.py index 66c46a4..09039b9 100644 --- a/app.py +++ b/app.py @@ -311,6 +311,7 @@ def cleanup_temp_files(): def load_jobs(): """Load jobs from JSON file.""" print(f"Loading jobs from {JOBS_FILE}") + print(f"Jobs file exists: {os.path.exists(JOBS_FILE)}") if os.path.exists(JOBS_FILE): try: with open(JOBS_FILE, 'r') as f: @@ -322,9 +323,13 @@ def load_jobs(): try: # Handle the format: "2025-11-05 09:10:23.730974" 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 pass + else: + print(f"Job {job_id} has timestamp type: {type(job.get('timestamp'))} value: {job.get('timestamp')}") print(f"Processed {len(jobs)} jobs") return jobs except Exception as e: @@ -439,7 +444,9 @@ def jobs(): print(f"Loaded {len(jobs)} jobs: {list(jobs.keys())}") # Sort jobs by timestamp, newest first 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()) @app.route('/job/')