Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): add endpoint to get votes #416

Merged
merged 4 commits into from
Dec 14, 2022

Conversation

xStrixU
Copy link
Contributor

@xStrixU xStrixU commented Dec 14, 2022

Fixes #414

@vercel
Copy link

vercel bot commented Dec 14, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated
devfaq ⬜️ Ignored (Inspect) Dec 14, 2022 at 0:34AM (UTC)

@github-actions
Copy link

github-actions bot commented Dec 14, 2022

📦 Next.js Bundle Analysis

This analysis was generated by the next.js bundle analysis action 🤖

This PR introduced no changes to the javascript bundle 🙌

Comment on lines 136 to 164
const { category, level, status = "accepted", limit, offset, order, orderBy } = request.query;
const levels = level?.split(",");

const where = {
...(category && { categoryId: category }),
...(levels && { levelId: { in: levels } }),
...(status && request.session.data?._user._roleId === "admin"
? { statusId: status }
: { statusId: "accepted" }),
};

const questions = await fastify.db.question.findMany({
where,
take: limit,
skip: offset,
...(order &&
orderBy && {
orderBy: {
...(orderBy === "votesCount"
? {
QuestionVote: {
_count: order,
},
}
: {
[orderBy]: order,
}),
},
}),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Większość kodu się powtarza w /questions – może przydałoby się to wynieść?

@typeofweb typeofweb merged commit 874d911 into develop Dec 14, 2022
@typeofweb typeofweb deleted the 414-add-endpoint-to-get-votes branch December 14, 2022 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add endpoint to get votes
2 participants