fix(scraper): deduplicate job_hash in Python before PostgreSQL batch upsert
This commit is contained in:
parent
3aad6705d0
commit
83ee7378da
1 changed files with 4 additions and 0 deletions
|
|
@ -168,6 +168,7 @@ def _upsert_postgres(jobs_list: list, db_url: str):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
records = []
|
records = []
|
||||||
|
seen_hashes = set()
|
||||||
now = datetime.datetime.now(datetime.timezone.utc)
|
now = datetime.datetime.now(datetime.timezone.utc)
|
||||||
|
|
||||||
for j in jobs_list:
|
for j in jobs_list:
|
||||||
|
|
@ -175,6 +176,9 @@ def _upsert_postgres(jobs_list: list, db_url: str):
|
||||||
if not job_url:
|
if not job_url:
|
||||||
continue
|
continue
|
||||||
job_hash = generate_job_hash(job_url)
|
job_hash = generate_job_hash(job_url)
|
||||||
|
if job_hash in seen_hashes:
|
||||||
|
continue
|
||||||
|
seen_hashes.add(job_hash)
|
||||||
job_id = "job_" + str(uuid.uuid4()).replace("-", "")[:20]
|
job_id = "job_" + str(uuid.uuid4()).replace("-", "")[:20]
|
||||||
|
|
||||||
records.append((
|
records.append((
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue