Skip to content

Commit 9806daa

Browse files
fix: new TA cutoff date logic (#253)
* fix: new TA cutoff date logic * fix: rename
1 parent ca3ffaa commit 9806daa

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

apps/worker/tasks/tests/unit/test_upload_task.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,18 @@ def test_upload_task_call_new_ta_tasks(
507507
dbsession.flush()
508508
dbsession.refresh(commit)
509509

510+
mock_repo_provider_service.get_commit.return_value = {
511+
"author": {
512+
"id": "123",
513+
"username": "456",
514+
"email": "789",
515+
"name": "101",
516+
},
517+
"message": "hello world",
518+
"parents": [],
519+
"timestamp": str(NEW_TA_TASKS_CUTOFF_DATE - timedelta(days=10)),
520+
}
521+
510522
mock_redis.lists[f"uploads/{commit.repoid}/{commit.commitid}/test_results"] = (
511523
jsonified_redis_queue
512524
)

apps/worker/tasks/upload.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -756,18 +756,17 @@ def _schedule_ta_processing_task(
756756
new_ta_tasks = "old"
757757
else:
758758
db_session: Session = commit.get_db_session() # type: ignore
759-
earliest_commit = (
759+
commit_before_cutoff = (
760760
db_session.query(Commit)
761761
.filter(
762762
Commit.repoid == commit.repoid,
763-
Commit.timestamp > NEW_TA_TASKS_CUTOFF_DATE,
763+
Commit.timestamp < NEW_TA_TASKS_CUTOFF_DATE,
764764
)
765-
.order_by(Commit.timestamp)
766765
.limit(1)
767766
.first()
768767
)
769768

770-
if earliest_commit:
769+
if commit_before_cutoff is None:
771770
new_ta_tasks = "new"
772771
new_ta_tasks_repo_summary.inc()
773772

0 commit comments

Comments
 (0)