Skip to content

Commit d3866ad

Browse files
committed
Fix project handling when no repositories found
The change updates the project processing logic. Instead of deleting invalid projects, they are now marked as garbage-collected. Tags and search indices are only processed after valid repositories are confirmed.
1 parent 287951b commit d3866ad

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

api/src/digest/cron.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,6 @@ it may contain non-translatable parts like acronyms, keep them as is.`;
142142
name_ar,
143143
};
144144
const [{ id: projectId }] = await this.projectsRepository.upsert(projectEntity);
145-
for (const tagId of project.tags || []) {
146-
await this.tagRepository.upsert({ id: tagId, runId });
147-
await this.projectsRepository.upsertRelationWithTag({ projectId, tagId, runId });
148-
}
149-
await this.searchService.upsert("project", projectEntity);
150145

151146
let addedRepositoryCount = 0;
152147
try {
@@ -294,8 +289,19 @@ it may contain non-translatable parts like acronyms, keep them as is.`;
294289
if (addedRepositoryCount === 0) {
295290
captureException(new Error("Empty project"), { extra: { project } });
296291
await this.projectsRepository.deleteRelationWithTagByProjectId(projectId);
297-
await this.projectsRepository.deleteById(projectId);
292+
await this.projectsRepository.upsert({ ...projectEntity, runId: "garbage-collected" });
293+
continue;
294+
}
295+
296+
for (const tagId of project.tags || []) {
297+
await this.tagRepository.upsert({ id: tagId, runId });
298+
await this.projectsRepository.upsertRelationWithTag({
299+
projectId,
300+
tagId,
301+
runId,
302+
});
298303
}
304+
await this.searchService.upsert("project", projectEntity);
299305
}
300306

301307
try {
@@ -373,7 +379,9 @@ it may contain non-translatable parts like acronyms, keep them as is.`;
373379
repoContributors
374380
.filter(({ type }) => type === "User")
375381
.map(async (contributor) => {
376-
const userInfo = await this.githubService.getUser({ username: contributor.login });
382+
const userInfo = await this.githubService.getUser({
383+
username: contributor.login,
384+
});
377385
return {
378386
id: contributor.login,
379387
name: userInfo.name,

0 commit comments

Comments
 (0)