from core.database import SchedulerDatabase import json db = SchedulerDatabase() print("=== TUTTI GLI SCHEDULE CHE ESEGUONO 'DataHub Weekly Refresh' ===\n") # Get the job ID with db._get_connection() as conn: cursor = conn.execute("SELECT id, name FROM jobs WHERE name LIKE '%DataHub%Weekly%Refresh%'") job = cursor.fetchone() if job: job_id = job['id'] job_name = job['name'] print(f"Job trovato: ID={job_id}, Name={job_name}\n") # Find all schedules targeting this job cursor = conn.execute(""" SELECT id, name, schedule_type, schedule_config, enabled, target_type, target_id FROM schedules WHERE target_type = 'job' AND target_id = ? """, (job_id,)) schedules = cursor.fetchall() print(f"Schedule diretti per questo job: {len(schedules)}\n") for sched in schedules: config = json.loads(sched['schedule_config']) if isinstance(sched['schedule_config'], str) else sched['schedule_config'] print(f" Schedule ID: {sched['id']}") print(f" Nome: {sched['name']}") print(f" Type: {sched['schedule_type']}") print(f" Config: {config}") print(f" Enabled: {sched['enabled']}") print("-" * 50) # Find groups containing this job print("\n=== GRUPPI CHE CONTENGONO QUESTO JOB ===\n") cursor = conn.execute(""" SELECT jg.id, jg.name, jg.description, jgm.execution_order FROM job_groups jg JOIN job_group_members jgm ON jg.id = jgm.group_id WHERE jgm.job_id = ? ORDER BY jg.name, jgm.execution_order """, (job_id,)) groups = cursor.fetchall() print(f"Gruppi trovati: {len(groups)}\n") for grp in groups: print(f" Group ID: {grp['id']}") print(f" Nome: {grp['name']}") print(f" Order: {grp['execution_order']}") # Find schedules for this group cursor2 = conn.execute(""" SELECT id, name, schedule_type, schedule_config, enabled FROM schedules WHERE target_type = 'group' AND target_id = ? """, (grp['id'],)) group_schedules = cursor2.fetchall() if group_schedules: print(f" Schedules per questo gruppo:") for gs in group_schedules: config = json.loads(gs['schedule_config']) if isinstance(gs['schedule_config'], str) else gs['schedule_config'] print(f" - Schedule ID: {gs['id']}, Name: {gs['name']}") print(f" Type: {gs['schedule_type']}, Config: {config}, Enabled: {gs['enabled']}") print("-" * 50) else: print("Job 'DataHub Weekly Refresh' non trovato!")