feat(organize): 整理记录按整理方式、媒体库目录、分类筛选,统计给出维度计数
列表与统计新增 action / libraryRootId / category 参数(分类取冻结计划的 classification.category); 统计 facets 按其余条件给出三个维度的可选值与条数(只列非零项),供整理记录的维度按钮列选项。 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
This commit is contained in:
1 parent
ad3bf8926b
commit
eb294b0ffa
3 files changed
+86
-1
No files matched your search
@@ -107,7 +107,7 @@ describe.skipIf(skip)("整理记录筛选与统计", () => {
|
||||
it("统计与列表同口径,不受状态筛选影响", async () => {
|
||||
const all = await h.api("GET", "/organization-records/stats");
|
||||
expect(all.status).toBe(200);
|
||||
expect(all.body.data).toEqual({
|
||||
expect(all.body.data).toMatchObject({
|
||||
total: 4,
|
||||
succeeded: 2,
|
||||
partial: 0,
|
||||
@@ -120,6 +120,44 @@ describe.skipIf(skip)("整理记录筛选与统计", () => {
|
||||
expect(movies.body.data).toMatchObject({ total: 1, succeeded: 1, failed: 0 });
|
||||
});
|
||||
|
||||
it("整理方式、媒体库目录、分类:列表筛选与维度计数", async () => {
|
||||
const root = await h.db
|
||||
.insertInto("library_root")
|
||||
.values({ name: "电影库", local_path: "/lib/movies" })
|
||||
.returning("id")
|
||||
.executeTakeFirstOrThrow();
|
||||
await h.db
|
||||
.updateTable("organization_record")
|
||||
.set({ target_library_root_id: root.id })
|
||||
.where("id", "=", ids.film!)
|
||||
.execute();
|
||||
try {
|
||||
expect(idsOf(await list("organizeOnly=true&action=copy"))).toEqual([ids.film, ids.unknown].sort());
|
||||
expect(idsOf(await list("action=move"))).toEqual([ids.show]);
|
||||
expect(idsOf(await list(`libraryRootId=${root.id}`))).toEqual([ids.film]);
|
||||
expect(idsOf(await list(`category=${encodeURIComponent("欧美电影")}`))).toEqual([ids.film]);
|
||||
expect(await list(`category=${encodeURIComponent("纪录片")}`)).toEqual([]);
|
||||
// 维度计数:按其余条件计,不含本维度自己的条件;只列非零项
|
||||
const s = await h.api("GET", "/organization-records/stats?organizeOnly=true&action=copy");
|
||||
expect(s.body.data.total).toBe(2);
|
||||
expect(s.body.data.facets.action).toEqual([
|
||||
{ value: "copy", n: 2 },
|
||||
{ value: "move", n: 1 },
|
||||
]);
|
||||
expect(s.body.data.facets.libraryRootId).toEqual([{ value: root.id, n: 1 }]);
|
||||
expect(s.body.data.facets.category).toEqual([{ value: "欧美电影", n: 1 }]);
|
||||
const bad = await h.api("GET", "/organization-records?action=rename");
|
||||
expect(bad.status).toBe(422);
|
||||
} finally {
|
||||
await h.db
|
||||
.updateTable("organization_record")
|
||||
.set({ target_library_root_id: null })
|
||||
.where("id", "=", ids.film!)
|
||||
.execute();
|
||||
await h.db.deleteFrom("library_root").where("id", "=", root.id).execute();
|
||||
}
|
||||
});
|
||||
|
||||
it("历史分页和统计排除排队与运行记录,显式active仍可查询", async () => {
|
||||
const inserted = await h.db
|
||||
.insertInto("organization_record")
|
||||
|
||||
Reference in new issue
Block a user