Deduplicate Cove runs per job instead of globally
This commit is contained in:
parent
8fe3f99e40
commit
47bb4ee4f0
@ -407,12 +407,6 @@ def _process_account(account: dict) -> bool:
|
|||||||
run_ts = int(last_run_ts_raw or 0)
|
run_ts = int(last_run_ts_raw or 0)
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
run_ts = 0
|
run_ts = 0
|
||||||
external_id = f"cove-{account_id}-{run_ts}"
|
|
||||||
|
|
||||||
existing = JobRun.query.filter_by(external_id=external_id).first()
|
|
||||||
if existing:
|
|
||||||
db.session.commit()
|
|
||||||
return False
|
|
||||||
|
|
||||||
# Fetch the linked job
|
# Fetch the linked job
|
||||||
from .models import Job
|
from .models import Job
|
||||||
@ -421,6 +415,16 @@ def _process_account(account: dict) -> bool:
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
external_id = f"cove-{account_id}-{run_ts}"
|
||||||
|
|
||||||
|
# Deduplicate per job + session, not globally.
|
||||||
|
# This avoids blocking a run on a newly linked/relinked job when the same
|
||||||
|
# Cove session was previously stored under another job.
|
||||||
|
existing = JobRun.query.filter_by(job_id=job.id, external_id=external_id).first()
|
||||||
|
if existing:
|
||||||
|
db.session.commit()
|
||||||
|
return False
|
||||||
|
|
||||||
status = _map_status(last_status_code)
|
status = _map_status(last_status_code)
|
||||||
run_remark = (
|
run_remark = (
|
||||||
f"Cove account: {account_name or account_id} | "
|
f"Cove account: {account_name or account_id} | "
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user