File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,11 +9,21 @@ class SurveyController {
99 async updateSurveyGitHub ( req : Request , res : Response ) : Promise < void > {
1010 let survey : SurveyType ;
1111 try {
12- const _survey = await surveyService . updateSurvey ( {
13- ...req . body ,
12+ const sanitizedBody = {
13+ id : req . body . id ,
14+ userId : req . body . userId ,
15+ org : req . body . org ,
16+ repo : req . body . repo ,
17+ prNumber : req . body . prNumber ,
18+ usedCopilot : req . body . usedCopilot ,
19+ percentTimeSaved : req . body . percentTimeSaved ,
20+ reason : req . body . reason ,
21+ timeUsedFor : req . body . timeUsedFor ,
22+ kudos : req . body . kudos ,
1423 hits : 0 ,
1524 status : 'completed'
16- } ) ;
25+ } ;
26+ const _survey = await surveyService . updateSurvey ( sanitizedBody ) ;
1727 if ( ! _survey ) throw new Error ( 'Survey not found' ) ;
1828 survey = _survey ;
1929 res . status ( 201 ) . json ( survey ) ;
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ class SurveyService {
3333 throw new Error ( 'Invalid survey data provided' ) ;
3434 }
3535 const Survey = mongoose . model ( 'Survey' ) ;
36- const result = await Survey . updateOne ( { id : survey . id } , { $set : survey } ) ;
36+ const result = await Survey . updateOne ( { id : { $eq : survey . id } } , { $set : survey } ) ;
3737
3838 // Check if the update modified any document.
3939 if ( result . modifiedCount === 0 ) {
You can’t perform that action at this time.
0 commit comments