APIs for links and references in the ATmosphere

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

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