From b8bc0443f6affbee79a8d1a968eb08cda5c7fc10 Mon Sep 17 00:00:00 2001 From: Johannes Horn Date: Fri, 13 Nov 2026 22:56:19 +0100 Subject: [PATCH 01/14] docs: explain sorting choices and the single Playwright worker --- docs/choices-and-reasoning.md | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/docs/choices-and-reasoning.md b/docs/choices-and-reasoning.md index 47271ccc..4d5883ea 100644 --- a/docs/choices-and-reasoning.md +++ b/docs/choices-and-reasoning.md @@ -54,12 +54,30 @@ Search results are fetched 12 at a time with `limit` and `offset`, together with We chose offset pagination based on how we expect the app to be used. Most users look at the first few pages of results, and change their search or filters if they don't find what they are looking for. The cost of `offset` only grows with how far out you go: to show page 600, the database has to step past all the rows on the pages before it. Since browsing that deep is very rare, we think page numbers are worth more to our users than what we would gain from keyset (cursor) pagination, which keeps every page equally fast but only lets you move to the next or previous page. The pagination in the interface shows the first and last page and the pages around the current one, so an arbitrary page can only be opened from the URL. With page numbers, the URL stays short and readable, and we can show which page you are on out of how many. -As the dataset grows, keeping the first pages fast depends on database indexes on the columns we sort and filter by (planned in #77), and the total count could be capped or estimated instead of counting every match. +Keeping the first pages fast depends on database indexes. We have added indexes on the columns we sort by (number of ratings, rating, title, pages and publish year), on the language and book format filters, and trigram indexes for the search on title and author (see `backend/src/db/schema/books.ts`). If the dataset grows much larger, the total count could be capped or estimated instead of counting every match. ## Books without ratings are stored as NULL The dataset uses a rating of 0.0 for books nobody has rated. We store these as `NULL` instead, so they aren't treated as the worst-rated books, and they are placed last when sorting by rating. +## Sorting + +The search results can be sorted by relevance (the default), rating, title, publish date and number of pages. + +Relevance shows the books with the most ratings first, so well-known books come before books that few people have rated. When a search has no exact matches and we show books with similar titles or authors instead, the closest match comes first. + +### Sorting by highest rating adds a minimum number of ratings + +When the user chooses "Rating: high to low", we also add the filter "10,000+ ratings", unless the user has already chosen a minimum number of ratings. A toast tells the user that the filter was added, and that it can be changed in the filters. + +Without a minimum, this sort order is not very useful. More than 800 books in our dataset have a rating of 5.0, and the one with the most ratings has only 36, so about the first 70 pages would be books that almost nobody has rated. A single 5-star review from one of our users on a book without ratings would also place it among them. With the minimum, about 12,600 of our roughly 52,000 books are left, and it is the same limit as we use for the top-rated books on the home page. + +We discussed whether a filter that is chosen for the user is more annoying than useful (#117). We kept it because it is easy to notice and easy to remove: the toast explains it, the filter button shows how many filters are active, and the minimum can be set back to "Any". We also never replace a minimum that the user has chosen. The filter stays when the user switches to another sort order, since filters and sorting are independent everywhere else. + +### No sorting by author + +We do not offer sorting by author (#100). The author field in the dataset is free text and can hold several names, like "Author One, Author Two". We have no guarantee that the authors of a book are always listed in the same order, or whether a name is written as "First Last" or "Last, First", so sorting on this field would often give an order that looks random. Authors can be found with the search field instead, which searches both titles and authors. + ## Selecting several genres shows books in any of them When several genres are selected, we show books that belong to at least one of them (OR), not all of them (AND). This is because it widens the search instead of quickly ending up with no results. @@ -84,11 +102,15 @@ These cover almost all of the browser engines that are in use, i.e. Chromium, Ge We have skipped Microsoft Edge and (branded) Google Chrome because we already test Chromium, which is the browser engine these use. Mobile Chrome and Mobile Safari are used to test the app on mobile screens. +We run the tests with one worker, so only one test runs at a time (`workers: 1` in `frontend/playwright.config.ts`). +With several workers, the tests run in several browsers at the same time against the same local backend, and we got timeouts and other failures that were not caused by bugs in the app. +How many workers a machine can handle differs, so one worker gives the same results for everyone on the team. The price is that a full run takes longer. + We do not use CI for E2E tests. Our VM only has 1 CPU core available and the tests take a very long time. They also slow down our app, which is running on the same server. Instead, we use CI for other tasks, such as linting and formatting. ## Changes/not implemented yet from our specification -- **Filters:** We filter on genres, language, book format and number of pages. The specification also mentioned author, publisher, place and person, which we have not implemented yet. +- **Filters:** We filter on genres, language, book format, number of pages and a minimum number of ratings. The specification also mentioned author, publisher, place and person. Authors are covered by the search field, which searches both titles and authors, and we have not implemented filters for publisher, place and person. - **Login:** Instead of Google login, we support email/password and GitHub and Discord login. Google was rejected since it required https connection, which we do not provide. -- **Reviews:** Reviews with a star rating are planned for the next delivery. +- **Reviews:** Implemented in delivery 4 as specified, with a star rating from 1 to 5 and an optional text. Reviews are written and shown on the book's page, and the user's own reviews are also listed on their profile. A book's rating combines the rating from the dataset with the reviews from our users. From b3ccb1f92bd7658a90fbfac6201ac804af8c7b1c Mon Sep 17 00:00:00 2001 From: Johannes Horn Date: Fri, 13 Nov 2026 22:56:19 +0100 Subject: [PATCH 02/14] docs: explain when we use div and span --- docs/accessibility.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/accessibility.md b/docs/accessibility.md index 5c0bf212..6947b73a 100644 --- a/docs/accessibility.md +++ b/docs/accessibility.md @@ -4,6 +4,8 @@ - **Semantic HTML.** The page language is set (``), the main navigation is a `