feat: expose FSSP source APIs and exports
This commit is contained in:
@@ -62,7 +62,7 @@ def _complete_snapshot_job(job, load_log, artifact, result) -> dict:
|
||||
"version": artifact.version or None,
|
||||
"checksum_sha256": artifact.sha256 or None,
|
||||
}
|
||||
if artifact.source == "sro_membership_check":
|
||||
if artifact.source in ("sro_membership_check", "fssp_enforcement_proceedings"):
|
||||
payload.update(artifact.metadata)
|
||||
job.meta = {
|
||||
**job.meta,
|
||||
@@ -79,7 +79,11 @@ def _complete_snapshot_job(job, load_log, artifact, result) -> dict:
|
||||
|
||||
def _claim_snapshot_job(job, source, task_name):
|
||||
with transaction.atomic():
|
||||
if source in ("sro_membership_check", "fedresurs_company_profile"):
|
||||
if source in (
|
||||
"sro_membership_check",
|
||||
"fedresurs_company_profile",
|
||||
"fssp_enforcement_proceedings",
|
||||
):
|
||||
sequence, _ = ParserBatchSequence.objects.get_or_create(source=source)
|
||||
ParserBatchSequence.objects.select_for_update().get(pk=sequence.pk)
|
||||
if (
|
||||
@@ -107,6 +111,18 @@ def _update_snapshot_progress(job, queried, candidates, found, quarantined):
|
||||
job.refresh_from_db()
|
||||
if job.status != JobStatus.STARTED:
|
||||
raise SnapshotValidationError("snapshot_job_no_longer_active")
|
||||
if job.meta.get("source") == "fssp_enforcement_proceedings":
|
||||
job.update_progress(5, f"Прочитано {queried} строк CSV")
|
||||
BackgroundJob.objects.filter(pk=job.pk, status=JobStatus.STARTED).update(
|
||||
meta={
|
||||
**job.meta,
|
||||
"raw_records_count": queried,
|
||||
"matched_records_count": found,
|
||||
"quarantined_records_count": quarantined,
|
||||
},
|
||||
updated_at=timezone.now(),
|
||||
)
|
||||
return
|
||||
if queried % 10 == 0 or queried == candidates:
|
||||
job.update_progress(
|
||||
5 + (90 * queried // max(candidates, 1)),
|
||||
@@ -290,3 +306,23 @@ def parse_fedresurs_company_profiles(
|
||||
track_progress=True,
|
||||
mode=mode,
|
||||
)
|
||||
|
||||
|
||||
@shared_task(
|
||||
bind=True,
|
||||
name="parsers.fssp_enforcement_proceedings.refresh",
|
||||
soft_time_limit=8 * 3600,
|
||||
time_limit=8 * 3600 + 300,
|
||||
)
|
||||
def parse_fssp_enforcement_proceedings(
|
||||
self, *, requested_by_id: int | None = None
|
||||
) -> dict:
|
||||
from apps.parsers.fssp_snapshot import refresh_fssp_enforcement_proceedings
|
||||
|
||||
return _run_snapshot(
|
||||
self,
|
||||
source="fssp_enforcement_proceedings",
|
||||
refresh=refresh_fssp_enforcement_proceedings,
|
||||
requested_by_id=requested_by_id,
|
||||
track_progress=True,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user