Changes between Version 12 and Version 13 of P6
- Timestamp:
- 04/28/26 10:50:51 (4 days ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
P6
v12 v13 26 26 COUNT(DISTINCT rli.list_id) AS saved_in_lists 27 27 FROM story s 28 JOIN writer w ON s.user_id = w.user_id29 JOIN users u ON w.user_id = u.user_id30 JOIN status st ON s.story_id = st.story_id31 LEFT JOIN chapter ch ON s.story_id = ch.story_id32 LEFT JOIN likes l ON s.story_id = l.story_id33 LEFT JOIN comment c ON s.story_id = c.story_id34 LEFT JOIN collaboration col ON s.story_id = col.story_id35 LEFT JOIN has_genre hg ON s.story_id = hg.story_id36 LEFT JOIN reading_list_items rli ON s.story_id = rli.story_id28 JOIN writer w ON s.user_id = w.user_id 29 JOIN users u ON w.user_id = u.user_id 30 JOIN status st ON s.story_id = st.story_id 31 LEFT JOIN chapter ch ON s.story_id = ch.story_id 32 LEFT JOIN likes l ON s.story_id = l.story_id 33 LEFT JOIN comment c ON s.story_id = c.story_id 34 LEFT JOIN collaboration col ON s.story_id = col.story_id 35 LEFT JOIN has_genre hg ON s.story_id = hg.story_id 36 LEFT JOIN reading_list_items rli ON s.story_id = rli.story_id 37 37 GROUP BY 38 38 DATE_TRUNC('quarter', s.story_created_at), … … 51 51 / NULLIF(total_chapters, 0), 2 52 52 ) AS avg_views_per_chapter, 53 LAG(total_views) OVER (PARTITION BY story_id ORDER BY quarter) AS prev_quarter_views,54 LAG(total_likes) OVER (PARTITION BY story_id ORDER BY quarter) AS prev_quarter_likes,53 LAG(total_views) OVER (PARTITION BY story_id ORDER BY quarter) AS prev_quarter_views, 54 LAG(total_likes)OVER (PARTITION BY story_id ORDER BY quarter) AS prev_quarter_likes, 55 55 LAG(total_comments) OVER (PARTITION BY story_id ORDER BY quarter) AS prev_quarter_comments 56 56 FROM quarterly_story_stats … … 114 114 Base ← 115 115 story s 116 ⨝ (s.user_id = w.user_id) writer w117 ⨝ (w.user_id = u.user_id) users u116 ⨝ (s.user_id = w.user_id) writer w 117 ⨝ (w.user_id = u.user_id) users u 118 118 ⨝ (s.story_id = st.story_id) status st 119 119 120 120 WithChapters ← 121 121 Base 122 ⟕ (s.story_id = ch.story_id) chapter ch122 ⟕ (s.story_id = ch.story_id) chapter ch 123 123 124 124 WithLikes ← 125 125 WithChapters 126 ⟕ (s.story_id = l.story_id) likes l126 ⟕ (s.story_id = l.story_id) likes l 127 127 128 128 WithComments ← 129 129 WithLikes 130 ⟕ (s.story_id = c.story_id) comment c130 ⟕ (s.story_id = c.story_id) comment c 131 131 132 132 WithCollabs ← … … 136 136 WithGenres ← 137 137 WithCollabs 138 ⟕ (s.story_id = hg.story_id) has_genre hg138 ⟕ (s.story_id = hg.story_id) has_genre hg 139 139 140 140 WithLists ← … … 159 159 total_collaborators := COUNT(DISTINCT col.user_id), 160 160 total_genres := COUNT(DISTINCT hg.genre_id), 161 saved_in_lists := COUNT(DISTINCT rli.list_id)161 saved_in_lists := COUNT(DISTINCT rli.list_id) 162 162 ( 163 163 WithLists … … 169 169 ROUND((total_likes + total_comments) / NULLIF(total_views, 0) * 100, 2) → engagement_rate, 170 170 ROUND(total_views / NULLIF(total_chapters, 0), 2) → avg_views_per_chapter, 171 LAG(total_views) OVER (PARTITION BY story_id ORDER BY quarter) → prev_quarter_views,172 LAG(total_likes) OVER (PARTITION BY story_id ORDER BY quarter) → prev_quarter_likes,171 LAG(total_views) OVER (PARTITION BY story_id ORDER BY quarter) → prev_quarter_views, 172 LAG(total_likes) OVER (PARTITION BY story_id ORDER BY quarter) → prev_quarter_likes, 173 173 LAG(total_comments) OVER (PARTITION BY story_id ORDER BY quarter) → prev_quarter_comments 174 174 ( … … 242 242 FROM genre g 243 243 JOIN has_genre hg ON g.genre_id = hg.genre_id 244 JOIN story s ON hg.story_id = s.story_id245 JOIN writer w ON s.user_id = w.user_id246 JOIN status st ON s.story_id = st.story_id AND st.status = 'published'244 JOIN story s ON hg.story_id = s.story_id 245 JOIN writer w ON s.user_id = w.user_id 246 JOIN status st ON s.story_id = st.story_id AND st.status = 'published' 247 247 LEFT JOIN chapter ch ON s.story_id = ch.story_id 248 248 LEFT JOIN likes l ON s.story_id = l.story_id
