mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 02:11:11 -05:00
everything except extend
This commit is contained in:
@@ -226,7 +226,7 @@ def find_jobs_with_missing_rows():
|
|||||||
ten_minutes_ago = utc_now() - timedelta(minutes=20)
|
ten_minutes_ago = utc_now() - timedelta(minutes=20)
|
||||||
yesterday = utc_now() - timedelta(days=1)
|
yesterday = utc_now() - timedelta(days=1)
|
||||||
jobs_with_rows_missing = (
|
jobs_with_rows_missing = (
|
||||||
db.session.query(Job)
|
select(Job)
|
||||||
.filter(
|
.filter(
|
||||||
Job.job_status == JobStatus.FINISHED,
|
Job.job_status == JobStatus.FINISHED,
|
||||||
Job.processing_finished < ten_minutes_ago,
|
Job.processing_finished < ten_minutes_ago,
|
||||||
@@ -237,16 +237,16 @@ def find_jobs_with_missing_rows():
|
|||||||
.having(func.count(Notification.id) != Job.notification_count)
|
.having(func.count(Notification.id) != Job.notification_count)
|
||||||
)
|
)
|
||||||
|
|
||||||
return jobs_with_rows_missing.all()
|
return db.session.execute(jobs_with_rows_missing).all()
|
||||||
|
|
||||||
|
|
||||||
def find_missing_row_for_job(job_id, job_size):
|
def find_missing_row_for_job(job_id, job_size):
|
||||||
expected_row_numbers = db.session.query(
|
expected_row_numbers = select(
|
||||||
func.generate_series(0, job_size - 1).label("row")
|
func.generate_series(0, job_size - 1).label("row")
|
||||||
).subquery()
|
).subquery()
|
||||||
|
|
||||||
query = (
|
query = (
|
||||||
db.session.query(
|
select(
|
||||||
Notification.job_row_number, expected_row_numbers.c.row.label("missing_row")
|
Notification.job_row_number, expected_row_numbers.c.row.label("missing_row")
|
||||||
)
|
)
|
||||||
.outerjoin(
|
.outerjoin(
|
||||||
@@ -258,4 +258,4 @@ def find_missing_row_for_job(job_id, job_size):
|
|||||||
)
|
)
|
||||||
.filter(Notification.job_row_number == None) # noqa
|
.filter(Notification.job_row_number == None) # noqa
|
||||||
)
|
)
|
||||||
return query.all()
|
return db.session.execute(query).all()
|
||||||
|
|||||||
Reference in New Issue
Block a user