This commit is contained in:
@@ -140,23 +140,28 @@ def persist_discovery_candidates(candidates: list[SourceCandidate]) -> tuple[int
|
||||
for candidate in ordered:
|
||||
provenance = _provenance_entry(candidate)
|
||||
now = _utc_now()
|
||||
source, was_created = Source.objects.get_or_create(
|
||||
domain=candidate.domain,
|
||||
source_type=candidate.source_type,
|
||||
defaults={
|
||||
"name": _candidate_name(candidate),
|
||||
"base_url": candidate.url,
|
||||
"status": Source.Status.CANDIDATE,
|
||||
"policy": Source.Policy.REVIEW,
|
||||
"policy_reason": "Automatisch ontdekt",
|
||||
"parser_key": "auto",
|
||||
"strict_mode": True,
|
||||
"metadata": {
|
||||
"discovery": [provenance],
|
||||
"discovered_at": now,
|
||||
},
|
||||
},
|
||||
source = (
|
||||
Source.objects.filter(
|
||||
domain=candidate.domain,
|
||||
source_type=candidate.source_type,
|
||||
)
|
||||
.order_by("id")
|
||||
.first()
|
||||
)
|
||||
was_created = source is None
|
||||
if source is None:
|
||||
source = Source.objects.create(
|
||||
domain=candidate.domain,
|
||||
source_type=candidate.source_type,
|
||||
name=_candidate_name(candidate),
|
||||
base_url=candidate.url,
|
||||
status=Source.Status.CANDIDATE,
|
||||
policy=Source.Policy.REVIEW,
|
||||
policy_reason="Automatisch ontdekt",
|
||||
parser_key="auto",
|
||||
strict_mode=True,
|
||||
metadata={"discovery": [provenance], "discovered_at": now},
|
||||
)
|
||||
if was_created:
|
||||
created += 1
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user