Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit 17c8fb5

Browse files
fix: change cache_test_rollups to use repo_id (#1196)
1 parent 60bf2e3 commit 17c8fb5

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

tasks/cache_test_rollups.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,37 +114,42 @@ class CacheTestRollupsTask(BaseCodecovTask, name=cache_test_rollups_task_name):
114114
def run_impl(
115115
self,
116116
_db_session,
117-
repoid: int,
118117
branch: str,
118+
repo_id: int | None = None,
119+
repoid: int | None = None,
119120
update_date: bool = True,
120121
impl_type: Literal["old", "new", "both"] = "old",
121122
**kwargs,
122123
):
124+
repo_id = repo_id or repoid
125+
if repo_id is None:
126+
raise ValueError("repo_id or repoid must be provided")
127+
123128
redis_conn = get_redis_connection()
124129
try:
125130
with redis_conn.lock(
126-
f"rollups:{repoid}:{branch}", timeout=300, blocking_timeout=2
131+
f"rollups:{repo_id}:{branch}", timeout=300, blocking_timeout=2
127132
):
128133
if impl_type == "new" or impl_type == "both":
129-
cache_rollups(repoid, branch)
130-
cache_rollups(repoid, None)
134+
cache_rollups(repo_id, branch)
135+
cache_rollups(repo_id, None)
131136
if impl_type == "new":
132137
return {"success": True}
133138

134-
self.run_impl_within_lock(repoid, branch)
139+
self.run_impl_within_lock(repo_id, branch)
135140

136141
if update_date:
137142
LastCacheRollupDate.objects.update_or_create(
138-
repository_id=repoid,
143+
repository_id=repo_id,
139144
branch=branch,
140145
defaults={"last_rollup_date": dt.date.today()},
141146
)
142147
return {"success": True}
143148
except LockError:
144149
return {"in_progress": True}
145150

146-
def run_impl_within_lock(self, repoid: int, branch: str):
147-
storage_service = shared.storage.get_appropriate_storage_service(repoid)
151+
def run_impl_within_lock(self, repo_id: int, branch: str):
152+
storage_service = shared.storage.get_appropriate_storage_service(repo_id)
148153

149154
if get_config("setup", "database", "read_replica_enabled", default=False):
150155
connection = connections["default_read"]
@@ -164,7 +169,7 @@ def run_impl_within_lock(self, repoid: int, branch: str):
164169
(60, 30),
165170
]:
166171
query_params = {
167-
"repoid": repoid,
172+
"repoid": repo_id, # query is expecting repoid
168173
"branch": branch,
169174
"interval_start": f"{interval_start} days",
170175
# SQL `BETWEEN` syntax is equivalent to `<= end`, with an inclusive end date,
@@ -201,9 +206,9 @@ def run_impl_within_lock(self, repoid: int, branch: str):
201206
serialized_table.seek(0) # avoids Stream must be at beginning errors
202207

203208
storage_key = (
204-
f"test_results/rollups/{repoid}/{branch}/{interval_start}"
209+
f"test_results/rollups/{repo_id}/{branch}/{interval_start}"
205210
if interval_end is None
206-
else f"test_results/rollups/{repoid}/{branch}/{interval_start}_{interval_end}"
211+
else f"test_results/rollups/{repo_id}/{branch}/{interval_start}_{interval_end}"
207212
)
208213
storage_service.write_file(
209214
settings.GCS_BUCKET_NAME, storage_key, serialized_table

0 commit comments

Comments
 (0)