Skip to content

Commit

Permalink
update get contest top5
Browse files Browse the repository at this point in the history
  • Loading branch information
HUNG-rushb committed Nov 27, 2023
1 parent de9e7dd commit 52338db
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/Type_Definitions/Contest_Contest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const contestDefs = gql`
extend type Query {
allContests: [Contest]!
contestInfo(data: ContestInfoInput!): Contest!
getTopPostContest(data: ContestInfoInput!): [Post]!
contestPosts(
contestId: String
Expand All @@ -16,10 +17,6 @@ const contestDefs = gql`
contestId: ID!
}
input ContestPostsInput {
contestId: ID!
}
# _______________________________________________________
# _______________________________________________________
Expand Down
14 changes: 14 additions & 0 deletions src/resolvers/Query/CONTEST.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ const contestQuery = {
},
});
},
getTopPostContest: async (parent, args, info) => {
return await prisma.post.findMany({
where: {
contestId: args.data.contestId,
},
orderBy: [
{ points: 'desc' },
{
createdAt: 'desc',
},
],
take: 5,
});
},
contestPosts: async (parent, args, info) => {
const { contestId, userId: currentUserId, after } = args;
console.log(args);
Expand Down

0 comments on commit 52338db

Please sign in to comment.