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

fix: set initial ordering to relevance in the frontend component #766

Merged
merged 4 commits into from
Oct 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/components/CodebaseListSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const initializeFilterValues = () => {
values.endDate = urlParams.get("publishedBefore")
? new Date(urlParams.get("publishedBefore")!)
: null;
values.ordering = urlParams.get("ordering") || "-first_published_at";
values.ordering = urlParams.get("ordering") || "relevance";
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain what behavior this is attempting to fix? The initial sort order should be newest to oldest as "relevance" doesn't make sense on initial load; won't this set the initial sort order to "relevance" when the ordering query param isn't explicitly set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the user sets the ordering explicitely, the ordering will be available through urlParams.get("ordering"). If not, the default ordering during searching (seqrch query is not empty) is "relevance".

But I guess, you also have a point, namely: when there is no search query, just filtering by programming languages. In which case it should be something like:

values.ordering = urlParams.get("ordering") || (urlParams.get("query") ? "relevance" : "-first_published_at");


initialFilterValues.value = { ...values };
};
Expand Down
Loading