Page MenuHomePhabricator

Add an option to sort list of books alphabetically
Closed, ResolvedPublic

Description

Currently, the list of books are sorted in the Wikisource reader app based on the pageviews data denoting their popularity. Books with more views are placed earlier than the books with relatively lesser views. But books can also be sorted alphabetically in addition to the default sorting option through pageviews. .

The alphabetical sorting should be made possible from the wsindex API and then the sorting option should be visible in UI.

In the sort options, there should be two ways to sort - 1) existing popularity based sort 2) alphabetical based sort. More options can come in future

Event Timeline

Hello @Bodhisattwa , I would like to take this issue

sure, please go ahead

@System625 pls make sure you enable a way to sort alphabetically (A to Z and also Z to A) and popularity (high to low is by default available now, need to work on low to high if I'm not wrong) from the API before working on adding the sort function in the App UI. The repo for the API is: https://codeberg.org/ph4ni/wsindex

@Saiphani02 I have noted this, thank you. So I have to first made changes in the API repo right?

Hi @Saiphani02 @Bodhisattwa
I have made a PR in the API repo: https://codeberg.org/ph4ni/wsindex/pulls/4
Please kindly review. Once merged, I’ll commence work on the UI

Thank you for the PR. The primary mentor @Saiphani02 will review it in his due time.

@System625 , thanks for the PR. Its a festive season in India and we are celebrating Diwali with our friends and families and it might take a couple of days to be back. Don't worry, the PR you have submitted will be reviewed as soon as we return. Thanks for your understanding.

@System625 , thanks for the PR. Its a festive season in India and we are celebrating Diwali with our friends and families and it might take a couple of days to be back. Don't worry, the PR you have submitted will be reviewed as soon as we return. Thanks for your understanding.

No problem. Happy Diwali

Hi @System625, I've changed the title field to title_native_language as a temporary fix since title fields are empty for most non-English language works. As a separate contribution, can you update the logic to check for both 'title_native_language' and 'title' fields and prioritize sorting in that order? If 'title_native_language' is empty and 'title' exists, you can use 'title' for sorting.

Hello @Saiphani02 , I've created a PR concerning the logic update: https://codeberg.org/ph4ni/wsindex/pulls/6
please kindly review

Hello @Saiphani02 , I've created a PR concerning the logic update: https://codeberg.org/ph4ni/wsindex/pulls/6
please kindly review

The PR has been merged in the API repo. Please move forward on the UI part.

Hi @Saiphani02 @Bodhisattwa , I've implemented the sort functionality in the Android app UI and it's passing the correct sort parameters to the API (verified via logs). However, the API seems to be returning the same books in the same order regardless of the sort parameter. Test URLs:
https://wsindex.toolforge.org/books?page=1&sort=title_asc
https://wsindex.toolforge.org/books?page=1&sort=title_desc
https://wsindex.toolforge.org/books?page=1&sort=popularity_asc
All return: "Constitution of the United States of America", "Jibanananda Dasher Shrestha Kabita", "The Osteology of the Reptiles" as the first 3 books. Has the API been deployed to production? The UI implementation is complete and ready for testing once the API sort is working.

Missed deploying the recent title name fix. Done now. The keys are title, -title, view_count, -view_count right?

Example: https://wsindex.toolforge.org/books/?page=1&sort=title

@Saiphani02 yes you are correct
I’ll test it out soon, thank you

Hi @Saiphani02 , I've made a PR: https://github.com/cis-india/Wikisource-Reader/pull/53
The sorting works on the UI now. Please kindly review

Thank you, working perfectly!

You’re welcome!
I’ll be starting afresh on task T406912 if that’s okay, I noticed the contributor who claimed it has dropped it