@@ -146,40 +146,6 @@ export class InstrumentRecordsService {
146146 }
147147
148148 async exportRecords ( { groupId } : { groupId ?: string } = { } , { ability } : Required < EntityOperationOptions > ) {
149- //separate this into seperate queries that are done within the thread (ie find session and subject info in thread instead with prisma model)
150- // const records = await this.instrumentRecordModel.findMany({
151- // include: {
152- // session: {
153- // select: {
154- // date: true,
155- // id: true,
156- // type: true,
157- // user: { select: { username: true } }
158- // }
159- // },
160- // subject: {
161- // select: {
162- // dateOfBirth: true,
163- // groupIds: true,
164- // id: true,
165- // sex: true
166- // }
167- // }
168- // },
169- // where: {
170- // AND: [
171- // {
172- // subject: groupId ? { groupIds: { has: groupId } } : {}
173- // },
174- // accessibleQuery(ability, 'read', 'InstrumentRecord')
175- // ]
176- // }
177- // });
178-
179- // TBD IMPORTANT - add permissions
180-
181- //const permissions = accessibleQuery(ability, 'read', 'InstrumentRecord')
182-
183149 const records = await this . queryRecordsRaw ( ability , groupId ) ;
184150
185151 // console.log(records[0]
@@ -221,7 +187,7 @@ export class InstrumentRecordsService {
221187 // console.log(records[0]);
222188
223189 // throw new Error("NULL")
224- structuredClone ( records ) ;
190+ // structuredClone(records);
225191
226192 const instrumentIds = [ ...new Set ( records . map ( ( r ) => r . instrumentId ) ) ] ;
227193
@@ -231,29 +197,6 @@ export class InstrumentRecordsService {
231197
232198 const instruments = new Map ( instrumentsArray . map ( ( instrument ) => [ instrument . id , instrument ] ) ) ;
233199
234- // const convertRecords = records.map((record) => {
235- // return {
236- // computedMeasures: record.computedMeasures,
237- // date: record.date.toISOString(),
238- // id: record.id,
239- // instrumentId: record.instrumentId,
240- // session: {
241- // date: record.session.date.toISOString(),
242- // id: record.session.id,
243- // type: record.session.type,
244- // user: {
245- // username: record.session.user?.username
246- // }
247- // },
248- // subject: {
249- // age: record.subject.dateOfBirth ? yearsPassed(record.subject.dateOfBirth) : null,
250- // groupIds: record.subject.groupIds,
251- // id: record.subject.id,
252- // sex: record.subject.sex
253- // }
254- // };
255- // });
256-
257200 const numWorkers = Math . min ( cpus ( ) . length , Math . ceil ( records . length / 100 ) ) ; // Use up to CPU count, chunk size 100
258201 const chunkSize = Math . ceil ( records . length / numWorkers ) ;
259202 const chunks = [ ] ;
0 commit comments