From 3404a0cfd1ad9fb90c5e3b0f4e7a9df29939d87b Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 6 Jun 2024 12:40:32 +0330 Subject: [PATCH 1/6] update rf4 urls --- src/features/import-projects/rf4/constants.ts | 2 +- src/features/import-projects/rf4/helpers.ts | 6 ++++++ src/features/import-projects/rf4/index.ts | 7 ++++++- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 src/features/import-projects/rf4/helpers.ts diff --git a/src/features/import-projects/rf4/constants.ts b/src/features/import-projects/rf4/constants.ts index 1c2d504..715a3d2 100644 --- a/src/features/import-projects/rf4/constants.ts +++ b/src/features/import-projects/rf4/constants.ts @@ -6,6 +6,6 @@ export const rf4SourceConfig: SourceConfig = { idField: "id", titleField: "name", descriptionField: "description", - slugField: "url", imageField: "bannerImageUrl", + urlField: "url", }; diff --git a/src/features/import-projects/rf4/helpers.ts b/src/features/import-projects/rf4/helpers.ts new file mode 100644 index 0000000..4089325 --- /dev/null +++ b/src/features/import-projects/rf4/helpers.ts @@ -0,0 +1,6 @@ +import { type Rf4ProjectInfo } from "./type"; + +export const generateRf4Url = (project: Rf4ProjectInfo) => { + return `/project/${project.id}`; +}; + diff --git a/src/features/import-projects/rf4/index.ts b/src/features/import-projects/rf4/index.ts index 87429ef..60db499 100644 --- a/src/features/import-projects/rf4/index.ts +++ b/src/features/import-projects/rf4/index.ts @@ -1,5 +1,6 @@ import { updateOrCreateProject } from "../helpers"; import { rf4SourceConfig } from "./constants"; +import { generateRf4Url } from "./helpers"; import { fetchRf4Projects } from "./service"; export const fetchAndProcessRf4Projects = async () => { @@ -7,7 +8,11 @@ export const fetchAndProcessRf4Projects = async () => { const data = await fetchRf4Projects(); if (!data) return; for (const project of data) { - await updateOrCreateProject(project, rf4SourceConfig); + const processedProject = { + ...project, + url: generateRf4Url(project), + } + await updateOrCreateProject(processedProject, rf4SourceConfig); } } catch (error: any) { console.log("error on fetchAndProcessRf4Projects", error.message); From f9a1bd6088e8ea722e7772d995610b1a69074de0 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 6 Jun 2024 12:40:43 +0330 Subject: [PATCH 2/6] update giveth urls --- src/features/import-projects/giveth/constants.ts | 4 ++-- src/features/import-projects/giveth/helpers.ts | 10 +++++++++- src/features/import-projects/giveth/service.ts | 7 ++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/features/import-projects/giveth/constants.ts b/src/features/import-projects/giveth/constants.ts index 98055c5..b13c48d 100644 --- a/src/features/import-projects/giveth/constants.ts +++ b/src/features/import-projects/giveth/constants.ts @@ -1,13 +1,13 @@ export const GIVETH_API_URL = process.env.GIVETH_API_URL || "https://mainnet.serve.giveth.io/graphql"; -export const GIVETH_API_LIMIT = 100; +export const GIVETH_API_LIMIT = 50; export const givethSourceConfig: SourceConfig = { source: "giveth", idField: "id", titleField: "title", descriptionField: "descriptionSummary", - slugField: "slug", + urlField: "url", imageField: "image", }; diff --git a/src/features/import-projects/giveth/helpers.ts b/src/features/import-projects/giveth/helpers.ts index 4044dce..5da05ee 100644 --- a/src/features/import-projects/giveth/helpers.ts +++ b/src/features/import-projects/giveth/helpers.ts @@ -3,10 +3,18 @@ import { type GivethProjectInfo } from "./type"; import { updateOrCreateProject } from "../helpers"; import { givethSourceConfig } from "./constants"; +export const generateGivethUrl = (project: GivethProjectInfo) => { + return `/project/${project.slug}`; +}; + export const processProjectsBatch = async ( projectsBatch: GivethProjectInfo[] ) => { for (const project of projectsBatch) { - await updateOrCreateProject(project, givethSourceConfig); + const processedProject = { + ...project, + url: generateGivethUrl(project), + }; + await updateOrCreateProject(processedProject, givethSourceConfig); } }; diff --git a/src/features/import-projects/giveth/service.ts b/src/features/import-projects/giveth/service.ts index 7825140..44dafc4 100644 --- a/src/features/import-projects/giveth/service.ts +++ b/src/features/import-projects/giveth/service.ts @@ -6,11 +6,11 @@ export const fetchGivethProjectsBatch = async (limit: number, skip: number) => { try { const res = await graphQLRequest( GIVETH_API_URL, - `query ($limit: Int, $skip: Int, $sortingBy: SortingField) { + `query ($limit: Int, $skip: Int) { allProjects( limit: $limit skip: $skip - sortingBy: $sortingBy + sortingBy: Newest ) { projects { id @@ -24,10 +24,11 @@ export const fetchGivethProjectsBatch = async (limit: number, skip: number) => { { limit, skip, - sortingBy: "Newest", } ); + console.log('res', res) + return res.data.allProjects.projects; } catch (error: any) { console.log("error on fetchGivethProjectsBatch", error.message); From 1f7700779917a986cd5880bf1e7fb4f982926e88 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 6 Jun 2024 12:41:08 +0330 Subject: [PATCH 3/6] update gitcoin url --- src/features/import-projects/gitcoin/constants.ts | 2 +- src/features/import-projects/gitcoin/helpers.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/features/import-projects/gitcoin/constants.ts b/src/features/import-projects/gitcoin/constants.ts index 105fc42..a90cc2a 100644 --- a/src/features/import-projects/gitcoin/constants.ts +++ b/src/features/import-projects/gitcoin/constants.ts @@ -11,6 +11,6 @@ export const gitcoinSourceConfig: SourceConfig = { idField: "id", titleField: "title", descriptionField: "description", - slugField: "slug", imageField: "image", + urlField: "url", }; diff --git a/src/features/import-projects/gitcoin/helpers.ts b/src/features/import-projects/gitcoin/helpers.ts index 6a9ea68..1d2d6e2 100644 --- a/src/features/import-projects/gitcoin/helpers.ts +++ b/src/features/import-projects/gitcoin/helpers.ts @@ -2,7 +2,7 @@ import type { GitcoinProjectInfo } from "./type"; import { updateOrCreateProject } from "../helpers"; import { IPFS_GATEWAY, gitcoinSourceConfig } from "./constants"; -const generateGitcoinSlug = (project: GitcoinProjectInfo) => { +const generateGitcoinUrl = (project: GitcoinProjectInfo) => { const application = project.applications[0]; if ( @@ -30,7 +30,7 @@ export const processProjectsBatch = async ( id: project.id, title: project.name || project.metadata?.title, description: project.metadata?.description, - url: generateGitcoinSlug(project), + url: generateGitcoinUrl(project), image: project.metadata?.bannerImg ? convertIpfsHashToHttps(project.metadata?.bannerImg) : "", From 2b2f0e21cb79d6f4792b1359743caa1ee34734e2 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 6 Jun 2024 12:41:36 +0330 Subject: [PATCH 4/6] update to urlField --- src/features/import-projects/helpers.ts | 8 ++++---- src/features/import-projects/rpgf/constants.ts | 2 +- src/features/import-projects/types.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/features/import-projects/helpers.ts b/src/features/import-projects/helpers.ts index 35156e5..20722ea 100644 --- a/src/features/import-projects/helpers.ts +++ b/src/features/import-projects/helpers.ts @@ -11,7 +11,7 @@ export const updateOrCreateProject = async ( idField, titleField, descriptionField, - slugField, + urlField, imageField, } = sourConfig; @@ -36,7 +36,7 @@ export const updateOrCreateProject = async ( const isUpdated = existingProject.title !== project[titleField] || existingProject.description !== project[descriptionField] || - existingProject.url !== project[slugField] || + existingProject.url !== project[urlField] || existingProject.image !== project[imageField]; if (isUpdated) { @@ -45,7 +45,7 @@ export const updateOrCreateProject = async ( title: project[titleField], description: project[descriptionField], image: project[imageField], - url: project[slugField], + url: project[urlField], lastUpdatedTimestamp: new Date(), imported: true, }); @@ -67,7 +67,7 @@ export const updateOrCreateProject = async ( title: project[titleField], description: project[descriptionField], image: project[imageField], - url: project[slugField], + url: project[urlField], projectId: projectId, source: source, totalVouches: 0, diff --git a/src/features/import-projects/rpgf/constants.ts b/src/features/import-projects/rpgf/constants.ts index e912b1c..bf7d641 100644 --- a/src/features/import-projects/rpgf/constants.ts +++ b/src/features/import-projects/rpgf/constants.ts @@ -6,6 +6,6 @@ export const rpgf3SourceConfig: SourceConfig = { idField: "RPGF3Id", titleField: "name", descriptionField: "impactDescription", - slugField: "url", + urlField: "url", imageField: "image", }; diff --git a/src/features/import-projects/types.ts b/src/features/import-projects/types.ts index 33351d4..ccdbb74 100644 --- a/src/features/import-projects/types.ts +++ b/src/features/import-projects/types.ts @@ -3,6 +3,6 @@ interface SourceConfig { idField: string; titleField: string; descriptionField: string; - slugField: string; + urlField: string; imageField: string; } From 2c176b27fc5904762aa7d5edd1fc9f2b6e194543 Mon Sep 17 00:00:00 2001 From: Amin Latifi Date: Thu, 6 Jun 2024 12:46:06 +0330 Subject: [PATCH 5/6] Updated a comment --- schema.graphql | 2 +- src/model/generated/project.model.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/schema.graphql b/schema.graphql index 38f5cc0..63e17fb 100644 --- a/schema.graphql +++ b/schema.graphql @@ -57,7 +57,7 @@ type Project @entity { totalFlags: Int! "Total attests" totalAttests: Int! - "Slug of the project" + "Url of the project" url: String "Image of the project" image: String diff --git a/src/model/generated/project.model.ts b/src/model/generated/project.model.ts index 0abce05..74e898b 100644 --- a/src/model/generated/project.model.ts +++ b/src/model/generated/project.model.ts @@ -59,7 +59,7 @@ export class Project { totalAttests!: number /** - * Slug of the project + * Url of the project */ @Column_("text", {nullable: true}) url!: string | undefined | null From e8d0cc9442facd8b0e4a36ca5738978caa34844c Mon Sep 17 00:00:00 2001 From: Amin Latifi Date: Thu, 6 Jun 2024 12:50:50 +0330 Subject: [PATCH 6/6] Removed log --- src/features/import-projects/giveth/service.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/features/import-projects/giveth/service.ts b/src/features/import-projects/giveth/service.ts index 44dafc4..1b3a7ca 100644 --- a/src/features/import-projects/giveth/service.ts +++ b/src/features/import-projects/giveth/service.ts @@ -1,6 +1,5 @@ import { graphQLRequest } from "../../../helpers/request"; import { GIVETH_API_URL } from "./constants"; -import { GivethProjectInfo } from "./type"; export const fetchGivethProjectsBatch = async (limit: number, skip: number) => { try { @@ -27,8 +26,6 @@ export const fetchGivethProjectsBatch = async (limit: number, skip: number) => { } ); - console.log('res', res) - return res.data.allProjects.projects; } catch (error: any) { console.log("error on fetchGivethProjectsBatch", error.message);