-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
syncDBスクリプトを追加し、全ページを処理する機能を実装しました。また、package.jsonから不要なスクリプトを削除しました。 (#…
…540)
- Loading branch information
Showing
2 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { processPageHtml } from "~/routes/$locale+/user.$handle+/page+/$slug+/edit/utils/processHtmlContent"; | ||
import { prisma } from "~/utils/prisma"; | ||
|
||
// 全ページに対して処理を実行するメイン関数 | ||
async function main(): Promise<void> { | ||
// 1. DB から全ページを取得 | ||
const pages = await prisma.page.findMany({ | ||
include: { | ||
pageSegments: { where: { number: 0 } }, | ||
}, | ||
}); | ||
|
||
// 2. 取得したページを順番に処理 | ||
for (const page of pages) { | ||
if (!page.pageSegments[0]) { | ||
console.log( | ||
`pageSegments[0] が存在しません。userId=${page.userId}, sourceLocale=${page.sourceLocale}, status=${page.status}`, | ||
); | ||
// スキップする場合は continue を使用 | ||
continue; | ||
} | ||
// 例: pageSlug プロパティ名が異なる場合は適宜修正 | ||
await processPageHtml( | ||
page.pageSegments[0].text, | ||
page.content, | ||
page.slug, | ||
page.userId, | ||
page.sourceLocale, | ||
page.status, | ||
); | ||
} | ||
|
||
console.log("全ページの処理が完了しました。"); | ||
} | ||
|
||
// スクリプト実行 | ||
main().catch((error) => { | ||
console.error("ページ処理中にエラーが発生しました:", error); | ||
process.exit(1); | ||
}); |