This commit is contained in:
29
app.py
29
app.py
@@ -70,20 +70,21 @@ def create_app():
|
||||
user_id = config.user_id
|
||||
mappings = config.mappings
|
||||
for sheer_title, params in mappings.items():
|
||||
cron_schedule = params.get('schedule_cron')
|
||||
if cron_schedule:
|
||||
job_id = f"user_{user_id}_sheet_{sheer_title}"
|
||||
try:
|
||||
scheduler.add_job(
|
||||
id=job_id,
|
||||
func=execute_olap_export,
|
||||
trigger='cron',
|
||||
args=[user_id, sheer_title],
|
||||
**_parse_cron_string(cron_schedule)
|
||||
)
|
||||
app.logger.info(f"Job {job_id} loaded on startup.")
|
||||
except Exception as e:
|
||||
app.logger.error(f"Failed to load job {job_id}: {e}")
|
||||
if isinstance(params, dict):
|
||||
cron_schedule = params.get('schedule_cron')
|
||||
if cron_schedule:
|
||||
job_id = f"user_{user_id}_sheet_{sheer_title}"
|
||||
try:
|
||||
scheduler.add_job(
|
||||
id=job_id,
|
||||
func=execute_olap_export,
|
||||
trigger='cron',
|
||||
args=[user_id, sheer_title],
|
||||
**_parse_cron_string(cron_schedule)
|
||||
)
|
||||
app.logger.info(f"Job {job_id} loaded on startup.")
|
||||
except Exception as e:
|
||||
app.logger.error(f"Failed to load job {job_id}: {e}")
|
||||
else:
|
||||
app.logger.warning("Database tables not found. Skipping job loading on startup. Run 'flask init-db' to create the tables.")
|
||||
scheduler.start()
|
||||
|
||||
Reference in New Issue
Block a user