fix: avoid spacetimedb filtered index panics
This commit is contained in:
@@ -696,15 +696,16 @@ fn list_match3d_works_tx(
|
|||||||
let rows = if input.published_only {
|
let rows = if input.published_only {
|
||||||
ctx.db
|
ctx.db
|
||||||
.match3d_work_profile()
|
.match3d_work_profile()
|
||||||
.by_match3d_work_publication_status()
|
.iter()
|
||||||
.filter(&MATCH3D_PUBLICATION_PUBLISHED.to_string())
|
// 中文注释:列表页优先稳定性,避免二级索引 filter 初始化异常直接打爆模块实例。
|
||||||
|
.filter(|row| row.publication_status == MATCH3D_PUBLICATION_PUBLISHED)
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
} else {
|
} else {
|
||||||
require_non_empty(&input.owner_user_id, "match3d owner_user_id")?;
|
require_non_empty(&input.owner_user_id, "match3d owner_user_id")?;
|
||||||
ctx.db
|
ctx.db
|
||||||
.match3d_work_profile()
|
.match3d_work_profile()
|
||||||
.by_match3d_work_owner_user_id()
|
.iter()
|
||||||
.filter(&input.owner_user_id)
|
.filter(|row| row.owner_user_id == input.owner_user_id)
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
};
|
};
|
||||||
let mut items = rows
|
let mut items = rows
|
||||||
|
|||||||
@@ -108,8 +108,9 @@ fn update_work_visibility_tx(
|
|||||||
fn list_puzzle_work_visibility(ctx: &ReducerContext) -> Vec<AdminWorkVisibilitySnapshot> {
|
fn list_puzzle_work_visibility(ctx: &ReducerContext) -> Vec<AdminWorkVisibilitySnapshot> {
|
||||||
ctx.db
|
ctx.db
|
||||||
.puzzle_work_profile()
|
.puzzle_work_profile()
|
||||||
.by_puzzle_work_publication_status()
|
.iter()
|
||||||
.filter(PuzzlePublicationStatus::Published)
|
// 中文注释:后台页签是低频管理入口,列表优先保证稳定性,避免二级索引 filter 初始化异常打爆 wasm 实例。
|
||||||
|
.filter(|row| row.publication_status == PuzzlePublicationStatus::Published)
|
||||||
.map(|row| puzzle_work_visibility_snapshot(&row))
|
.map(|row| puzzle_work_visibility_snapshot(&row))
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
@@ -165,8 +166,9 @@ fn puzzle_work_visibility_snapshot(row: &PuzzleWorkProfileRow) -> AdminWorkVisib
|
|||||||
fn list_custom_world_work_visibility(ctx: &ReducerContext) -> Vec<AdminWorkVisibilitySnapshot> {
|
fn list_custom_world_work_visibility(ctx: &ReducerContext) -> Vec<AdminWorkVisibilitySnapshot> {
|
||||||
ctx.db
|
ctx.db
|
||||||
.custom_world_profile()
|
.custom_world_profile()
|
||||||
.by_custom_world_profile_publication_status()
|
.iter()
|
||||||
.filter(CustomWorldPublicationStatus::Published)
|
// 中文注释:后台必须能读到所有已发布源表记录,包括已隐藏作品,因此不复用公开 view。
|
||||||
|
.filter(|row| row.publication_status == CustomWorldPublicationStatus::Published)
|
||||||
.filter(|row| row.deleted_at.is_none())
|
.filter(|row| row.deleted_at.is_none())
|
||||||
.map(|row| custom_world_work_visibility_snapshot(&row))
|
.map(|row| custom_world_work_visibility_snapshot(&row))
|
||||||
.collect()
|
.collect()
|
||||||
@@ -240,8 +242,8 @@ fn custom_world_work_visibility_snapshot(row: &CustomWorldProfile) -> AdminWorkV
|
|||||||
fn list_jump_hop_work_visibility(ctx: &ReducerContext) -> Vec<AdminWorkVisibilitySnapshot> {
|
fn list_jump_hop_work_visibility(ctx: &ReducerContext) -> Vec<AdminWorkVisibilitySnapshot> {
|
||||||
ctx.db
|
ctx.db
|
||||||
.jump_hop_work_profile()
|
.jump_hop_work_profile()
|
||||||
.by_jump_hop_work_publication_status()
|
.iter()
|
||||||
.filter(JUMP_HOP_PUBLICATION_PUBLISHED)
|
.filter(|row| row.publication_status == JUMP_HOP_PUBLICATION_PUBLISHED)
|
||||||
.map(|row| jump_hop_work_visibility_snapshot(&row))
|
.map(|row| jump_hop_work_visibility_snapshot(&row))
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
@@ -293,8 +295,8 @@ fn jump_hop_work_visibility_snapshot(row: &JumpHopWorkProfileRow) -> AdminWorkVi
|
|||||||
fn list_wooden_fish_work_visibility(ctx: &ReducerContext) -> Vec<AdminWorkVisibilitySnapshot> {
|
fn list_wooden_fish_work_visibility(ctx: &ReducerContext) -> Vec<AdminWorkVisibilitySnapshot> {
|
||||||
ctx.db
|
ctx.db
|
||||||
.wooden_fish_work_profile()
|
.wooden_fish_work_profile()
|
||||||
.by_wooden_fish_work_publication_status()
|
.iter()
|
||||||
.filter(WOODEN_FISH_PUBLICATION_PUBLISHED)
|
.filter(|row| row.publication_status == WOODEN_FISH_PUBLICATION_PUBLISHED)
|
||||||
.map(|row| wooden_fish_work_visibility_snapshot(&row))
|
.map(|row| wooden_fish_work_visibility_snapshot(&row))
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
@@ -348,8 +350,8 @@ fn wooden_fish_work_visibility_snapshot(
|
|||||||
fn list_match3d_work_visibility(ctx: &ReducerContext) -> Vec<AdminWorkVisibilitySnapshot> {
|
fn list_match3d_work_visibility(ctx: &ReducerContext) -> Vec<AdminWorkVisibilitySnapshot> {
|
||||||
ctx.db
|
ctx.db
|
||||||
.match3d_work_profile()
|
.match3d_work_profile()
|
||||||
.by_match3d_work_publication_status()
|
.iter()
|
||||||
.filter(MATCH3D_PUBLICATION_PUBLISHED)
|
.filter(|row| row.publication_status == MATCH3D_PUBLICATION_PUBLISHED)
|
||||||
.map(|row| match3d_work_visibility_snapshot(&row))
|
.map(|row| match3d_work_visibility_snapshot(&row))
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
@@ -401,8 +403,8 @@ fn match3d_work_visibility_snapshot(row: &Match3DWorkProfileRow) -> AdminWorkVis
|
|||||||
fn list_square_hole_work_visibility(ctx: &ReducerContext) -> Vec<AdminWorkVisibilitySnapshot> {
|
fn list_square_hole_work_visibility(ctx: &ReducerContext) -> Vec<AdminWorkVisibilitySnapshot> {
|
||||||
ctx.db
|
ctx.db
|
||||||
.square_hole_work_profile()
|
.square_hole_work_profile()
|
||||||
.by_square_hole_work_publication_status()
|
.iter()
|
||||||
.filter(SQUARE_HOLE_PUBLICATION_PUBLISHED)
|
.filter(|row| row.publication_status == SQUARE_HOLE_PUBLICATION_PUBLISHED)
|
||||||
.map(|row| square_hole_work_visibility_snapshot(&row))
|
.map(|row| square_hole_work_visibility_snapshot(&row))
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
@@ -456,8 +458,8 @@ fn square_hole_work_visibility_snapshot(
|
|||||||
fn list_visual_novel_work_visibility(ctx: &ReducerContext) -> Vec<AdminWorkVisibilitySnapshot> {
|
fn list_visual_novel_work_visibility(ctx: &ReducerContext) -> Vec<AdminWorkVisibilitySnapshot> {
|
||||||
ctx.db
|
ctx.db
|
||||||
.visual_novel_work_profile()
|
.visual_novel_work_profile()
|
||||||
.by_visual_novel_work_publication_status()
|
.iter()
|
||||||
.filter(VISUAL_NOVEL_PUBLICATION_PUBLISHED)
|
.filter(|row| row.publication_status == VISUAL_NOVEL_PUBLICATION_PUBLISHED)
|
||||||
.map(|row| visual_novel_work_visibility_snapshot(&row))
|
.map(|row| visual_novel_work_visibility_snapshot(&row))
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
@@ -511,8 +513,8 @@ fn visual_novel_work_visibility_snapshot(
|
|||||||
fn list_big_fish_work_visibility(ctx: &ReducerContext) -> Vec<AdminWorkVisibilitySnapshot> {
|
fn list_big_fish_work_visibility(ctx: &ReducerContext) -> Vec<AdminWorkVisibilitySnapshot> {
|
||||||
ctx.db
|
ctx.db
|
||||||
.big_fish_creation_session()
|
.big_fish_creation_session()
|
||||||
.by_big_fish_session_stage()
|
.iter()
|
||||||
.filter(BigFishCreationStage::Published)
|
.filter(|row| row.stage == BigFishCreationStage::Published)
|
||||||
.map(|row| big_fish_work_visibility_snapshot(&row))
|
.map(|row| big_fish_work_visibility_snapshot(&row))
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user