Added parse summary to commit summary
This commit is contained in:
21
main.ts
21
main.ts
@@ -32,18 +32,24 @@ export interface VideoDescription {
|
||||
nags: string[]
|
||||
}
|
||||
|
||||
async function fetchPages(pages: string[], bot: Mwn): Promise<VideoDescription[]> {
|
||||
async function fetchPages(pages: string[], bot: Mwn): Promise<{ pages: VideoDescription[], errors: string[] }> {
|
||||
const d = await Promise.allSettled(pages.map(async (v) =>
|
||||
parseSummary(await new bot.Page(v).text(), v)
|
||||
))
|
||||
|
||||
const siteProblems: string[] = []
|
||||
|
||||
d.map((v, index) => ({ r: v, source: pages[index] }))
|
||||
.filter((v): v is { source: string, r: PromiseRejectedResult } => v.r.status === "rejected")
|
||||
.forEach(
|
||||
v => console.warn(`Error parsing ${v.source}: ${v.r.reason}`
|
||||
))
|
||||
v => {
|
||||
const e = `Error parsing ${v.source}: ${v.r.reason}`
|
||||
console.warn(e)
|
||||
siteProblems.push(e)
|
||||
}
|
||||
)
|
||||
|
||||
return d.filter(v => v.status === "fulfilled").map(v => v.value)
|
||||
return { pages: d.filter(v => v.status === "fulfilled").map(v => v.value), errors: siteProblems }
|
||||
|
||||
}
|
||||
|
||||
@@ -112,9 +118,12 @@ async function main() {
|
||||
await bot.login();
|
||||
await watchdog(bot, async (paths) => {
|
||||
const relevantFiles = await getWorkshopVideos(bot)
|
||||
const d = await fetchPages(relevantFiles, bot)
|
||||
const { pages: d, errors: parseErrors } = await fetchPages(relevantFiles, bot)
|
||||
const t = writeSections(bucketEvents(d))
|
||||
const response = await bot.save(title, "{{TOC|limit=3}}\n\n" + t, 'Triggered by changes to ' + paths.map(v => "[[" + v + "]]").join(", "));
|
||||
const trigger_summary = 'Triggered by changes to ' + paths.map(v => `[[${v}]]`).join(", ")
|
||||
const error_summary = parseErrors.join("\n")
|
||||
const summary = [trigger_summary, error_summary].filter(v => v !== undefined && v.length > 0).join("\n")
|
||||
const response = await bot.save(title, "{{TOC|limit=3}}\n\n" + t, summary);
|
||||
console.log(response)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user