Skip to content

Commit

Permalink
Merge pull request #1889 from Giveth/fetch-unlisted-projects
Browse files Browse the repository at this point in the history
Fetch unlisted projects
  • Loading branch information
MohammadPCh authored Dec 10, 2024
2 parents d6e3888 + 92f15c9 commit d12453d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/repositories/projectRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export type FilterProjectQueryInputParams = {
qfRoundId?: number;
activeQfRoundId?: number;
qfRoundSlug?: string;
includeUnlisted?: boolean;
};
export const filterProjectsQuery = (params: FilterProjectQueryInputParams) => {
const {
Expand All @@ -97,6 +98,7 @@ export const filterProjectsQuery = (params: FilterProjectQueryInputParams) => {
qfRoundId,
qfRoundSlug,
activeQfRoundId,
includeUnlisted,
} = params;

let query = Project.createQueryBuilder('project')
Expand All @@ -122,11 +124,16 @@ export const filterProjectsQuery = (params: FilterProjectQueryInputParams) => {
'projectPower.totalPower',
'projectPower.powerRank',
'projectPower.round',
])
.where(
]);

if (includeUnlisted) {
query = query.where(`project.statusId = ${ProjStatus.active}`);
} else {
query = query.where(
`project.statusId = ${ProjStatus.active} AND project.reviewStatus = :reviewStatus`,
{ reviewStatus: ReviewStatus.Listed },
);
}

const isFilterByQF =
!!filters?.find(f => f === FilterField.ActiveQfRound) && activeQfRoundId;
Expand Down Expand Up @@ -255,7 +262,6 @@ export const filterProjectsQuery = (params: FilterProjectQueryInputParams) => {
break;
case SortingField.BestMatch:
break;

default:
query
.addOrderBy('projectInstantPower.totalPower', OrderDirection.DESC)
Expand Down
5 changes: 5 additions & 0 deletions src/resolvers/projectResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ class GetProjectsArgs {

@Field(_type => String, { nullable: true })
qfRoundSlug?: string;

@Field({ nullable: true })
includeUnlisted?: boolean;
}

@ObjectType()
Expand Down Expand Up @@ -740,6 +743,7 @@ export class ProjectResolver {
campaignSlug,
qfRoundId,
qfRoundSlug,
includeUnlisted,
}: GetProjectsArgs,
@Ctx() { req: { user }, projectsFiltersThreadPool }: ApolloContext,
): Promise<AllProjects> {
Expand All @@ -766,6 +770,7 @@ export class ProjectResolver {
qfRoundId,
qfRoundSlug,
activeQfRoundId,
includeUnlisted,
};
let campaign;
if (campaignSlug) {
Expand Down

0 comments on commit d12453d

Please sign in to comment.