@@ -82,10 +82,10 @@ function getBusApiClient () {
82
82
*/
83
83
function getEsClient ( ) {
84
84
const esHost = config . get ( 'esConfig.HOST' )
85
- if ( ! esClients [ ' client' ] ) {
85
+ if ( ! esClients . client ) {
86
86
// AWS ES configuration is different from other providers
87
87
if ( / .* a m a z o n a w s .* / . test ( esHost ) ) {
88
- esClients [ ' client' ] = elasticsearch . Client ( {
88
+ esClients . client = elasticsearch . Client ( {
89
89
apiVersion : config . get ( 'esConfig.API_VERSION' ) ,
90
90
hosts : esHost ,
91
91
connectionClass : require ( 'http-aws-es' ) , // eslint-disable-line global-require
@@ -95,13 +95,13 @@ function getEsClient () {
95
95
}
96
96
} )
97
97
} else {
98
- esClients [ ' client' ] = new elasticsearch . Client ( {
98
+ esClients . client = new elasticsearch . Client ( {
99
99
apiVersion : config . get ( 'esConfig.API_VERSION' ) ,
100
100
hosts : esHost
101
101
} )
102
102
}
103
103
}
104
- return esClients [ ' client' ]
104
+ return esClients . client
105
105
}
106
106
107
107
/*
@@ -135,7 +135,7 @@ function prepESFilter (query, actResource) {
135
135
// Adding resource filter
136
136
boolQuery . push ( { match_phrase : { resource : actResource } } )
137
137
_ . map ( filters , ( value , key ) => {
138
- let pair = { }
138
+ const pair = { }
139
139
pair [ key ] = value
140
140
if ( key . indexOf ( '.' ) > - 1 ) {
141
141
const resKey = key . split ( '.' ) [ 0 ]
@@ -182,7 +182,7 @@ function prepESFilter (query, actResource) {
182
182
from : ( page - 1 ) * pageSize , // Es Index starts from 0
183
183
body : {
184
184
_source : {
185
- exclude : [ 'resource' ] // Remove the resource field which is not required
185
+ exclude : [ 'resource' ] // Remove the resource field which is not required
186
186
} ,
187
187
query : {
188
188
bool : {
@@ -196,14 +196,14 @@ function prepESFilter (query, actResource) {
196
196
197
197
if ( sortBy ) {
198
198
const obj = { }
199
- obj [ sortBy ] = { ' order' : orderBy || 'asc' }
199
+ obj [ sortBy ] = { order : orderBy || 'asc' }
200
200
esQuerySortArray . push ( obj )
201
201
}
202
202
203
203
// Internal sorting by 'updated' timestamp
204
204
if ( actResource !== 'reviewType' ) {
205
205
esQuerySortArray . push ( {
206
- updated : { ' order' : 'desc' }
206
+ updated : { order : 'desc' }
207
207
} )
208
208
}
209
209
@@ -229,10 +229,12 @@ function * fetchFromES (query, resource) {
229
229
// Extract data from hits
230
230
const rows = _ . map ( docs . hits . hits , single => single . _source )
231
231
232
- const response = { 'total' : docs . hits . total ,
233
- 'pageSize' : filter . size ,
234
- 'page' : query . page || 1 ,
235
- 'rows' : rows }
232
+ const response = {
233
+ total : docs . hits . total ,
234
+ pageSize : filter . size ,
235
+ page : query . page || 1 ,
236
+ rows : rows
237
+ }
236
238
return response
237
239
}
238
240
@@ -283,7 +285,7 @@ function setPaginationHeaders (req, res, data) {
283
285
'X-Per-Page' : data . pageSize ,
284
286
'X-Total' : data . total ,
285
287
'X-Total-Pages' : totalPages ,
286
- ' Link' : link
288
+ Link : link
287
289
} )
288
290
}
289
291
// Return the data after setting pagination headers
@@ -317,9 +319,9 @@ function * getSubmissionPhaseId (challengeId) {
317
319
}
318
320
if ( response ) {
319
321
const phases = _ . get ( response . body , 'result.content' , [ ] )
320
- const checkPoint = _ . filter ( phases , { phaseType : 'Checkpoint Submission' , phaseStatus : 'Open' } )
321
- const submissionPh = _ . filter ( phases , { phaseType : 'Submission' , phaseStatus : 'Open' } )
322
- const finalFixPh = _ . filter ( phases , { phaseType : 'Final Fix' , phaseStatus : 'Open' } )
322
+ const checkPoint = _ . filter ( phases , { phaseType : 'Checkpoint Submission' , phaseStatus : 'Open' } )
323
+ const submissionPh = _ . filter ( phases , { phaseType : 'Submission' , phaseStatus : 'Open' } )
324
+ const finalFixPh = _ . filter ( phases , { phaseType : 'Final Fix' , phaseStatus : 'Open' } )
323
325
if ( checkPoint . length !== 0 ) {
324
326
phaseId = checkPoint [ 0 ] . id
325
327
} else if ( submissionPh . length !== 0 ) {
@@ -367,7 +369,7 @@ function * checkCreateAccess (authUser, subEntity) {
367
369
throw new errors . HttpStatusError ( 403 , 'You are not allowed to submit when submission phase is not open' )
368
370
}
369
371
370
- const currPhase = _ . filter ( phases , { id : submissionPhaseId } )
372
+ const currPhase = _ . filter ( phases , { id : submissionPhaseId } )
371
373
372
374
if ( currPhase [ 0 ] . phaseType === 'Final Fix' ) {
373
375
if ( ! authUser . handle . equals ( winner [ 0 ] . handle ) ) {
@@ -442,33 +444,35 @@ function * checkGetAccess (authUser, submission) {
442
444
443
445
// User is either a Reviewer or Screener
444
446
if ( screener . length !== 0 || reviewer . length !== 0 ) {
445
- const screeningPhase = _ . filter ( phases , { phaseType : 'Screening' , ' phaseStatus' : 'Scheduled' } )
446
- const reviewPhase = _ . filter ( phases , { phaseType : 'Review' , ' phaseStatus' : 'Scheduled' } )
447
+ const screeningPhase = _ . filter ( phases , { phaseType : 'Screening' , phaseStatus : 'Scheduled' } )
448
+ const reviewPhase = _ . filter ( phases , { phaseType : 'Review' , phaseStatus : 'Scheduled' } )
447
449
448
450
// Neither Screening Nor Review is Opened / Closed
449
451
if ( screeningPhase . length !== 0 && reviewPhase . length !== 0 ) {
450
452
throw new errors . HttpStatusError ( 403 , 'You can access the submission only when Screening / Review is open' )
451
453
}
452
454
} else {
453
- const appealsResponse = _ . filter ( phases , { phaseType : 'Appeals Response' , ' phaseStatus' : 'Closed' } )
455
+ const appealsResponse = _ . filter ( phases , { phaseType : 'Appeals Response' , phaseStatus : 'Closed' } )
454
456
455
457
// Appeals Response is not closed yet
456
458
if ( appealsResponse . length === 0 ) {
457
459
throw new errors . HttpStatusError ( 403 , 'You cannot access other submissions before the end of Appeals Response phase' )
458
460
} else {
459
- const userSubmission = yield fetchFromES ( { challengeId : submission . challengeId ,
460
- memberId : authUser . userId } , camelize ( 'Submission' ) )
461
+ const userSubmission = yield fetchFromES ( {
462
+ challengeId : submission . challengeId ,
463
+ memberId : authUser . userId
464
+ } , camelize ( 'Submission' ) )
461
465
// User requesting submission haven't made any submission
462
466
if ( userSubmission . total === 0 ) {
463
- throw new errors . HttpStatusError ( 403 , ` You did not submit to the challenge!` )
467
+ throw new errors . HttpStatusError ( 403 , ' You did not submit to the challenge!' )
464
468
}
465
469
466
470
const reqSubmission = userSubmission . rows [ 0 ]
467
471
// Only if the requestor has passing score, allow to download other submissions
468
472
if ( reqSubmission . reviewSummation && reqSubmission . reviewSummation [ 0 ] . isPassing ) {
469
473
return true
470
474
} else {
471
- throw new errors . HttpStatusError ( 403 , ` You should have passed the review to access other member submissions!` )
475
+ throw new errors . HttpStatusError ( 403 , ' You should have passed the review to access other member submissions!' )
472
476
}
473
477
}
474
478
}
@@ -509,7 +513,7 @@ function * checkReviewGetAccess (authUser, submission) {
509
513
logger . info ( 'No access check for Marathon match' )
510
514
return true
511
515
} else {
512
- const appealsResponse = _ . filter ( phases , { phaseType : 'Appeals Response' , ' phaseStatus' : 'Closed' } )
516
+ const appealsResponse = _ . filter ( phases , { phaseType : 'Appeals Response' , phaseStatus : 'Closed' } )
513
517
514
518
// Appeals Response is not closed yet
515
519
if ( appealsResponse . length === 0 ) {
@@ -541,15 +545,15 @@ function * downloadFile (fileURL) {
541
545
*/
542
546
function * postToBusApi ( payload ) {
543
547
const busApiClient = getBusApiClient ( )
544
- const originalTopic = payload [ ' topic' ]
548
+ const originalTopic = payload . topic
545
549
546
550
yield busApiClient . postEvent ( payload )
547
551
548
552
// Post to aggregate topic
549
- payload [ ' topic' ] = config . get ( 'KAFKA_AGGREGATE_TOPIC' )
553
+ payload . topic = config . get ( 'KAFKA_AGGREGATE_TOPIC' )
550
554
551
555
// Store the original topic
552
- payload [ ' payload' ] [ ' originalTopic' ] = originalTopic
556
+ payload . payload . originalTopic = originalTopic
553
557
554
558
yield busApiClient . postEvent ( payload )
555
559
}
0 commit comments