Compare commits

..

2 Commits

Author SHA1 Message Date
c97825b54f error 2024-12-16 08:43:26 +08:00
f8c408878e 打印表名 2024-12-16 08:38:39 +08:00
2 changed files with 13 additions and 6 deletions

15
main.js
View File

@@ -78,10 +78,17 @@ export default function () {
setInterval(async () => { setInterval(async () => {
存档('每10分钟自动存档...')
await update('web_images', 'day_rank', Object.entries(Object.fromEntries(截图.浏览数.))) try {
await update('web_article', 'day_rank', Object.entries(Object.fromEntries(文章.浏览数.))) 存档('每10分钟自动存档...')
await update_explorer('web_member_explorer', 'day_rank', Object.entries(Object.fromEntries(收藏.浏览数.))) await update('web_images', 'day_rank', Object.entries(Object.fromEntries(截图.浏览数.)))
await update('web_article', 'day_rank', Object.entries(Object.fromEntries(文章.浏览数.)))
await update_explorer('web_member_explorer', 'day_rank', Object.entries(Object.fromEntries(收藏.浏览数.)))
} catch(err) {
console.error(err)
}
}, 10000) }, 10000)

View File

@@ -48,7 +48,7 @@ export async function update_explorer(table, rank, views) {
console.log('统计当天时间段内排行榜到临时表') console.log('统计当天时间段内排行榜到临时表')
await conn.query("UPDATE temp_updates SET rank = fans_count * 35 + views_count * 25") await conn.query("UPDATE temp_updates SET rank = fans_count * 35 + views_count * 25")
console.log('更新数据从临时表转入生产库') console.log('更新数据从临时表转入生产库', table)
await conn.query(`UPDATE ${table} t LEFT JOIN temp_updates tu ON t.id = tu.id SET t.${rank} = IFNULL(tu.rank, 0)`) await conn.query(`UPDATE ${table} t LEFT JOIN temp_updates tu ON t.id = tu.id SET t.${rank} = IFNULL(tu.rank, 0)`)
await conn.end() await conn.end()
console.log('更新完成') console.log('更新完成')
@@ -109,7 +109,7 @@ export async function update(table, rank, views) {
console.log('统计当天时间段内排行榜到临时表') console.log('统计当天时间段内排行榜到临时表')
await conn.query("UPDATE temp_updates SET rank = collect_count * 35 + praise_count * 20 + comment_count * 20 + views_count * 25") await conn.query("UPDATE temp_updates SET rank = collect_count * 35 + praise_count * 20 + comment_count * 20 + views_count * 25")
console.log('更新数据从临时表转入生产库') console.log('更新数据从临时表转入生产库', table)
await conn.query(`UPDATE ${table} t LEFT JOIN temp_updates tu ON t.id = tu.id SET t.${rank} = IFNULL(tu.rank, 0)`) await conn.query(`UPDATE ${table} t LEFT JOIN temp_updates tu ON t.id = tu.id SET t.${rank} = IFNULL(tu.rank, 0)`)
await conn.end() await conn.end()
console.log('更新完成') console.log('更新完成')