-
Notifications
You must be signed in to change notification settings - Fork 21
Paper -> Count Route #219
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
base: staging
Are you sure you want to change the base?
Paper -> Count Route #219
Conversation
Created new component to display users starred papers
src/components/PapersCarousel.tsx
Outdated
function PapersCarousel({ | ||
carouselType, | ||
}: { | ||
carouselType: "users" | "default"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work in here, just change it to upcoming and users and make the default as upcoming using carouselType="default"
const { searchParams } = new URL(req.url); | ||
const subject = searchParams.get("subject"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
req.query.subject
should work
{ status: 200 } | ||
); | ||
const filter = subject ? { subject } : {}; | ||
const count = await Paper.countDocuments(filter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just maintain a counter in db
and increment those values on the fly
@@ -29,7 +29,7 @@ export async function GET(req: NextRequest) { | |||
if (papers.length === 0) { | |||
return NextResponse.json( | |||
{ message: "No papers found for the specified subject" }, | |||
{ status: 404 }, | |||
{ status: 200 }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errors shouldn't be 200
|
||
export async function POST(req: Request) { | ||
try { | ||
await connectToDatabase(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will happen at startup u dont need to do this
await connectToDatabase(); | ||
const body = (await req.json()) as StoredSubjects; | ||
|
||
const subjects = body; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant
made paper count route in api