4d01e13a84
* Revert "Revert structured logging 2 (#1240)"
This reverts commit 78ecaeffcb.
* Logging should not be bundled into core shared directory
* making sure observability stuff isnt bundled into frontend
Co-authored-by: Kristaps Fabians Geikins <fabis94@live.com>
30 lines
1009 B
TypeScript
30 lines
1009 B
TypeScript
import { CommandModule } from 'yargs'
|
|
import { initializeQueue } from '@/modules/notifications/services/queue'
|
|
import { sendActivityNotifications } from '@/modules/activitystream/services/summary'
|
|
import { publishNotification } from '@/modules/notifications/services/publication'
|
|
import { cliLogger } from '@/logging/logging'
|
|
|
|
const command: CommandModule = {
|
|
command: 'send [days]',
|
|
describe:
|
|
'Send activity summary notifications for the past days specified in the argument.',
|
|
builder(yargs) {
|
|
return yargs.positional('days', {
|
|
describe: 'Number of days to look for activities',
|
|
type: 'number',
|
|
default: 7
|
|
})
|
|
},
|
|
handler: async (argv) => {
|
|
initializeQueue()
|
|
const numberOfDays = argv.days as number
|
|
const end = new Date()
|
|
const start = new Date(end.getTime())
|
|
start.setDate(start.getDate() - numberOfDays)
|
|
await sendActivityNotifications(start, end, publishNotification)
|
|
cliLogger.info('Sent activity notifications')
|
|
}
|
|
}
|
|
|
|
export = command
|