diff --git a/crates/ld-server/src/docs.rs b/crates/ld-server/src/docs.rs index d9cd60f..8776901 100644 --- a/crates/ld-server/src/docs.rs +++ b/crates/ld-server/src/docs.rs @@ -289,9 +289,11 @@ pub async fn load_state(state: &AppState, doc_id: &str) -> AppResult { .bind(doc_id) .fetch_all(&state.db) .await?; + // Same second (the variants of a seed): the order they were written in, not their + // random identifiers. The engine ranks rivals on its own; this order is what people see. let proposals = sqlx::query_as::<_, ProposalRow>(&format!( "{PROPOSAL_SELECT} WHERE p.unit_id IN (SELECT id FROM units WHERE doc_id = ?) - AND p.status IN ('open', 'in_force', 'draft') ORDER BY p.submitted_at, p.created_at, p.id" + AND p.status IN ('open', 'in_force', 'draft') ORDER BY p.submitted_at, p.created_at, p.rowid" )) .bind(doc_id) .fetch_all(&state.db) diff --git a/crates/ld-server/tests/api.rs b/crates/ld-server/tests/api.rs index f7574db..fd0263d 100644 --- a/crates/ld-server/tests/api.rs +++ b/crates/ld-server/tests/api.rs @@ -115,7 +115,9 @@ async fn the_seed_a_minima_and_the_open_proposals() { // Every other article is an open proposal at zero votes, standard inertia. let e3 = unit(&doc, "E3"); assert!(e3["inForce"].is_null()); - assert_eq!(e3["proposals"].as_array().expect("p").len(), 2, "E3 and its 0.4.0 variant"); + // In the order of the seed, whatever their random identifiers. + let labels: Vec<&str> = e3["proposals"].as_array().expect("p").iter().filter_map(|p| p["label"].as_str()).collect(); + assert_eq!(labels, ["1.0.0", "0.4.0-draft"], "E3 and its 0.4.0 variant"); assert_eq!(e3["inertia"], "standard"); // Translations seeded. assert!(e1["translations"]["en"]["body"].as_str().expect("en").contains("commit"));