perf: cache public gallery views
This commit is contained in:
@@ -228,10 +228,22 @@ impl SpacetimeClient {
|
||||
pub async fn list_square_hole_gallery(
|
||||
&self,
|
||||
) -> Result<Vec<SquareHoleWorkProfileRecord>, SpacetimeClientError> {
|
||||
self.list_square_hole_works_with_input(SquareHoleWorksListInput {
|
||||
// 中文注释:公开广场只依赖 published_only,owner_user_id 用固定值通过输入校验。
|
||||
owner_user_id: "square-hole-public-gallery".to_string(),
|
||||
published_only: true,
|
||||
self.read_after_connect(move |connection| {
|
||||
let mut items = connection
|
||||
.db()
|
||||
.square_hole_gallery_view()
|
||||
.iter()
|
||||
.collect::<Vec<_>>();
|
||||
items.sort_by(|left, right| {
|
||||
right
|
||||
.updated_at_micros
|
||||
.cmp(&left.updated_at_micros)
|
||||
.then_with(|| left.profile_id.cmp(&right.profile_id))
|
||||
});
|
||||
Ok(items
|
||||
.into_iter()
|
||||
.map(map_square_hole_gallery_view_row)
|
||||
.collect())
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user