Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/loaders/cronJob.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ElectionService } from '@/services/ElectionService'
import chalk from 'chalk'
import Cron from 'node-cron'
import { Connection } from 'typeorm'
import { logger } from './logger'
Expand All @@ -8,8 +9,6 @@ import { logger } from './logger'
*/
const cronWorkerLoader = (database: Connection) => {
Cron.schedule('* * * * *', async () => {
logger.info('🧹 | check date and status for elections')

let cronUpdatedCount = 0
const electionService = new ElectionService(database)

Expand All @@ -20,7 +19,10 @@ const cronWorkerLoader = (database: Connection) => {
cronUpdatedCount += electionsClosed.affected!

if (cronUpdatedCount > 0) {
logger.info(`--- updated status for ${cronUpdatedCount} elections`)
logger.info('🧹 | checked date and status for elections')
logger.info(`--- updated status for ${chalk.yellow(cronUpdatedCount)} elections`)
logger.info(`--- ${chalk.green(electionsStarted.affected)} elections were started`)
logger.info(`--- ${chalk.red(electionsClosed.affected)} elections were closed`)
}
cronUpdatedCount = 0
})
Expand Down