| | 1 | == User Views Public Reading Lists |
| | 2 | |
| | 3 | === Authors: **Regular User / Guest User** |
| | 4 | A user browses all public reading lists on the platform to discover new stories recommended by other readers. |
| | 5 | |
| | 6 | **1.** The user navigates to the "Community Reading Lists" section. |
| | 7 | |
| | 8 | **2.** The system retrieves all public reading lists along with their story counts. |
| | 9 | {{{#!sql |
| | 10 | SELECT rl.list_id, rl.name, rl.content, u.username, |
| | 11 | COUNT(rli.story_id) AS total_stories, rl.created_at |
| | 12 | FROM READING_LIST rl |
| | 13 | JOIN USERS u ON rl.user_id = u.user_id |
| | 14 | LEFT JOIN READING_LIST_ITEMS rli ON rl.list_id = rli.list_id |
| | 15 | WHERE rl.is_public = TRUE |
| | 16 | GROUP BY rl.list_id, u.username |
| | 17 | ORDER BY total_stories DESC; |
| | 18 | }}} |
| | 19 | |
| | 20 | **3.** The user selects a reading list to view its contents. |
| | 21 | |
| | 22 | **4.** The system displays all stories in that reading list with their details. |
| | 23 | {{{#!sql |
| | 24 | SELECT s.story_id, s.short_description, s.mature_content, |
| | 25 | u.username AS author, COUNT(l.user_id) AS likes, |
| | 26 | rli.added_at |
| | 27 | FROM READING_LIST_ITEMS rli |
| | 28 | JOIN STORY s ON rli.story_id = s.story_id |
| | 29 | JOIN USERS u ON s.user_id = u.user_id |
| | 30 | LEFT JOIN LIKES l ON s.story_id = l.story_id |
| | 31 | WHERE rli.list_id = 1 |
| | 32 | GROUP BY s.story_id, u.username, rli.added_at |
| | 33 | ORDER BY rli.added_at DESC; |
| | 34 | }}} |
| | 35 | |
| | 36 | **5.** The user clicks on a story from the list and is redirected to the story page. |