From b4fada022e3fde89206e416fed87b2c81fcdadf9 Mon Sep 17 00:00:00 2001 From: mohammadranjbarz Date: Fri, 18 Oct 2024 12:48:37 +0300 Subject: [PATCH] hotfix 4844 fix instant boosting sort (#1863) * Fix instant boosting sort related to #Giveth/giveth-dapps-v2/4844 * Remove .only from test cases --- src/repositories/projectRepository.ts | 7 ++++--- .../projectResolver.allProject.test.ts | 19 ++++++++++++++++--- test/pre-test-scripts.ts | 4 ++-- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/repositories/projectRepository.ts b/src/repositories/projectRepository.ts index 34bb4f907..d500b41bb 100644 --- a/src/repositories/projectRepository.ts +++ b/src/repositories/projectRepository.ts @@ -209,13 +209,14 @@ export const filterProjectsQuery = (params: FilterProjectQueryInputParams) => { break; case SortingField.InstantBoosting: // This is our default sorting query - .addOrderBy('project.isGivbackEligible', 'DESC') // Primary sorting condition - .addOrderBy('project.verified', 'DESC') // Secondary sorting condition .addOrderBy( 'projectInstantPower.totalPower', OrderDirection.DESC, 'NULLS LAST', - ); + ) + .addOrderBy('project.isGivbackEligible', 'DESC') // Primary sorting condition + .addOrderBy('project.verified', 'DESC'); // Secondary sorting condition + if (isFilterByQF) { query.addOrderBy( 'project.sumDonationValueUsdForActiveQfRound', diff --git a/src/resolvers/projectResolver.allProject.test.ts b/src/resolvers/projectResolver.allProject.test.ts index 533e61209..c6543637d 100644 --- a/src/resolvers/projectResolver.allProject.test.ts +++ b/src/resolvers/projectResolver.allProject.test.ts @@ -550,12 +550,25 @@ function allProjectsTestCases() { const user1 = await saveUserDirectlyToDb(generateRandomEtheriumAddress()); const user2 = await saveUserDirectlyToDb(generateRandomEtheriumAddress()); - const project1 = await saveProjectDirectlyToDb(createProjectData()); - const project2 = await saveProjectDirectlyToDb(createProjectData()); - const project3 = await saveProjectDirectlyToDb(createProjectData()); + const project1 = await saveProjectDirectlyToDb({ + ...createProjectData(), + verified: true, + isGivbackEligible: true, + }); + const project2 = await saveProjectDirectlyToDb({ + ...createProjectData(), + verified: true, + isGivbackEligible: false, + }); + const project3 = await saveProjectDirectlyToDb({ + ...createProjectData(), + verified: true, + isGivbackEligible: true, + }); const project4 = await saveProjectDirectlyToDb({ ...createProjectData(), verified: false, + isGivbackEligible: false, }); // Not boosted -Not verified project await saveProjectDirectlyToDb(createProjectData()); // Not boosted project diff --git a/test/pre-test-scripts.ts b/test/pre-test-scripts.ts index 6c5cfa285..da482f3a5 100644 --- a/test/pre-test-scripts.ts +++ b/test/pre-test-scripts.ts @@ -40,9 +40,9 @@ import { ProjectActualMatchingViewV161717646612482 } from '../migration/17176466 import { LastSnapshotProjectPowerViewV21717648491606 } from '../migration/1717648491606-LastSnapshotProjectPowerView_V2'; import { ProjectFuturePowerViewV21717643016553 } from '../migration/1717643016553-ProjectFuturePowerView_V2'; import { ProjectUserInstantPowerViewV21717644442966 } from '../migration/1717644442966-ProjectUserInstantPowerView_V2'; -import { ProjectInstantPowerViewV21717648653115 } from '../migration/1717648653115-ProjectInstantPowerView_V2'; import { UserProjectPowerViewV21717645768886 } from '../migration/1717645768886-UserProjectPowerView_V2'; import { ProjectGivbackRankViewV31725260193333 } from '../migration/1725260193333-projectGivbackRankView'; +import { ProjectInstantPowerViewV31724223781248 } from '../migration/1724223781248-ProjectInstantPowerViewV3'; async function seedDb() { await seedUsers(); @@ -538,7 +538,7 @@ async function runMigrations() { queryRunner, ); await new createOrganisatioTokenTable1646302349926().up(queryRunner); - await new ProjectInstantPowerViewV21717648653115().up(queryRunner); + await new ProjectInstantPowerViewV31724223781248().up(queryRunner); await new ProjectEstimatedMatchingViewV21717646357435().up(queryRunner); await new ProjectUserInstantPowerViewV21717644442966().up(queryRunner); await new TakePowerBoostingSnapshotProcedureSecondVersion1690723242749().up(