Skip to content

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

Open
wants to merge 10 commits into
base: staging
Choose a base branch
from

Conversation

Advik-Gupta
Copy link

made paper count route in api

@abhitrueprogrammer
Copy link
Collaborator

image

make a note to put a button that redirects to the page for adding new papers incase there isn't one in the design

function PapersCarousel({
carouselType,
}: {
carouselType: "users" | "default";
Copy link
Collaborator

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"

Comment on lines +11 to +12
const { searchParams } = new URL(req.url);
const subject = searchParams.get("subject");
Copy link
Contributor

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);
Copy link
Contributor

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 },
Copy link
Contributor

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();
Copy link
Contributor

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;
Copy link
Contributor

Choose a reason for hiding this comment

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

redundant

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.

3 participants