From 99422217bf8c2c21f791019b2be1846ca0b275a6 Mon Sep 17 00:00:00 2001 From: nmemmert <67961292+nmemmert@users.noreply.github.com> Date: Wed, 5 Nov 2025 15:41:22 -0500 Subject: [PATCH] Add more debugging to job loading and fix sorting - Add prints in load_jobs and save_jobs to track job persistence - Change job sorting to use string timestamps to avoid type comparison errors --- app.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index 719bd30..cefa4e1 100644 --- a/app.py +++ b/app.py @@ -310,12 +310,14 @@ def cleanup_temp_files(): def load_jobs(): """Load jobs from JSON file.""" + print(f"Loading jobs from {JOBS_FILE}") if os.path.exists(JOBS_FILE): try: with open(JOBS_FILE, 'r') as f: jobs = json.load(f) + print(f"Loaded raw jobs: {list(jobs.keys())}") # Convert timestamp strings back to datetime objects - for job in jobs.values(): + for job_id, job in jobs.items(): if 'timestamp' in job and isinstance(job['timestamp'], str): try: # Handle the format: "2025-11-05 09:10:23.730974" @@ -323,13 +325,18 @@ def load_jobs(): except (ValueError, TypeError): # If conversion fails, keep as string pass + print(f"Processed {len(jobs)} jobs") return jobs - except: + except Exception as e: + print(f"Error loading jobs: {e}") return {} + else: + print("Jobs file does not exist") return {} def save_jobs(jobs): """Save jobs to JSON file.""" + print(f"Saving {len(jobs)} jobs to {JOBS_FILE}") with open(JOBS_FILE, 'w') as f: json.dump(jobs, f, indent=2, default=str) @@ -427,7 +434,7 @@ def jobs(): jobs = load_jobs() print(f"Loaded {len(jobs)} jobs") # Sort jobs by timestamp, newest first - sorted_jobs = sorted(jobs.values(), key=lambda x: x['timestamp'], reverse=True) + sorted_jobs = sorted(jobs.values(), key=lambda x: str(x.get('timestamp', '')), reverse=True) return render_template('jobs.html', jobs=sorted_jobs, user_info=get_user_info()) @app.route('/job/')