From 7f140afb6adc90b9d5fa2c62eceaf446026d00fd Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Wed, 9 Nov 2022 15:32:18 +0800 Subject: [PATCH] [portal][feat] add ranking for cities --- .../20221109070931_company_city_ranking/migration.sql | 5 +++++ apps/portal/prisma/schema.prisma | 4 ++++ apps/portal/src/server/router/locations-router.ts | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 apps/portal/prisma/migrations/20221109070931_company_city_ranking/migration.sql diff --git a/apps/portal/prisma/migrations/20221109070931_company_city_ranking/migration.sql b/apps/portal/prisma/migrations/20221109070931_company_city_ranking/migration.sql new file mode 100644 index 00000000..d8b32694 --- /dev/null +++ b/apps/portal/prisma/migrations/20221109070931_company_city_ranking/migration.sql @@ -0,0 +1,5 @@ +-- AlterTable +ALTER TABLE "City" ADD COLUMN "ranking" INTEGER DEFAULT 0; + +-- AlterTable +ALTER TABLE "Company" ADD COLUMN "ranking" INTEGER DEFAULT 0; diff --git a/apps/portal/prisma/schema.prisma b/apps/portal/prisma/schema.prisma index 4a530ac4..31f846d9 100644 --- a/apps/portal/prisma/schema.prisma +++ b/apps/portal/prisma/schema.prisma @@ -99,6 +99,8 @@ model Company { description String? @db.Text logoUrl String? website String? + // The higher the value of the ranking, the higher it appears in the search results. + ranking Int? @default(0) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt @@ -133,6 +135,8 @@ model City { id String @id name String stateId String + // The higher the value of the ranking, the higher it appears in the search results. + ranking Int? @default(0) state State @relation(fields: [stateId], references: [id]) questionsQuestionEncounters QuestionsQuestionEncounter[] OffersExperience OffersExperience[] diff --git a/apps/portal/src/server/router/locations-router.ts b/apps/portal/src/server/router/locations-router.ts index 253d75a6..0094d744 100644 --- a/apps/portal/src/server/router/locations-router.ts +++ b/apps/portal/src/server/router/locations-router.ts @@ -10,7 +10,7 @@ export const locationsRouter = createRouter() async resolve({ ctx, input }) { return await ctx.prisma.city.findMany({ orderBy: { - name: 'asc', + ranking: 'desc', }, select: { id: true,