v0.16.0: 后台体验升级——i18n(默认英文)/浅深主题/字号放大/关站维护页/个人设置(头像·语言·主题·密码·MCP Token)/权限管理(菜单+MCP·API)/询盘抽屉翻倍+PHP序列化数据清洗(22.7万行)+去裸JSON
This commit is contained in:
@@ -44,18 +44,18 @@ let added = 0, removed = 0;
|
||||
for (const [wpId, cats] of liveCats) {
|
||||
const cid = contentByLegacy.get(wpId);
|
||||
if (!cid) continue;
|
||||
const localRows = await sql`select category_id from content_terms where content_id = ${cid}`;
|
||||
const localSet = new Set(localRows.map((r: any) => r.category_id as number));
|
||||
const localRows = await sql`select category_id from content_terms where content_id = ${Number(cid)}`;
|
||||
const localSet = new Set<number>(localRows.map((r: any) => r.category_id as number));
|
||||
const liveSet = new Set(cats.map((t) => catByLegacy.get(t)).filter((x): x is number => x != null));
|
||||
for (const add of liveSet) {
|
||||
if (localSet.has(add)) continue;
|
||||
added++;
|
||||
if (!dry) await sql`insert into content_terms (content_id, category_id) values (${cid}, ${add}) on conflict do nothing`;
|
||||
if (!dry) await sql`insert into content_terms (content_id, category_id) values (${cid}, ${Number(add)}) on conflict do nothing`;
|
||||
}
|
||||
for (const rm of localSet) {
|
||||
if (liveSet.has(rm)) continue;
|
||||
removed++;
|
||||
if (!dry) await sql`delete from content_terms where content_id = ${cid} and category_id = ${rm}`;
|
||||
if (!dry) await sql`delete from content_terms where content_id = ${cid} and category_id = ${Number(rm)}`;
|
||||
}
|
||||
}
|
||||
console.log(`分类成员同步: 新增 ${added} 移除 ${removed}${dry ? "(dry 未写库)" : ""}`);
|
||||
|
||||
Reference in New Issue
Block a user