Constellation, Spacedust, Slingshot, UFOs: atproto crates and services for microcosm

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
···
.get_links(&query.target, &query.collection, &query.path, limit, until)
.map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)?;
-
let total = store
-
.get_count(&query.target, &query.collection, &query.path)
-
.map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)?;
-
let cursor = paged.next.map(|next| {
ApiCursor {
version: paged.version,
···
Ok(acceptable(
accept,
GetLinkItemsResponse {
-
total: total,
+
total: paged.total,
linking_records: paged.items,
cursor,
query: (*query).clone(),
···
.get_distinct_dids(&query.target, &query.collection, &query.path, limit, until)
.map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)?;
-
let distinct_dids_total = store
-
.get_distinct_did_count(&query.target, &query.collection, &query.path)
-
.map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)?;
-
-
-
let cursor = paged.next.map(|next| {
ApiCursor {
version: paged.version,
···
Ok(acceptable(
accept,
GetDidItemsResponse {
-
total: distinct_dids_total,
+
total: paged.total,
linking_dids: paged.items,
cursor,
query: (*query).clone(),
+6
constellation/src/storage/mem_store.rs
···
version: (0, 0),
items: Vec::new(),
next: None,
+
total: 0,
});
};
let Some(did_rkeys) = paths.get(&Source::new(collection, path)) else {
···
version: (0, 0),
items: Vec::new(),
next: None,
+
total: 0,
});
};
···
version: (total as u64, gone as u64),
items,
next,
+
total: alive as u64,
})
}
···
version: (0, 0),
items: Vec::new(),
next: None,
+
total: 0,
});
};
let Some(did_rkeys) = paths.get(&Source::new(collection, path)) else {
···
version: (0, 0),
items: Vec::new(),
next: None,
+
total: 0,
});
};
···
version: (total as u64, gone as u64),
items,
next,
+
total: alive as u64,
})
}
+1
constellation/src/storage/mod.rs
···
pub version: (u64, u64), // (collection length, deleted item count) // TODO: change to (total, active)? since dedups isn't "deleted"
pub items: Vec<T>,
pub next: Option<u64>,
+
pub total: u64,
}
#[derive(Debug, Deserialize, Serialize, PartialEq)]
+4
constellation/src/storage/rocks_store.rs
···
version: (0, 0),
items: Vec::new(),
next: None,
+
total: 0,
});
};
···
version: (total, gone),
items,
next,
+
total: alive,
})
}
···
version: (0, 0),
items: Vec::new(),
next: None,
+
total: 0,
});
};
···
version: (total, gone),
items,
next,
+
total: alive,
})
}