@@ -41,7 +41,8 @@ export default class PostgresInstrumentDataSource
4141 instrument . name ,
4242 instrument . short_code ,
4343 instrument . description ,
44- instrument . manager_user_id
44+ instrument . manager_user_id ,
45+ instrument . selectable
4546 ) ;
4647 }
4748
@@ -80,6 +81,7 @@ export default class PostgresInstrumentDataSource
8081 short_code : args . shortCode ,
8182 description : args . description ,
8283 manager_user_id : args . managerUserId ,
84+ selectable : ! ! args . selectable ,
8385 } )
8486 . into ( 'instruments' )
8587 . returning ( '*' ) ;
@@ -153,7 +155,8 @@ export default class PostgresInstrumentDataSource
153155 }
154156
155157 async getInstrumentsByCallId (
156- callIds : number [ ]
158+ callIds : number [ ] ,
159+ selectableOnly ?: boolean
157160 ) : Promise < InstrumentWithAvailabilityTime [ ] > {
158161 return database
159162 . select ( [
@@ -170,6 +173,11 @@ export default class PostgresInstrumentDataSource
170173 'i.instrument_id' : 'chi.instrument_id' ,
171174 } )
172175 . whereIn ( 'chi.call_id' , callIds )
176+ . modify ( ( query ) => {
177+ if ( selectableOnly ) {
178+ query . andWhere ( 'i.selectable' , true ) ;
179+ }
180+ } )
173181 . distinct ( 'i.instrument_id' )
174182 . then ( ( instruments : InstrumentWithAvailabilityTimeRecord [ ] ) => {
175183 const result = instruments . map ( ( instrument ) =>
@@ -286,6 +294,7 @@ export default class PostgresInstrumentDataSource
286294 short_code : instrument . shortCode ,
287295 description : instrument . description ,
288296 manager_user_id : instrument . managerUserId ,
297+ selectable : instrument . selectable ,
289298 } ,
290299 [ '*' ]
291300 )
0 commit comments