@@ -84,36 +84,40 @@ export function useInstrumentVisualization({ params }: UseInstrumentVisualizatio
8484 } ;
8585
8686 const makeLongRows = ( ) => {
87- let date : Date ;
88- const longRecord : object [ ] = [ ] ;
89- return exportRecords . map ( ( item ) => {
90- for ( const [ objKey , objVal ] of Object . entries ( item ) ) {
87+ const longRecord : any [ ] = [ ] ;
88+
89+ exportRecords . forEach ( ( item ) => {
90+ let date : Date ;
91+
92+ Object . entries ( item ) . forEach ( ( [ objKey , objVal ] ) => {
9193 if ( objKey === '__date__' ) {
9294 date = objVal as Date ;
93- continue ;
95+ return ;
9496 }
97+
9598 if ( Array . isArray ( objVal ) ) {
96- objVal . map ( ( arrayItem ) => {
97- for ( const [ arrKey , arrItem ] of Object . entries ( arrayItem as object ) ) {
99+ objVal . forEach ( ( arrayItem ) => {
100+ Object . entries ( arrayItem as object ) . forEach ( ( [ arrKey , arrItem ] ) => {
98101 longRecord . push ( {
99- Date : date . toISOString ( ) ,
102+ Date : toBasicISOString ( date ) ,
100103 SubjectID : params . subjectId ,
101104 Value : arrItem as string ,
102- Variable : objKey + '-' + arrKey
105+ Variable : ` ${ objKey } - ${ arrKey } `
103106 } ) ;
104- }
107+ } ) ;
108+ } ) ;
109+ } else {
110+ longRecord . push ( {
111+ Date : toBasicISOString ( date ) ,
112+ SubjectID : params . subjectId ,
113+ Value : objVal ,
114+ Variable : objKey
105115 } ) ;
106- continue ;
107116 }
108- longRecord . push ( {
109- Date : date . toISOString ( ) ,
110- SubjectID : params . subjectId ,
111- Value : objVal ,
112- Variable : objKey
113- } ) ;
114- }
115- return longRecord ;
117+ } ) ;
116118 } ) ;
119+
120+ return longRecord ;
117121 } ;
118122
119123 const parseHelper = ( rows : unknown [ ] , delimiter : string ) => {
@@ -156,6 +160,8 @@ export function useInstrumentVisualization({ params }: UseInstrumentVisualizatio
156160 void download ( `${ baseFilename } .tsv` , ( ) => {
157161 const rows = makeWideRows ( ) ;
158162
163+ console . log ( rows ) ;
164+
159165 const tsv = parseHelper ( rows , '\t' ) ;
160166
161167 return tsv ;
@@ -164,6 +170,7 @@ export function useInstrumentVisualization({ params }: UseInstrumentVisualizatio
164170 case 'TSV Long' :
165171 void download ( `${ baseFilename } .tsv` , ( ) => {
166172 const rows = makeLongRows ( ) ;
173+ console . log ( rows ) ;
167174
168175 const tsv = parseHelper ( rows , '\t' ) ;
169176
0 commit comments