APIs for links and references in the ATmosphere

fixes at-microcosm#24 refactor to avoid extra db query by putting total in PagedAppendingCollection struct

+13 -12
+2 -12
constellation/src/server/mod.rs
··· 274 .get_links(&query.target, &query.collection, &query.path, limit, until) 275 .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)?; 276 277 - let total = store 278 - .get_count(&query.target, &query.collection, &query.path) 279 - .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)?; 280 - 281 let cursor = paged.next.map(|next| { 282 ApiCursor { 283 version: paged.version, ··· 289 Ok(acceptable( 290 accept, 291 GetLinkItemsResponse { 292 - total: total, 293 linking_records: paged.items, 294 cursor, 295 query: (*query).clone(), ··· 339 .get_distinct_dids(&query.target, &query.collection, &query.path, limit, until) 340 .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)?; 341 342 - let distinct_dids_total = store 343 - .get_distinct_did_count(&query.target, &query.collection, &query.path) 344 - .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)?; 345 - 346 - 347 - 348 let cursor = paged.next.map(|next| { 349 ApiCursor { 350 version: paged.version, ··· 356 Ok(acceptable( 357 accept, 358 GetDidItemsResponse { 359 - total: distinct_dids_total, 360 linking_dids: paged.items, 361 cursor, 362 query: (*query).clone(),
··· 274 .get_links(&query.target, &query.collection, &query.path, limit, until) 275 .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)?; 276 277 let cursor = paged.next.map(|next| { 278 ApiCursor { 279 version: paged.version, ··· 285 Ok(acceptable( 286 accept, 287 GetLinkItemsResponse { 288 + total: paged.total, 289 linking_records: paged.items, 290 cursor, 291 query: (*query).clone(), ··· 335 .get_distinct_dids(&query.target, &query.collection, &query.path, limit, until) 336 .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)?; 337 338 let cursor = paged.next.map(|next| { 339 ApiCursor { 340 version: paged.version, ··· 346 Ok(acceptable( 347 accept, 348 GetDidItemsResponse { 349 + total: paged.total, 350 linking_dids: paged.items, 351 cursor, 352 query: (*query).clone(),
+6
constellation/src/storage/mem_store.rs
··· 173 version: (0, 0), 174 items: Vec::new(), 175 next: None, 176 }); 177 }; 178 let Some(did_rkeys) = paths.get(&Source::new(collection, path)) else { ··· 180 version: (0, 0), 181 items: Vec::new(), 182 next: None, 183 }); 184 }; 185 ··· 209 version: (total as u64, gone as u64), 210 items, 211 next, 212 }) 213 } 214 ··· 226 version: (0, 0), 227 items: Vec::new(), 228 next: None, 229 }); 230 }; 231 let Some(did_rkeys) = paths.get(&Source::new(collection, path)) else { ··· 233 version: (0, 0), 234 items: Vec::new(), 235 next: None, 236 }); 237 }; 238 ··· 275 version: (total as u64, gone as u64), 276 items, 277 next, 278 }) 279 } 280
··· 173 version: (0, 0), 174 items: Vec::new(), 175 next: None, 176 + total: 0, 177 }); 178 }; 179 let Some(did_rkeys) = paths.get(&Source::new(collection, path)) else { ··· 181 version: (0, 0), 182 items: Vec::new(), 183 next: None, 184 + total: 0, 185 }); 186 }; 187 ··· 211 version: (total as u64, gone as u64), 212 items, 213 next, 214 + total: alive as u64, 215 }) 216 } 217 ··· 229 version: (0, 0), 230 items: Vec::new(), 231 next: None, 232 + total: 0, 233 }); 234 }; 235 let Some(did_rkeys) = paths.get(&Source::new(collection, path)) else { ··· 237 version: (0, 0), 238 items: Vec::new(), 239 next: None, 240 + total: 0, 241 }); 242 }; 243 ··· 280 version: (total as u64, gone as u64), 281 items, 282 next, 283 + total: alive as u64, 284 }) 285 } 286
+1
constellation/src/storage/mod.rs
··· 16 pub version: (u64, u64), // (collection length, deleted item count) // TODO: change to (total, active)? since dedups isn't "deleted" 17 pub items: Vec<T>, 18 pub next: Option<u64>, 19 } 20 21 #[derive(Debug, Deserialize, Serialize, PartialEq)]
··· 16 pub version: (u64, u64), // (collection length, deleted item count) // TODO: change to (total, active)? since dedups isn't "deleted" 17 pub items: Vec<T>, 18 pub next: Option<u64>, 19 + pub total: u64, 20 } 21 22 #[derive(Debug, Deserialize, Serialize, PartialEq)]
+4
constellation/src/storage/rocks_store.rs
··· 872 version: (0, 0), 873 items: Vec::new(), 874 next: None, 875 }); 876 }; 877 ··· 914 version: (total, gone), 915 items, 916 next, 917 }) 918 } 919 ··· 936 version: (0, 0), 937 items: Vec::new(), 938 next: None, 939 }); 940 }; 941 ··· 974 version: (total, gone), 975 items, 976 next, 977 }) 978 } 979
··· 872 version: (0, 0), 873 items: Vec::new(), 874 next: None, 875 + total: 0, 876 }); 877 }; 878 ··· 915 version: (total, gone), 916 items, 917 next, 918 + total: alive, 919 }) 920 } 921 ··· 938 version: (0, 0), 939 items: Vec::new(), 940 next: None, 941 + total: 0, 942 }); 943 }; 944 ··· 977 version: (total, gone), 978 items, 979 next, 980 + total: alive, 981 }) 982 } 983