File tree Expand file tree Collapse file tree 2 files changed +42
-2
lines changed Expand file tree Collapse file tree 2 files changed +42
-2
lines changed Original file line number Diff line number Diff line change @@ -172,6 +172,21 @@ export class FlowController {
172172 return 'Success' ;
173173 }
174174
175+ @UseGuards ( AuthGuard )
176+ @ApiOperation ( {
177+ summary : 'Used to unmark a project as Conflict of Interest' ,
178+ } )
179+ @ApiBody ( {
180+ type : SetCoIDto ,
181+ description : 'Project id' ,
182+ } )
183+ @UseGuards ( AuthGuard )
184+ @Post ( '/unmark-coI' )
185+ async unmarkCoI ( @Req ( ) { userId } : AuthedReq , @Body ( ) { pid } : SetCoIDto ) {
186+ await this . flowService . unsetCoi ( userId , pid ) ;
187+ return 'Success' ;
188+ }
189+
175190 @UseGuards ( AuthGuard )
176191 @ApiOperation ( {
177192 summary : 'Used for a pairwise vote between two projects' ,
Original file line number Diff line number Diff line change @@ -260,6 +260,30 @@ export class FlowService {
260260 } ) ;
261261 } ;
262262
263+ unsetCoi = async ( userId : number , projectId : number ) => {
264+ await this . prismaService . projectCoI . delete ( {
265+ where : {
266+ userId_projectId : {
267+ projectId,
268+ userId,
269+ } ,
270+ } ,
271+ } ) ;
272+ } ;
273+
274+ isCoi = async ( userId : number , projectId : number ) => {
275+ const res = await this . prismaService . projectCoI . findUnique ( {
276+ where : {
277+ userId_projectId : {
278+ projectId,
279+ userId,
280+ } ,
281+ } ,
282+ } ) ;
283+
284+ return ! ! res ;
285+ } ;
286+
263287 setRating = async (
264288 projectId : number ,
265289 userId : number ,
@@ -568,14 +592,15 @@ export class FlowService {
568592 include : { project : true } ,
569593 } ) ;
570594
571- const withStars = await Promise . all (
595+ const withMoreFields = await Promise . all (
572596 ranking . map ( async ( el ) => ( {
573597 ...el ,
574598 stars : await this . getProjectStars ( el . projectId , userId ) ,
599+ coi : await this . isCoi ( el . projectId , userId ) ,
575600 } ) ) ,
576601 ) ;
577602
578- return withStars . sort ( ( a , b ) => b . share - a . share ) ;
603+ return withMoreFields . sort ( ( a , b ) => b . share - a . share ) ;
579604 } ;
580605
581606 undo = async ( userId : number , parentCollection : number | null ) => {
You can’t perform that action at this time.
0 commit comments