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

Show recent records on the home page #70

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

damianmarti
Copy link
Collaborator

@damianmarti damianmarti commented Feb 23, 2024

closes #68

@damianmarti damianmarti requested a review from carletex February 23, 2024 23:23
Copy link

vercel bot commented Feb 23, 2024

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

Name Status Preview Comments Updated (UTC)
collectivedaoarchives-catalog ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 27, 2024 10:27am

@carletex
Copy link
Collaborator

Hey @damianmarti ,

now the ones that show first, are the ones that don't have a Date:

image

@damianmarti
Copy link
Collaborator Author

Hey @damianmarti ,

now the ones that show first, are the ones that don't have a Date:

image

Thanks @carletex

Now I'm filtering the records with date not null.

@carletex
Copy link
Collaborator

Hey @damianmarti thanks for this!

I see one «problem» when filtering out the ones without a date: the /records page uses the same endpoint

This is off because of it: (total count still gets ALL the records)
image

Not sure if this is a big deal, but just mentioning it here.


I remember tweaking the search query for this same reason, but it was rawSQL: "date-desc": Prisma.sqlCASE WHEN date IS NULL THEN 1 ELSE 0 END, "date" DESC,

What do you think?

@damianmarti
Copy link
Collaborator Author

Hey @damianmarti thanks for this!

I see one «problem» when filtering out the ones without a date: the /records page uses the same endpoint

This is off because of it: (total count still gets ALL the records) image

Not sure if this is a big deal, but just mentioning it here.

I remember tweaking the search query for this same reason, but it was rawSQL: "date-desc": Prisma.sqlCASE WHEN date IS NULL THEN 1 ELSE 0 END, "date" DESC,

What do you think?

Thanks!! I thought it was not used in another place. Let me check for a better solution.

@damianmarti
Copy link
Collaborator Author

@carletex please take a look now. I created a new backend endpoint for the home records, so we can do whatever we want to the records shown on the home page and not affect the rest of the site. Thanks and sorry for the previous issues!

@carletex
Copy link
Collaborator

@carletex please take a look now. I created a new backend endpoint for the home records, so we can do whatever we want to the records shown on the home page and not affect the rest of the site. Thanks and sorry for the previous issues!

This still has the same problem on the /records page, since we are filtering out the records with no dates (and pagination is off because off it too)

Let me try to come up with a solution!

@carletex
Copy link
Collaborator

@damianmarti so I added this: 80fcb74

It's a raw query so we can order elements with no date at the end and everything keeps working the same.

  • had to select specific fields (id, title, etc) because the tsvector from the text search was giving errors.
  • Had to put quotes " to some fields, because if not it wasn't case sensitive 🤷‍♂️

Let me know what you think. Thanks!!

@damianmarti
Copy link
Collaborator Author

@carletex Oh, no, sorry! I forgot to push the changes to records.ts, to leave it at it was before, so the change only affects the home page!

Your change looks good, I was trying to avoid using raw SQL to keep it simple.

We can go with your change or we can add again the backend endpoint for the home page, but keeping the records endpoint as it was before. Please let me know what you prefer. Thanks!!

@carletex
Copy link
Collaborator

We can go with your change or we can add again the backend endpoint for the home page, but keeping the records endpoint as it was before. Please let me know what you prefer. Thanks!!

The only PRO I see of doing the raw SQL is that we are also sorting by date DESC correctly on the /records page. If we don't need that, let's use the homepage endpoint.

Let's ask @amy-jung !!

Amy, do we want to sort by date DESC the /records page, or just the homepage?

Thanks all! <3

@amy-jung
Copy link
Owner

Sorry what is DESC?

Ideally we would just have both! (Assuming when you search, the default is by closest to search, then by date)

@damianmarti
Copy link
Collaborator Author

Sorry what is DESC?

Ideally we would just have both! (Assuming when you search, the default is by closest to search, then by date)

It means the most recent record first. We can show the most recent records on the home page and with the same ordering on the records page too. Is it ok for you?

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.

Shuffle Records on Home Page
3 participants