26 lines
851 B
Python

"""Scheduled and manual entry points for the SFDA scraper."""
from __future__ import annotations
import frappe
from sfda_parser.sfda_scraper.importer import import_latest_weekly_alerts
def run_weekly_sfda_import_scheduled():
"""
Runs automatically every Monday (see hooks.py cron).
Each execution:
1. Opens SFDA weekly-alert page
2. Picks the **latest** bulletin (top / newest date)
3. Imports new recalls into SFDA Entries (skips existing NCMDR refs)
When SFDA publishes a new weekly PDF, the table top row changes;
the next run imports only alerts that are not yet in ERP.
"""
frappe.logger("sfda_scraper").info("SFDA weekly scheduled job started")
summary = import_latest_weekly_alerts()
frappe.logger("sfda_scraper").info("SFDA weekly scheduled job finished: %s", summary)
return summary