Skip to content

Commit 11fe5f1

Browse files
Merge pull request #488 from topcoder-platform/hotfix/send-survey-workperiods
[DEV] Weekly Survey Switch OFF
2 parents 0a03795 + 90c25ca commit 11fe5f1

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

app-constants.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ const PaymentProcessingSwitch = {
143143
OFF: 'OFF'
144144
}
145145

146+
const WeeklySurveySwitch = {
147+
ON: 'ON',
148+
OFF: 'OFF'
149+
}
150+
146151
const PaymentSchedulerStatus = {
147152
START_PROCESS: 'start-process',
148153
CREATE_CHALLENGE: 'create-challenge',
@@ -172,6 +177,7 @@ module.exports = {
172177
PaymentSchedulerStatus,
173178
PaymentProcessingSwitch,
174179
PaymentStatusRules,
180+
WeeklySurveySwitch,
175181
ActiveWorkPeriodPaymentStatuses,
176182
JobStatus,
177183
JobCandidateStatus

app.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const interviewService = require('./src/services/InterviewService')
1616
const { processScheduler } = require('./src/services/PaymentSchedulerService')
1717
const { sendSurveys } = require('./src/services/SurveyService')
1818
const emailNotificationService = require('./src/services/EmailNotificationService')
19+
const { WeeklySurveySwitch } = require('./app-constants')
1920

2021
// setup express app
2122
const app = express()
@@ -101,7 +102,9 @@ const server = app.listen(app.get('port'), () => {
101102
// schedule updateCompletedInterviews to run every hour
102103
schedule.scheduleJob('0 0 * * * *', interviewService.updateCompletedInterviews)
103104
// schedule sendSurveys
104-
schedule.scheduleJob(config.WEEKLY_SURVEY.CRON, sendSurveys)
105+
if (WeeklySurveySwitch.ON === config.WEEKLY_SURVEY.SWITCH) {
106+
schedule.scheduleJob(config.WEEKLY_SURVEY.CRON, sendSurveys)
107+
}
105108
// schedule payment processing
106109
schedule.scheduleJob(config.PAYMENT_PROCESSING.CRON, processScheduler)
107110

config/default.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ module.exports = {
184184
TOPCODER_SKILLS_CACHE_TIME: process.env.TOPCODER_SKILLS_CACHE_TIME || 60,
185185
// weekly survey scheduler config
186186
WEEKLY_SURVEY: {
187+
SWITCH: process.env.WEEKLY_SURVEY_SWITCH || 'OFF',
187188
CRON: process.env.WEEKLY_SURVEY_CRON || '0 1 * * 7',
188189
BASE_URL: process.env.WEEKLY_SURVEY_BASE_URL || 'https://api.surveymonkey.net/v3/surveys',
189190
JWT_TOKEN: process.env.WEEKLY_SURVEY_JWT_TOKEN || '',

src/bootstrap.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const Joi = require('joi')
33
const config = require('config')
44
const path = require('path')
55
const _ = require('lodash')
6-
const { Interviews, AggregatePaymentStatus, WorkPeriodPaymentStatus, WorkPeriodPaymentUpdateStatus, PaymentProcessingSwitch } = require('../app-constants')
6+
const { Interviews, AggregatePaymentStatus, WorkPeriodPaymentStatus, WorkPeriodPaymentUpdateStatus, PaymentProcessingSwitch, WeeklySurveySwitch } = require('../app-constants')
77
const logger = require('./common/logger')
88

99
const allowedInterviewStatuses = _.values(Interviews.Status)
@@ -51,8 +51,12 @@ buildServices(path.join(__dirname, 'services'))
5151
const paymentProcessingSwitchSchema = Joi.string().label('PAYMENT_PROCESSING_SWITCH').valid(
5252
...Object.values(PaymentProcessingSwitch)
5353
)
54+
const weeklySurveySwitchSchema = Joi.string().label('WEEKLY_SURVEY_SWITCH').valid(
55+
...Object.values(WeeklySurveySwitch)
56+
)
5457
try {
5558
Joi.attempt(config.PAYMENT_PROCESSING.SWITCH, paymentProcessingSwitchSchema)
59+
Joi.attempt(config.WEEKLY_SURVEY.SWITCH, weeklySurveySwitchSchema)
5660
} catch (err) {
5761
console.error(err.message)
5862
process.exit(1)

0 commit comments

Comments
 (0)