@@ -21,6 +21,7 @@ const { RunDetectorQualities } = require('../../lib/domain/enums/RunDetectorQual
2121const { RunCalibrationStatus } = require ( '../../lib/domain/enums/RunCalibrationStatus.js' ) ;
2222const { updateRun } = require ( '../../lib/server/services/run/updateRun.js' ) ;
2323const { RunDefinition } = require ( '../../lib/domain/enums/RunDefinition.js' ) ;
24+ const { qcFlagService } = require ( '../../lib/server/services/qualityControlFlag/QcFlagService.js' ) ;
2425
2526module . exports = ( ) => {
2627 before ( resetDatabaseContent ) ;
@@ -570,6 +571,39 @@ module.exports = () => {
570571 expect ( runs . every ( ( { aliceDipoleCurrent, aliceDipolePolarity } ) =>
571572 Math . round ( aliceDipoleCurrent * ( aliceDipolePolarity === 'NEGATIVE' ? - 1 : 1 ) / 1000 ) === 0 ) ) . to . be . true ;
572573 } ) ;
574+
575+ it ( 'should successfully handle query including QC flags' , async ( ) => {
576+ { // Data Passes
577+ const response = await request ( server ) . get ( `/api/runs?filter[dataPassIds][]=1&include[effectiveQcFlags]=true` )
578+ expect ( response . status ) . to . equal ( 200 ) ;
579+ const { data : runs } = response . body ;
580+
581+ expect ( runs ) . to . have . lengthOf ( 3 ) ;
582+ expect ( runs . find ( ( { runNumber } ) => runNumber === 107 ) . qcFlags [ '1' ] . map ( ( { id } ) => id ) ) . to . have . all . members ( [ 202 , 201 ] ) ;
583+ expect ( runs . find ( ( { runNumber } ) => runNumber === 107 ) . qcFlags [ '2' ] . map ( ( { id } ) => id ) ) . to . have . all . members ( [ 203 ] ) ;
584+ expect ( runs . find ( ( { runNumber } ) => runNumber === 106 ) . qcFlags [ '1' ] . map ( ( { id } ) => id ) ) . to . have . all . members ( [ 3 , 2 , 1 ] ) ;
585+ }
586+
587+ { // Simulation Passes
588+ const response = await request ( server ) . get ( `/api/runs?filter[simulationPassIds][]=1&include[effectiveQcFlags]=true` )
589+ expect ( response . status ) . to . equal ( 200 ) ;
590+ const { data : runs } = response . body ;
591+ expect ( runs ) . to . have . lengthOf ( 3 ) ;
592+
593+ console . log ( 'TOBEC' , await qcFlagService . getAllPerSimulationPassAndRunAndDetector ( { simulationPassId : 1 , runNumber : 106 , detectorId : 1 } ) ) ;
594+
595+ expect ( runs . find ( ( { runNumber } ) => runNumber === 106 ) . qcFlags [ '1' ] . map ( ( { id } ) => id ) ) . to . have . all . members ( [ 6 , 5 ] ) ;
596+ }
597+
598+ { // Synchronous flags
599+ const response = await request ( server ) . get ( `/api/runs?filter[lhcPeriodIds][]=1&include[effectiveQcFlags]=true` )
600+ expect ( response . status ) . to . equal ( 200 ) ;
601+ const { data : runs } = response . body ;
602+ expect ( runs ) . to . have . lengthOf ( 4 ) ;
603+ expect ( runs . find ( ( { runNumber } ) => runNumber === 56 ) . qcFlags [ '7' ] . map ( ( { id } ) => id ) ) . to . have . all . members ( [ 101 , 100 ] ) ;
604+ expect ( runs . find ( ( { runNumber } ) => runNumber === 56 ) . qcFlags [ '4' ] . map ( ( { id } ) => id ) ) . to . have . all . members ( [ 102 ] ) ;
605+ }
606+ } ) ;
573607 } ) ;
574608
575609 describe ( 'GET /api/runs/reasonTypes' , ( ) => {
0 commit comments