Skip to content

Commit

Permalink
[jobs] Keep job results in SortingHat one week
Browse files Browse the repository at this point in the history
This commit updates the retention period for job results
in SortingHat to one week.

Signed-off-by: Jose Javier Merchante <jjmerchante@bitergia.com>
  • Loading branch information
jjmerchante committed Aug 6, 2024
1 parent b152145 commit 02f8279
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
8 changes: 8 additions & 0 deletions releases/unreleased/job-results-in-sortinghat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Job results in SortingHat
category: fixed
author: Jose Javier Merchante <jjmerchante@bitergia.com>
issue: null
notes: >
Fixed a bug that caused jobs to be missing in SortingHat.
Job results will be kept in SortingHat for one week.
2 changes: 2 additions & 0 deletions sortinghat/core/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,8 @@ def schedule_task(ctx, fn, task, scheduled_datetime=None, **kwargs):
on_success=on_success_job,
on_failure=on_failed_job,
job_timeout=-1,
result_ttl=60*60*24*7,
failure_ttl=60*60*24*7,
**kwargs)
task.scheduled_datetime = scheduled_datetime
task.job_id = job.id
Expand Down
29 changes: 21 additions & 8 deletions sortinghat/core/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,9 @@ def mutate(self, info, uuids=None, last_modified=MIN_PERIOD_DATE):

job = get_tenant_queue(tenant).enqueue(recommend_affiliations,
ctx, uuids, last_modified,
job_timeout=-1)
job_timeout=-1,
result_ttl=60*60*24*7,
failure_ttl=60*60*24*7)

return RecommendAffiliations(
job_id=job.id
Expand Down Expand Up @@ -1154,7 +1156,9 @@ def mutate(self, info, criteria,
strict,
match_source,
last_modified,
job_timeout=-1)
job_timeout=-1,
result_ttl=60*60*24*7,
failure_ttl=60*60*24*7)

return RecommendMatches(
job_id=job.id
Expand All @@ -1179,7 +1183,9 @@ def mutate(self, info, uuids=None, exclude=True, no_strict_matching=False):
job = get_tenant_queue(tenant).enqueue(recommend_gender,
ctx, uuids,
exclude, no_strict_matching,
job_timeout=-1)
job_timeout=-1,
result_ttl=60*60*24*7,
failure_ttl=60*60*24*7)

return RecommendGender(
job_id=job.id
Expand All @@ -1203,7 +1209,9 @@ def mutate(self, info, uuids=None, last_modified=MIN_PERIOD_DATE):

job = get_tenant_queue(tenant).enqueue(affiliate, ctx, uuids,
last_modified,
job_timeout=-1)
job_timeout=-1,
result_ttl=60*60*24*7,
failure_ttl=60*60*24*7)

return Affiliate(
job_id=job.id
Expand Down Expand Up @@ -1247,7 +1255,9 @@ def mutate(self, info, criteria,
strict,
match_source,
last_modified,
job_timeout=-1)
job_timeout=-1,
result_ttl=60*60*24*7,
failure_ttl=60*60*24*7)

return Unify(
job_id=job.id
Expand All @@ -1271,7 +1281,9 @@ def mutate(self, info, uuids=None, exclude=True, no_strict_matching=False):

job = get_tenant_queue(tenant).enqueue(genderize, ctx, uuids,
exclude, no_strict_matching,
job_timeout=-1)
job_timeout=-1,
result_ttl=60*60*24*7,
failure_ttl=60*60*24*7)

return Genderize(
job_id=job.id
Expand Down Expand Up @@ -1431,7 +1443,9 @@ def mutate(self, info, backend, url, params=None):

job = get_tenant_queue(tenant).enqueue(import_identities, ctx,
backend, url, params,
job_timeout=-1)
job_timeout=-1,
result_ttl=60*60*24*7,
failure_ttl=60*60*24*7)

return ImportIdentities(
job_id=job.id
Expand Down Expand Up @@ -1529,7 +1543,6 @@ def mutate(self, info, task_id, data):
new_dt = datetime.datetime.now(datetime.timezone.utc) \
+ datetime.timedelta(minutes=task.interval)
if task.scheduled_datetime and task.scheduled_datetime > new_dt:
find_job(task.job_id, tenant)
if task.job_id:
job = find_job(task.job_id, tenant)
if job:
Expand Down

0 comments on commit 02f8279

Please sign in to comment.