Skip to content

Commit

Permalink
chore: retry failed items
Browse files Browse the repository at this point in the history
  • Loading branch information
outloudvi committed Sep 2, 2023
1 parent dcd4953 commit 06d9ffa
Show file tree
Hide file tree
Showing 2 changed files with 193 additions and 37 deletions.
78 changes: 41 additions & 37 deletions observer/full.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as adv from '../dist/index.js'
import { getAllStoriesOcto, putFile, getFile, writeCommu } from './utils.mjs'
import retryItems from './retry.json' assert { type: 'json' }

const ADV_METAFILE_PATH = 'processed/adv/meta.json'

Expand All @@ -19,45 +20,48 @@ const ADV_METAFILE_PATH = 'processed/adv/meta.json'
console.log('Forced re-generating all advs.')
}
await Promise.all(
stories.map(({ name, objectName, generation, md5, uploadVersionId }) => {
const savePath = `processed/adv/${name}.json`
return (async () => {
if (!forcedRegenerate) {
const [advScriptVersion, sourceMd5] = metadataTable[name] ?? []
if (advScriptVersion === version && sourceMd5 === md5) {
console.log(`Skipped: ${savePath}`)
return
}
if (advScriptVersion === undefined) {
console.log(`Creating: ${savePath}`)
} else {
console.log(`Updating: ${savePath}`)
stories
.filter((x) => retryItems.includes(x.name))
.map(({ name, objectName, generation, md5, uploadVersionId }) => {
const savePath = `processed/adv/${name}.json`

return (async () => {
if (!forcedRegenerate) {
const [advScriptVersion, sourceMd5] = metadataTable[name] ?? []
if (advScriptVersion === version && sourceMd5 === md5) {
console.log(`Skipped: ${savePath}`)
return
}
if (advScriptVersion === undefined) {
console.log(`Creating: ${savePath}`)
} else {
console.log(`Updating: ${savePath}`)
}
}
}
const storyText = await fetch(
`https://${process.env.UPSTREAM_BASE_DOMAIN}/solis-${uploadVersionId}-resources/${objectName}?generation=${generation}&alt=media`
).then((x) => x.text())
const parsed = adv.read(storyText, true)
await Promise.all([
// putFile(savePath, JSON.stringify({ v: version, l: parsed, m: md5 })),
writeCommu(
name.replace(/^adv_/, '').replace(/\.txt$/, ''),
parsed.find((x) => x._t === 'Title')?.title ?? 'Untitled',
parsed
.filter((x) => x._t === 'Message')
.map(({ text, name }) => ({
text: text.replaceAll('{user}', 'マネジャー'),
name,
}))
),
])
metadataTable[name] = [version, md5]
console.log(`Finished: ${savePath}`)
})().catch((e) => {
console.warn(`Error: ${savePath} [${e}]`)
err++
const storyText = await fetch(
`https://${process.env.UPSTREAM_BASE_DOMAIN}/solis-${uploadVersionId}-resources/${objectName}?generation=${generation}&alt=media`
).then((x) => x.text())
const parsed = adv.read(storyText, true)
await Promise.all([
// putFile(savePath, JSON.stringify({ v: version, l: parsed, m: md5 })),
writeCommu(
name.replace(/^adv_/, '').replace(/\.txt$/, ''),
parsed.find((x) => x._t === 'Title')?.title ?? 'Untitled',
parsed
.filter((x) => x._t === 'Message')
.map(({ text, name }) => ({
text: text.replaceAll('{user}', 'マネジャー'),
name,
}))
),
])
metadataTable[name] = [version, md5]
console.log(`Finished: ${savePath}`)
})().catch((e) => {
console.warn(`Error: ${savePath} [${e.message}]`)
err++
})
})
})
)
await putFile(ADV_METAFILE_PATH, JSON.stringify(metadataTable))
if (err > 0) {
Expand Down
152 changes: 152 additions & 0 deletions observer/retry.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
[
"adv_card_yu_02_01.txt",
"adv_card_smr_02_01_short.txt",
"adv_card_hrk_02_01_short.txt",
"adv_card_rui_02_01_short.txt",
"adv_card_ngs_02_01_short.txt",
"adv_card_ngs_02_02.txt",
"adv_hbd_01_mei.txt",
"adv_card_ktn_02_01_short.txt",
"adv_card_suz_02_01_short.txt",
"adv_card_mei_02_01_short.txt",
"adv_hbd_01_ngs.txt",
"adv_card_ai_02_01_short.txt",
"adv_gacha_2021_0731.txt",
"adv_card_ski_02_01_short.txt",
"adv_event_cmn_kkr_01_01.txt",
"adv_event_cmn_skr_01_01.txt",
"adv_card_ski_02_02.txt",
"adv_event_cmn_rei_01_01.txt",
"adv_card_aoi_02_01_short.txt",
"adv_card_ski_02_03.txt",
"adv_card_mna_01_01_short.txt",
"adv_gacha_2021_0811.txt",
"adv_event_cmn_suz_01_01.txt",
"adv_card_rei_02_01_short.txt",
"adv_campaign_2021_0813.txt",
"adv_hbd_01_rio.txt",
"adv_event_cmn_ski_01_01.txt",
"adv_event_cmn_ngs_01_01.txt",
"adv_event_cmn_ktn_01_01.txt",
"adv_card_kkr_02_01_short.txt",
"adv_gacha_2021_0821.txt",
"adv_event_cmn_mei_01_01.txt",
"adv_gacha_2021_0831.txt",
"adv_hbd_01_suz.txt",
"adv_event_2109_02_aoi.txt",
"adv_event_2109_02_rio.txt",
"adv_event_2109_02_ai.txt",
"adv_card_skr_02_01_short.txt",
"adv_hbd_01_ski.txt",
"adv_hbd_01_szk.txt",
"adv_gacha_2021_0911.txt",
"adv_card_rio_02_01_short.txt",
"adv_card_rio_02_02.txt",
"adv_gacha_2021_0915.txt",
"adv_card_chs_02_01_short.txt",
"adv_gacha_2021_0921.txt",
"adv_campaign_2021_0928.txt",
"adv_card_rui_03_01_short.txt",
"adv_gacha_2021_0928.txt",
"adv_hbd_01_chs.txt",
"adv_gacha_2021_1012.txt",
"adv_gacha_2021_1004.txt",
"adv_event_cmn_hrk_01_01.txt",
"adv_event_cmn_chs_01_01.txt",
"adv_card_hrk_03_01_short.txt",
"adv_event_2111_02_suz.txt",
"adv_card_suz_03_01_short.txt",
"adv_card_ngs_03_01_short.txt",
"adv_card_mei_03_01_short.txt",
"adv_event_2111_02_rei.txt",
"adv_event_2111_02_mei.txt",
"adv_hbd_01_rui.txt",
"adv_card_szk_02_01_short.txt",
"adv_gacha_2021_1020.txt",
"adv_event_cmn_rui_01_01.txt",
"adv_gacha_2021_1031.txt",
"adv_event_cmn_szk_01_01.txt",
"adv_event_cmn_rio_01_01.txt",
"adv_event_cmn_aoi_01_01.txt",
"adv_event_cmn_yu_01_01.txt",
"adv_event_cmn_smr_01_01.txt",
"adv_event_cmn_ai_01_01.txt",
"adv_gacha_2021_1104.txt",
"adv_card_smr_03_01_short.txt",
"adv_gacha_2021_1112.txt",
"adv_hbd_01_kkr.txt",
"adv_hbd_02_hrk.txt",
"adv_hbd_02_ktn.txt",
"adv_card_yu_03_01_short.txt",
"adv_gacha_2021_1122.txt",
"adv_card_rei_03_01_short.txt",
"adv_gacha_2021_1130.txt",
"adv_card_ktn_03_01_short.txt",
"adv_card_rio_03_01_short.txt",
"adv_card_ski_03_01_short.txt",
"adv_card_skr_03_01_short.txt",
"adv_gacha_2021_1206.txt",
"adv_event_2201_02_01.txt",
"adv_gacha_2021_1217.txt",
"adv_gacha_2021_1216.txt",
"adv_card_ai_03_01_short.txt",
"adv_gacha_2021_1228.txt",
"adv_campaign_2021_1224.txt",
"adv_card_kkr_03_01_short.txt",
"adv_gacha_2021_1225.txt",
"adv_gacha_2022_0103.txt",
"adv_gacha_2021_1224.txt",
"adv_gacha_2022_0120.txt",
"adv_card_chs_03_01_short.txt",
"adv_card_aoi_03_01_short.txt",
"adv_gacha_2022_0112.txt",
"adv_hbd_02_yu.txt",
"adv_hbd_02_ai.txt",
"adv_hbd_02_rei.txt",
"adv_gacha_2022_0131.txt",
"adv_gacha_2022_0207.txt",
"adv_card_smr_04_01_short.txt",
"adv_gacha_2022_0212.txt",
"adv_card_szk_03_01_short.txt",
"adv_card_ngs_04_01_short.txt",
"adv_gacha_2022_0221.txt",
"adv_gacha_2022_0228.txt",
"adv_card_mna_02_01_short.txt",
"adv_card_mei_04_01_short.txt",
"adv_gacha_2022_0311.txt",
"adv_card_hrk_04_01_short.txt",
"adv_hbd_02_skr.txt",
"adv_gacha_2022_0314.txt",
"adv_gacha_2022_0321.txt",
"adv_card_rio_04_01_short.txt",
"adv_gacha_2022_0324.txt",
"adv_card_rei_04_01_short.txt",
"adv_campaign_2022_0401-02.txt",
"adv_campaign_2022_0401-01.txt",
"adv_card_suz_04_01_short.txt",
"adv_gacha_2022_0328.txt",
"adv_gacha_2022_0404.txt",
"adv_campaign_2022_0401-03.txt",
"adv_card_ski_04_01_short.txt",
"adv_gacha_2022_0423.txt",
"adv_card_chs_04_01_short.txt",
"adv_gacha_2022_0420.txt",
"adv_gacha_2022_0428.txt",
"adv_card_ai_04_01_short.txt",
"adv_card_rui_04_01_short.txt",
"adv_gacha_2022_0511.txt",
"adv_hbd_02_smr.txt",
"adv_card_hrk_05_01_short.txt",
"adv_card_skr_04_01_short.txt",
"adv_gacha_2022_0520.txt",
"adv_card_ktn_04_01_short.txt",
"adv_card_yu_04_01_short.txt",
"adv_hbd_02_aoi.txt",
"adv_gacha_2022_0606.txt",
"adv_gacha_2022_0526.txt",
"adv_card_ngs_05_01_short.txt",
"adv_card_kor_01_01_short.txt",
"adv_gacha_2022_0614.txt",
"adv_card_mhk_01_01_short.txt",
"adv_hbd_02_mei.txt"
]

0 comments on commit 06d9ffa

Please sign in to comment.