You are a constitutional council ranking individual git commits for ownership allocation. Compare these two commits. Decide which contributed more lasting value to the project. Judge substance, not spectacle: - Prefer correct, lasting design and real bugfixes over churn, formatting, renames, or generated noise. - Prefer clarity and necessity over sheer line count. A small precise change can beat a large diffuse one. - Do not favor a side merely because its patch is longer or noisier. - Weight what the change does for the project, not the contributor's name. Return ONLY a JSON object: {"winner": "A" or "B", "ratio": "N:M", "explanation": "..."} The explanation must cite concrete differences in the patches (1-3 sentences). Side A — contributor: tommy-mor Side A — commit message: [03cd8f2e] Skip pinned Reddit posts when importing subreddit listings. Co-authored-by: Cursor Side A — unified diff (full patch): diff --git a/server/src/reddit.rs b/server/src/reddit.rs index f409764c1e1f36216f1b08107043c2eab905694c..fa5577f8ee0a8c53ff4dbec988a90a5d2fc3cdee 100644 --- a/server/src/reddit.rs +++ b/server/src/reddit.rs @@ -661,6 +661,7 @@ pub fn map_children_url(id: &ItemId, api_base: &str) -> String { /// Parse a subreddit listing payload into `(child_id, child_payload)` entries. /// Each child id is the post's permalink under `reddit.com/…`, and the payload /// is the raw `{kind, data}` listing element (persisted per child). +/// Pinned / stickied posts are skipped. fn parse_children(_parent: &ItemId, payload: &Value) -> Vec<(ItemId, Value)> { let mut out = Vec::new(); let children = match payload.pointer("/data/children").and_then(|c| c.as_array()) { @@ -668,6 +669,9 @@ fn parse_children(_parent: &ItemId, payload: &Value) -> Vec<(ItemId, Value)> { None => return out, }; for child in children { + if child_is_pinned(child) { + continue; + } let permalink = match child.pointer("/data/permalink").and_then(|p| p.as_str()) { Some(p) if !p.is_empty() => p, _ => continue, @@ -680,6 +684,15 @@ fn parse_children(_parent: &ItemId, payload: &Value) -> Vec<(ItemId, Value)> { out } +fn child_is_pinned(child: &Value) -> bool { + let data = match child.get("data") { + Some(d) => d, + None => return false, + }; + data.get("stickied").and_then(|v| v.as_bool()) == Some(true) + || data.get("pinned").and_then(|v| v.as_bool()) == Some(true) +} + fn parse_reddit_view(id: &ItemId, v: &Value) -> Option { let segments: Vec<&str> = id.as_str().split('/').collect(); @@ -853,4 +866,46 @@ mod tests { Some("http://v3.redgifs.com/watch/impossibleprestigioushedgehog") ); } + + #[test] + fn parse_children_skips_pinned_posts() { + let payload = serde_json::json!({ + "kind": "Listing", + "data": { + "children": [ + { + "kind": "t3", + "data": { + "title": "Official rules (pinned)", + "permalink": "/r/rust/comments/pin/official_rules/", + "stickied": true + } + }, + { + "kind": "t3", + "data": { + "title": "Also pinned via pinned field", + "permalink": "/r/rust/comments/pin2/also_pinned/", + "pinned": true + } + }, + { + "kind": "t3", + "data": { + "title": "Normal post", + "permalink": "/r/rust/comments/aaa/normal_post/", + "stickied": false + } + } + ] + } + }); + let parent = ItemId::from_url("https://reddit.com/r/rust").unwrap(); + let children = parse_children(&parent, &payload); + assert_eq!(children.len(), 1); + assert_eq!( + children[0].0.as_str(), + "https://reddit.com/r/rust/comments/aaa" + ); + } } Side B — contributor: tommy-mor Side B — commit message: [3bc88847] removed optional Side B — unified diff (full patch): diff --git a/server/src/api/rpc.rs b/server/src/api/rpc.rs index ba93ca87182d49f57dffc8220f604ffa150f9a6c..5049a26b096bd8435d6eb9e75ccb751b6f489061 100644 --- a/server/src/api/rpc.rs +++ b/server/src/api/rpc.rs @@ -1337,8 +1337,7 @@ pub async fn handle_rpc_batch( .ingests_by_scope_thread .get(&(scope.clone(), e.thread.clone())) .and_then(|q| q.iter().rev().position(|id| id == &e.post_id)) - .map(|i| i + 1) - .unwrap_or(0); + .expect("rank history post_id must be in ingests_by_scope_thread for (scope, thread)"); RankHistoryRow { ts: e.ts, scope_rank: e.scope_rank, diff --git a/server/src/html/garden.rs b/server/src/html/garden.rs index 319feb15a6b68d2b5df98b4289fedbc9bdd048d3..23245d6fdfc9019b199ab8417150faf5f3297067 100644 --- a/server/src/html/garden.rs +++ b/server/src/html/garden.rs @@ -450,6 +450,7 @@ struct RankHistoryEntryView { scope_total: usize, scope_rank_delta: i32, thread: String, + /// 0-based index as [`crate::html::forum::ingest::thread_post_index_in_scope`] / `/t/tag/N`. thread_post_index: usize, caused_by: Vec, } @@ -573,11 +574,11 @@ fn build_rank_history( }) .unwrap_or_default(); - let thread_post_index = reduced.ingests_by_scope_thread + let thread_post_index = reduced + .ingests_by_scope_thread .get(&(scope.clone(), e.thread.clone())) .and_then(|q| q.iter().rev().position(|id| id == &e.post_id)) - .map(|i| i + 1) - .unwrap_or(0); + .expect("rank history post_id must be in ingests_by_scope_thread for (scope, thread)"); RankHistoryEntryView { ts: e.ts, @@ -704,11 +705,9 @@ async fn render_scope_view( span class="muted" { (ago) (label) } " · " a href=(thread_href(&e.thread)) { "#" (e.thread) } - @if e.thread_post_index > 0 { - " " - a href=(format!("{}/{}", thread_href(&e.thread), e.thread_post_index)) { - span class="muted" { "post #" (e.thread_post_index) } - } + " " + a href=(format!("{}/{}", thread_href(&e.thread), e.thread_post_index)) { + span class="muted" { "post #" (e.thread_post_index) } } } @if e.caused_by.is_empty() { diff --git a/server/tests/integration.rs b/server/tests/integration.rs index d4c5bfe9c6f1c71dc61878bd8c5e729b1b7c69ef..9766adb43ad315a64f5df17b79f66718ce149509 100644 --- a/server/tests/integration.rs +++ b/server/tests/integration.rs @@ -1322,6 +1322,11 @@ async fn test_rank_history() { assert_eq!(entry["scope_rank_delta"], 0, "delta is 0 on first appearance"); let caused_by = entry["caused_by"].as_array().unwrap(); assert_eq!(caused_by.len(), 2, "both votes in the ingest touched rust"); + assert_eq!( + entry["thread_post_index"], + 0, + "rank history links use same 0-based index as /t/hist-test/0" + ); ingest( "00000000-0000-0000-0000-000000000002:rig:test/model", @@ -1349,6 +1354,16 @@ async fn test_rank_history() { assert_eq!(caused_by2.len(), 1); assert!(caused_by2[0]["a"].as_str().unwrap().ends_with("python") || caused_by2[0]["b"].as_str().unwrap().ends_with("python")); + assert_eq!( + hist2[0]["thread_post_index"], + 0, + "first hist-test post is chronological index 0" + ); + assert_eq!( + hist2[1]["thread_post_index"], + 1, + "second ingest is chronological index 1" + ); let hist_rust2 = rpc_batch( &client, diff --git a/types/src/lib.rs b/types/src/lib.rs index edbb923e4d7d41ad82dfc254c3bd697562383527..49abba8ea9f786ef68e3157d2a5d309e15e09ba0 100644 --- a/types/src/lib.rs +++ b/types/src/lib.rs @@ -253,7 +253,7 @@ pub struct FeedPost { /// Primary thread tag (without #), if the ingest declared one. #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option, - /// 1-indexed chronological position of this post within the thread. + /// 1-based display ordinal for this post within the thread (feed only; URLs use 0-based paths). #[serde(skip_serializing_if = "Option::is_none")] pub thread_post_index: Option, /// Full raw body of the ingest document. @@ -628,7 +628,7 @@ pub struct RankHistoryRow { pub score: f64, /// Thread tag of the ingest that triggered this rank change. pub thread: String, - /// 1-indexed chronological position of this post within the thread. + /// 0-indexed chronological position of this post within the thread (same as `/t/tag/N` routes). pub thread_post_index: usize, /// Votes from this ingest that directly touched this item. Empty when change was transitive. pub caused_by: Vec,