@@ -88,13 +88,25 @@ class DataPassService {
8888 * @returns {Promise<CountedItems<DataPass>> } result
8989 */
9090 async getAll ( {
91- filter,
91+ filter = { } ,
9292 limit,
9393 offset,
9494 sort,
9595 } = { } ) {
9696 const queryBuilder = this . prepareQueryBuilder ( ) ;
9797
98+ /**
99+ * @typedef
100+ * @property {object } filter
101+ * @property {number[] } [filter.lhcPeriodIds] lhcPeriod identifier to filter with
102+ * @property {number[] } [filter.simulationPassIds] simulationPass identifier to filter with
103+ * @property {number[] } [filter.ids] data passes identifier to filter with
104+ * @property {string[] } [filter.names] data passes names to filter with
105+ * @property {string[] } [filter.permittedNonPhysicsNames] list of tokens in data passes names which indicate
106+ * a given data pass should not be excluded, possible tokens are 'test', 'debug'.
107+ */
108+ const { ids, names, permittedNonPhysicsNames = [ ] , lhcPeriodIds, simulationPassIds } = filter ;
109+
98110 if ( sort ) {
99111 for ( const property in sort ) {
100112 queryBuilder . orderBy ( property , sort [ property ] ) ;
@@ -108,37 +120,24 @@ class DataPassService {
108120 queryBuilder . offset ( offset ) ;
109121 }
110122
111- if ( filter ) {
112- /**
113- * @typedef
114- * @property {object } filter
115- * @property {number[] } [filter.lhcPeriodIds] lhcPeriod identifier to filter with
116- * @property {number[] } [filter.simulationPassIds] simulationPass identifier to filter with
117- * @property {number[] } [filter.ids] data passes identifier to filter with
118- * @property {string[] } [filter.names] data passes names to filter with
119- * @property {boolean } [filter.include.byName] list of tokens in data passes names which indicate
120- * a given data pass should not be excluded, possible tokens are 'test', 'debug'.
121- */
122- const { ids, names, lhcPeriodIds, simulationPassIds } = filter ;
123- if ( lhcPeriodIds ) {
124- queryBuilder . where ( 'lhcPeriodId' ) . oneOf ( ...lhcPeriodIds ) ;
125- }
126- if ( simulationPassIds ) {
127- queryBuilder . whereAssociation ( 'anchoredSimulationPasses' , 'id' ) . oneOf ( ...simulationPassIds ) ;
128- }
129- if ( ids ) {
130- queryBuilder . where ( 'id' ) . oneOf ( ...ids ) ;
131- }
132- if ( names ) {
133- queryBuilder . where ( 'name' ) . oneOf ( ...names ) ;
134- }
123+ if ( lhcPeriodIds ) {
124+ queryBuilder . where ( 'lhcPeriodId' ) . oneOf ( ...lhcPeriodIds ) ;
125+ }
126+ if ( simulationPassIds ) {
127+ queryBuilder . whereAssociation ( 'anchoredSimulationPasses' , 'id' ) . oneOf ( ...simulationPassIds ) ;
128+ }
129+ if ( ids ) {
130+ queryBuilder . where ( 'id' ) . oneOf ( ...ids ) ;
131+ }
132+ if ( names ) {
133+ queryBuilder . where ( 'name' ) . oneOf ( ...names ) ;
135134 }
136135
137- const byName = filter ?. include ?. byName ?? [ ] ;
138- if ( ! byName . includes ( NonPhysicsProductionsNamesWords . TEST ) ) {
136+ if ( ! permittedNonPhysicsNames . includes ( NonPhysicsProductionsNamesWords . TEST ) ) {
139137 queryBuilder . where ( 'name' ) . not ( ) . substring ( `\\_${ NonPhysicsProductionsNamesWords . TEST } ` ) ;
140138 }
141- if ( ! byName . includes ( NonPhysicsProductionsNamesWords . DEBUG ) ) {
139+
140+ if ( ! permittedNonPhysicsNames . includes ( NonPhysicsProductionsNamesWords . DEBUG ) ) {
142141 queryBuilder . where ( 'name' ) . not ( ) . substring ( `\\_${ NonPhysicsProductionsNamesWords . DEBUG } ` ) ;
143142 }
144143
0 commit comments