2023-05-19 22:33:54 +00:00
|
|
|
|
|
|
|
// this is intended to be run everyday after midnight CT
|
2023-05-18 23:41:56 +00:00
|
|
|
function views ({ models }) {
|
|
|
|
return async function () {
|
2023-05-19 22:33:54 +00:00
|
|
|
console.log('refreshing stats views')
|
2023-05-18 23:41:56 +00:00
|
|
|
|
|
|
|
for (const view of ['reg_growth_days', 'spender_growth_days', 'item_growth_days',
|
2023-05-19 22:33:54 +00:00
|
|
|
'spending_growth_days', 'stackers_growth_days', 'stacking_growth_days',
|
|
|
|
'user_stats_days']) {
|
|
|
|
await models.$queryRaw(`REFRESH MATERIALIZED VIEW CONCURRENTLY ${view}`)
|
2023-05-18 23:41:56 +00:00
|
|
|
}
|
|
|
|
|
2023-05-19 22:33:54 +00:00
|
|
|
console.log('done refreshing stats views')
|
2023-05-18 23:41:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-23 14:21:04 +00:00
|
|
|
// this should be run regularly ... like, every 1-5 minutes
|
|
|
|
function rankViews ({ models }) {
|
|
|
|
return async function () {
|
|
|
|
console.log('refreshing rank views')
|
|
|
|
|
|
|
|
for (const view of ['sat_rank_wwm_view', 'sat_rank_tender_view']) {
|
|
|
|
await models.$queryRaw(`REFRESH MATERIALIZED VIEW CONCURRENTLY ${view}`)
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log('done refreshing rank views')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = { views, rankViews }
|