Skip to content

Commit ca8c835

Browse files
committed
chore: improve query readability and deprecate unused fields
1 parent 23db013 commit ca8c835

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

services/apps/git_integration/src/crowdgit/database/crud.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
r."segmentId",
2424
r."gitIntegrationId",
2525
r."forkedFrom",
26-
r."createdAt",
27-
r."updatedAt",
2826
rp.state,
2927
rp.priority,
3028
rp."lockedAt",
@@ -74,21 +72,22 @@ async def acquire_onboarding_repo() -> Repository | None:
7472
selected_repo AS (
7573
SELECT r.id
7674
FROM public.repositories r
77-
JOIN git."repositoryProcessing" rp ON rp."repositoryId" = r.id,
78-
current_onboarding_count c
75+
JOIN git."repositoryProcessing" rp ON rp."repositoryId" = r.id
76+
CROSS JOIN current_onboarding_count c
7977
WHERE rp.state = $2
8078
AND rp."lockedAt" IS NULL
8179
AND r."deletedAt" IS NULL
8280
AND c.count < $3
83-
ORDER BY rp.priority ASC, r."createdAt" ASC
81+
ORDER BY rp.priority ASC, rp."createdAt" ASC
8482
LIMIT 1
8583
FOR UPDATE OF rp SKIP LOCKED
8684
)
8785
UPDATE git."repositoryProcessing" rp
8886
SET "lockedAt" = NOW(),
8987
state = $1,
9088
"updatedAt" = NOW()
91-
FROM public.repositories r, selected_repo
89+
FROM public.repositories r
90+
CROSS JOIN selected_repo
9291
WHERE rp."repositoryId" = r.id
9392
AND rp."repositoryId" = selected_repo.id
9493
RETURNING {REPO_SELECT_COLUMNS}
@@ -142,7 +141,8 @@ async def acquire_recurrent_repo() -> Repository | None:
142141
SET "lockedAt" = NOW(),
143142
state = $1,
144143
"updatedAt" = NOW()
145-
FROM public.repositories r, selected_repo
144+
FROM public.repositories r
145+
CROSS JOIN selected_repo
146146
WHERE rp."repositoryId" = r.id
147147
AND rp."repositoryId" = selected_repo.id
148148
RETURNING {REPO_SELECT_COLUMNS}

services/apps/git_integration/src/crowdgit/models/repository.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,9 @@ class Repository(BaseModel):
4646
description="Indicates if the stuck repository is resolved by a re-onboarding",
4747
)
4848
re_onboarding_count: int = Field(
49-
...,
49+
default=0,
5050
description="Tracks the number of times this repository has been re-onboarded. Used to identify unreachable commits via activity.attributes.cycle matching pattern onboarding-{reOnboardingCount}",
5151
)
52-
created_at: datetime = Field(..., description="Creation timestamp")
53-
updated_at: datetime = Field(..., description="Last update timestamp")
5452

5553
@classmethod
5654
def from_db(cls, db_data: dict[str, Any]) -> Repository:
@@ -65,8 +63,6 @@ def from_db(cls, db_data: dict[str, Any]) -> Repository:
6563

6664
# Map database field names to model field names
6765
field_mapping = {
68-
"createdAt": "created_at",
69-
"updatedAt": "updated_at",
7066
"lastProcessedAt": "last_processed_at",
7167
"lastProcessedCommit": "last_processed_commit",
7268
"lockedAt": "locked_at",

0 commit comments

Comments
 (0)