Skip to content

Commit 64b4005

Browse files
authored
Merge pull request #660 from dzcode-io/improve-cron-import
improved cron job: handle non-existent repo gracefully
2 parents ddce9ed + 322c61d commit 64b4005

File tree

6 files changed

+29
-11
lines changed

6 files changed

+29
-11
lines changed

.github/workflows/cd.deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
node-version: "20"
1313
os: "ubuntu-latest"
1414

15-
bundle-deploy:
15+
docker-build-push-api:
1616
needs: build
1717
runs-on: ubuntu-latest
1818
env:

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"singleQuote": false,
3+
"printWidth": 100,
4+
"trailingComma": "all",
5+
"endOfLine": "auto",
6+
"todo-zm": "remove packages/tooling/.prettierrc"
7+
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ npm run dev:all
5858

5959
Please check the README.md files inside `./api` and `./web` for more info.
6060

61+
<!--todo-zm: move this to CONTRIBUTING.md-->
62+
6163
## Contributing
6264

6365
To get started, see [the contributing guidelines](https://github.com/dzcode-io/dzcode.io/blob/main/.github/CONTRIBUTING.md).
@@ -69,8 +71,6 @@ If you use VSCode, please make sure to have a `.vscode/settings.json` file with
6971
"files.associations": {
7072
"*.css": "tailwindcss"
7173
},
72-
"prettier.configPath": "packages/tooling/.prettierrc",
73-
"prettier.prettierPath": "./node_modules/prettier/index.cjs",
7474
"eslint.options": { "overrideConfigFile": "packages/tooling/eslint.config.mjs" },
7575
"editor.codeActionsOnSave": {
7676
"source.fixAll.eslint": "always",

api/src/digest/cron.ts

Lines changed: 12 additions & 6 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 {

api/src/fetch/service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ export class FetchService {
4848
private async fetch<T>(url: string, options: FetchOptions) {
4949
this.logger.info({ message: `Fetching ${url}` });
5050
const response = await this.makeFetchHappenInstance(url, options);
51+
if (!response.ok) {
52+
this.logger.error({ message: `Failed to fetch ${url}`, meta: { status: response.status } });
53+
throw new Error(`Failed to fetch ${url}: ${response.statusText}`);
54+
}
5155
const jsonResponse = (await response.json()) as T;
5256
return jsonResponse;
5357
}

data/models/projects/SPL_Router/info.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
{
55
"provider": "github",
66
"owner": "Mouhamedtec",
7-
"repository": "SPL-Router"
7+
"name": "SPL-Router"
88
}
9-
]
9+
],
10+
"tags": ["by-algerian"]
1011
}

0 commit comments

Comments
 (0)