Skip to content

[DEV] Weekly Survey Switch OFF #488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions app-constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ const PaymentProcessingSwitch = {
OFF: 'OFF'
}

const WeeklySurveySwitch = {
ON: 'ON',
OFF: 'OFF'
}

const PaymentSchedulerStatus = {
START_PROCESS: 'start-process',
CREATE_CHALLENGE: 'create-challenge',
Expand Down Expand Up @@ -172,6 +177,7 @@ module.exports = {
PaymentSchedulerStatus,
PaymentProcessingSwitch,
PaymentStatusRules,
WeeklySurveySwitch,
ActiveWorkPeriodPaymentStatuses,
JobStatus,
JobCandidateStatus
Expand Down
5 changes: 4 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const interviewService = require('./src/services/InterviewService')
const { processScheduler } = require('./src/services/PaymentSchedulerService')
const { sendSurveys } = require('./src/services/SurveyService')
const emailNotificationService = require('./src/services/EmailNotificationService')
const { WeeklySurveySwitch } = require('./app-constants')

// setup express app
const app = express()
Expand Down Expand Up @@ -101,7 +102,9 @@ const server = app.listen(app.get('port'), () => {
// schedule updateCompletedInterviews to run every hour
schedule.scheduleJob('0 0 * * * *', interviewService.updateCompletedInterviews)
// schedule sendSurveys
schedule.scheduleJob(config.WEEKLY_SURVEY.CRON, sendSurveys)
if (WeeklySurveySwitch.ON === config.WEEKLY_SURVEY.SWITCH) {
schedule.scheduleJob(config.WEEKLY_SURVEY.CRON, sendSurveys)
}
// schedule payment processing
schedule.scheduleJob(config.PAYMENT_PROCESSING.CRON, processScheduler)

Expand Down
1 change: 1 addition & 0 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ module.exports = {
TOPCODER_SKILLS_CACHE_TIME: process.env.TOPCODER_SKILLS_CACHE_TIME || 60,
// weekly survey scheduler config
WEEKLY_SURVEY: {
SWITCH: process.env.WEEKLY_SURVEY_SWITCH || 'OFF',
CRON: process.env.WEEKLY_SURVEY_CRON || '0 1 * * 7',
BASE_URL: process.env.WEEKLY_SURVEY_BASE_URL || 'https://api.surveymonkey.net/v3/surveys',
JWT_TOKEN: process.env.WEEKLY_SURVEY_JWT_TOKEN || '',
Expand Down
6 changes: 5 additions & 1 deletion src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const Joi = require('joi')
const config = require('config')
const path = require('path')
const _ = require('lodash')
const { Interviews, AggregatePaymentStatus, WorkPeriodPaymentStatus, WorkPeriodPaymentUpdateStatus, PaymentProcessingSwitch } = require('../app-constants')
const { Interviews, AggregatePaymentStatus, WorkPeriodPaymentStatus, WorkPeriodPaymentUpdateStatus, PaymentProcessingSwitch, WeeklySurveySwitch } = require('../app-constants')
const logger = require('./common/logger')

const allowedInterviewStatuses = _.values(Interviews.Status)
Expand Down Expand Up @@ -51,8 +51,12 @@ buildServices(path.join(__dirname, 'services'))
const paymentProcessingSwitchSchema = Joi.string().label('PAYMENT_PROCESSING_SWITCH').valid(
...Object.values(PaymentProcessingSwitch)
)
const weeklySurveySwitchSchema = Joi.string().label('WEEKLY_SURVEY_SWITCH').valid(
...Object.values(WeeklySurveySwitch)
)
try {
Joi.attempt(config.PAYMENT_PROCESSING.SWITCH, paymentProcessingSwitchSchema)
Joi.attempt(config.WEEKLY_SURVEY.SWITCH, weeklySurveySwitchSchema)
} catch (err) {
console.error(err.message)
process.exit(1)
Expand Down