From 9cea07965f6ccf3c6eb731780411ed302fc046db Mon Sep 17 00:00:00 2001 From: Zakaria Mansouri Date: Fri, 1 Aug 2025 18:41:08 +0200 Subject: [PATCH 1/5] Add error handling for failed fetch requests --- api/src/fetch/service.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/src/fetch/service.ts b/api/src/fetch/service.ts index e757cdfe..c3de752f 100644 --- a/api/src/fetch/service.ts +++ b/api/src/fetch/service.ts @@ -48,6 +48,10 @@ export class FetchService { private async fetch(url: string, options: FetchOptions) { this.logger.info({ message: `Fetching ${url}` }); const response = await this.makeFetchHappenInstance(url, options); + if (!response.ok) { + this.logger.error({ message: `Failed to fetch ${url}`, meta: { status: response.status } }); + throw new Error(`Failed to fetch ${url}: ${response.statusText}`); + } const jsonResponse = (await response.json()) as T; return jsonResponse; } From 287951b5f42e1ce91c5ef30e1500ff3b2323958c Mon Sep 17 00:00:00 2001 From: Zakaria Mansouri Date: Fri, 1 Aug 2025 18:59:47 +0200 Subject: [PATCH 2/5] fix job names --- .github/workflows/cd.deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cd.deploy.yml b/.github/workflows/cd.deploy.yml index 3dd65d6d..e63cdd09 100644 --- a/.github/workflows/cd.deploy.yml +++ b/.github/workflows/cd.deploy.yml @@ -12,7 +12,7 @@ jobs: node-version: "20" os: "ubuntu-latest" - bundle-deploy: + docker-build-push-api: needs: build runs-on: ubuntu-latest env: From d3866ad395105623ddfb497c11a89231eb6fb471 Mon Sep 17 00:00:00 2001 From: Zakaria Mansouri Date: Fri, 1 Aug 2025 21:35:06 +0200 Subject: [PATCH 3/5] 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. --- api/src/digest/cron.ts | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/api/src/digest/cron.ts b/api/src/digest/cron.ts index 0a4110d1..ba23b5eb 100644 --- a/api/src/digest/cron.ts +++ b/api/src/digest/cron.ts @@ -142,11 +142,6 @@ it may contain non-translatable parts like acronyms, keep them as is.`; name_ar, }; const [{ id: projectId }] = await this.projectsRepository.upsert(projectEntity); - for (const tagId of project.tags || []) { - await this.tagRepository.upsert({ id: tagId, runId }); - await this.projectsRepository.upsertRelationWithTag({ projectId, tagId, runId }); - } - await this.searchService.upsert("project", projectEntity); let addedRepositoryCount = 0; try { @@ -294,8 +289,19 @@ it may contain non-translatable parts like acronyms, keep them as is.`; if (addedRepositoryCount === 0) { captureException(new Error("Empty project"), { extra: { project } }); await this.projectsRepository.deleteRelationWithTagByProjectId(projectId); - await this.projectsRepository.deleteById(projectId); + await this.projectsRepository.upsert({ ...projectEntity, runId: "garbage-collected" }); + continue; + } + + for (const tagId of project.tags || []) { + await this.tagRepository.upsert({ id: tagId, runId }); + await this.projectsRepository.upsertRelationWithTag({ + projectId, + tagId, + runId, + }); } + await this.searchService.upsert("project", projectEntity); } try { @@ -373,7 +379,9 @@ it may contain non-translatable parts like acronyms, keep them as is.`; repoContributors .filter(({ type }) => type === "User") .map(async (contributor) => { - const userInfo = await this.githubService.getUser({ username: contributor.login }); + const userInfo = await this.githubService.getUser({ + username: contributor.login, + }); return { id: contributor.login, name: userInfo.name, From 8fadb5f24545b0c6baca1344477cd9f7a95e8fdf Mon Sep 17 00:00:00 2001 From: Zakaria Mansouri Date: Fri, 1 Aug 2025 21:49:24 +0200 Subject: [PATCH 4/5] Fix repository field name in SPL_Router info.json and add tags --- data/models/projects/SPL_Router/info.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/data/models/projects/SPL_Router/info.json b/data/models/projects/SPL_Router/info.json index 667a29e7..848eb455 100644 --- a/data/models/projects/SPL_Router/info.json +++ b/data/models/projects/SPL_Router/info.json @@ -4,7 +4,8 @@ { "provider": "github", "owner": "Mouhamedtec", - "repository": "SPL-Router" + "name": "SPL-Router" } - ] + ], + "tags": ["by-algerian"] } From 322c61dc3aff9f782683dc75f68ac7b1379d56e3 Mon Sep 17 00:00:00 2001 From: Zakaria Mansouri Date: Sat, 2 Aug 2025 12:00:29 +0200 Subject: [PATCH 5/5] move Prettier config to repo too so other IDEs support it by default --- .prettierrc | 7 +++++++ README.md | 4 ++-- api/src/digest/cron.ts | 4 +--- 3 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 .prettierrc diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..aaaaf37b --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "singleQuote": false, + "printWidth": 100, + "trailingComma": "all", + "endOfLine": "auto", + "todo-zm": "remove packages/tooling/.prettierrc" +} diff --git a/README.md b/README.md index 6a521a84..6a5e3d40 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,8 @@ npm run dev:all Please check the README.md files inside `./api` and `./web` for more info. + + ## Contributing 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 "files.associations": { "*.css": "tailwindcss" }, - "prettier.configPath": "packages/tooling/.prettierrc", - "prettier.prettierPath": "./node_modules/prettier/index.cjs", "eslint.options": { "overrideConfigFile": "packages/tooling/eslint.config.mjs" }, "editor.codeActionsOnSave": { "source.fixAll.eslint": "always", diff --git a/api/src/digest/cron.ts b/api/src/digest/cron.ts index ba23b5eb..a57aa7dd 100644 --- a/api/src/digest/cron.ts +++ b/api/src/digest/cron.ts @@ -379,9 +379,7 @@ it may contain non-translatable parts like acronyms, keep them as is.`; repoContributors .filter(({ type }) => type === "User") .map(async (contributor) => { - const userInfo = await this.githubService.getUser({ - username: contributor.login, - }); + const userInfo = await this.githubService.getUser({ username: contributor.login }); return { id: contributor.login, name: userInfo.name,