transparentdemocracy / website

The frontend that visualizes the information obtained from the backend. Written in Angular.
1 stars 0 forks source link

Sort motions on descending plenary date #12

Closed sandervh14 closed 1 month ago

sandervh14 commented 2 months ago

I just noticed on the prototype screenshots the displayed motions start on plenary date in 2022. It would be nice if the homepage by default displays the motions ordered backwards in time, meaning the first pages shows the most recent motions.

idotj commented 1 month ago

I have been testing client-side pagination to get this issue and the solution trough Angular is very resource-intensive. I will suggest to change the approach and do it in another way (it will need to modify the backend request to include sorting parameters but I have no skills in that area).

The idea will be something like adding two new params in the url (&sortBy=date&order=desc): http://localhost:8080/motions/?page=1&size=10&sortBy=date&order=desc

The current test has the sort working, but you will see that has really poor performance (it needs to map all the motions and sort by date at the client side)

Branch name: test/sort-motions

sandervh14 commented 1 month ago

OK, I see. Thanks for looking into it!!

@GuidoDechamps can you add the 2 parameters on the backend? :-) This is important for the prototype, as for website users the more recent plenaries will be more interesting than those at the beginning of the legislature years ago. But also because we have tested our extraction of plenary reports more for recent reports than for the oldest reports, for the same reason. (I'll continue to add tests and identify needed improvements in our extraction to fix such cases.)

Anyway, so with the sorting in backend en frontend, we'd showcase the plenary reports that are most recent and interesting and that we're more sure about on top.

sandervh14 commented 1 month ago

Following from https://github.com/transparentdemocracy/website/issues/17#issuecomment-2138330437:

Currently, the implemented sorting on backend is now sorting on political term, plenary date and plenary number (for in case multiple plenaries occurred on the same date), in descending order.

At this time, I can't think of any other sorting that could be relevant. Unless maybe the same sorting, but in ascending order. But the same effect can be achieved by clicking the last page in the pagination element on the bottom of the page.

As conclusion: if you agree, I'd close this issue. You already said sorting was slow on frontend, it's now done on backend, and the above reasoning on no other ordering being relevant, makes the http://localhost:8080/motions/?page=1&size=10&sortBy=date&order=desc URL creation not interesting to implement.

I'm sorry for the work you put into it. I wanted to check how much that was, but I see the branch is not available on the github repo. I hope you think this is OK.

idotj commented 1 month ago

Yep, I deleted the branch because of high impact in performance and I will discourage to handle the sorting for that amount of data via Frontend. If sorting will stay as demanded and no option for the user to interact with the order (asc / desc) then no need to add new params.

No problem for me to close the issue