@@ -228,10 +228,12 @@ const csvFilePath = './../private-data/2022updvirtual.csv';
228228 }
229229 }
230230
231- if ( studentData [ student ] . hasOwnProperty ( 'Team' ) ) {
231+ /* if(studentData[student].hasOwnProperty('Team')) {
232+ // console.log(studentData[student]['Team'])
232233 for(var t in studentData[student]['Team']) {
233234 const school = schoolData['Name'];
234235 const team = studentData[student]['Team'][t];
236+ // console.log(school + " " + team)
235237 // console.log(team);
236238 if(team.includes("7th")) {
237239 const row = await competitionsTable.read({
@@ -247,6 +249,10 @@ const csvFilePath = './../private-data/2022updvirtual.csv';
247249 // Never hurts to check for null
248250 const schoolTeam = school + team.slice(0, -2);
249251
252+ // console.log(row)
253+ // console.log(studentRow)
254+ // console.log(schoolTeam)
255+
250256 if(teamData.hasOwnProperty(schoolTeam)) {
251257 // Switch in person
252258 if(team.charAt(team.length - 1) === '1') {
@@ -298,88 +304,89 @@ const csvFilePath = './../private-data/2022updvirtual.csv';
298304 }
299305 }
300306 }
301- }
307+ } */
302308
303309 if ( studentData [ student ] . hasOwnProperty ( 'Creative Thinking' ) ) {
304- for ( var t in studentData [ student ] [ 'Creative Thinking' ] ) {
305- const school = schoolData [ 'Name' ] ;
306- const team = studentData [ student ] [ 'Creative Thinking' ] [ t ] ;
307- // console.log(team);
308- if ( team . includes ( "Seventh" ) ) {
309- const row = await competitionsTable . read ( {
310- filterByFormula : 'Name = "Division ' + schoolData [ 'Division' ] + ' 7th Grade Creative Thinking"' ,
311- maxRecords : 1
312- } ) ;
313-
314- const studentRow = await studentsTable . read ( {
315- filterByFormula : 'Name = "' + student + '"' ,
316- maxRecords : 1
317- } ) ;
318-
319- // Never hurts to check for null
320- const schoolTeam = school + team . slice ( 0 , - 2 ) ;
321-
322- if ( teamData . hasOwnProperty ( schoolTeam ) ) {
323- // Switch in person
324- if ( team . charAt ( team . length - 1 ) === '1' ) {
325- const temp = teamData [ schoolTeam ] [ 'Students' ] [ 0 ] ;
326-
327- teamData [ schoolTeam ] [ 'Students' ] [ 0 ] = studentRow [ 0 ] [ 'id' ] ;
328- teamData [ schoolTeam ] [ 'Students' ] . push ( temp ) ;
329- }
330- else {
331- teamData [ schoolTeam ] [ 'Students' ] . push ( studentRow [ 0 ] [ 'id' ] ) ;
332- }
333- }
334- else if ( schoolTeam != '' ) {
335- teamData [ schoolTeam ] = { } ;
336- teamData [ schoolTeam ] [ 'Competition' ] = [ row [ 0 ] [ 'id' ] ] ;
337- teamData [ schoolTeam ] [ 'Students' ] = [ studentRow [ 0 ] [ 'id' ] ] ;
338- }
339- }
340- else {
341- const row = await competitionsTable . read ( {
342- filterByFormula : 'Name = "Division ' + schoolData [ 'Division' ] + ' 8th Grade Creative Thinking"' ,
343- maxRecords : 1
344- } ) ;
345-
346- const studentRow = await studentsTable . read ( {
347- filterByFormula : 'Name = "' + student + '"' ,
348- maxRecords : 1
349- } ) ;
350-
351- // Never hurts to check for null
352- const schoolTeam = school + team . slice ( 0 , - 2 ) ;
353-
354- if ( teamData . hasOwnProperty ( schoolTeam ) ) {
355- // Switch in person if necessary
356- if ( team . charAt ( team . length - 1 ) === '1' ) {
357- const temp = teamData [ schoolTeam ] [ 'Students' ] [ 0 ] ;
358-
359- teamData [ schoolTeam ] [ 'Students' ] [ 0 ] = studentRow [ 0 ] [ 'id' ] ;
360- teamData [ schoolTeam ] [ 'Students' ] . push ( temp ) ;
361- }
362- else {
363- teamData [ schoolTeam ] [ 'Students' ] . push ( studentRow [ 0 ] [ 'id' ] ) ;
364- }
365- }
366- else if ( schoolTeam != '' ) {
367- teamData [ schoolTeam ] = { } ;
368- teamData [ schoolTeam ] [ 'Competition' ] = [ row [ 0 ] [ 'id' ] ] ;
369- teamData [ schoolTeam ] [ 'Students' ] = [ studentRow [ 0 ] [ 'id' ] ] ;
370- }
310+ for ( var t in studentData [ student ] [ 'Creative Thinking' ] ) {
311+ const school = schoolData [ 'Name' ] ;
312+ const team = studentData [ student ] [ 'Creative Thinking' ] [ t ] ;
313+ // console.log(team);
314+ if ( team . includes ( "Seventh" ) ) {
315+ const row = await competitionsTable . read ( {
316+ filterByFormula : 'Name = "Division ' + schoolData [ 'Division' ] + ' Creative Thinking"' ,
317+ maxRecords : 1
318+ } ) ;
319+
320+ const studentRow = await studentsTable . read ( {
321+ filterByFormula : 'Name = "' + student + '"' ,
322+ maxRecords : 1
323+ } ) ;
324+
325+ // Never hurts to check for null
326+ const schoolTeam = school + team . slice ( 0 , - 15 ) ;
327+
328+ if ( teamData . hasOwnProperty ( schoolTeam ) ) {
329+ // Switch in person
330+ if ( team . charAt ( team . length - 1 ) === '1' ) {
331+ const temp = teamData [ schoolTeam ] [ 'Students' ] [ 0 ] ;
332+
333+ teamData [ schoolTeam ] [ 'Students' ] [ 0 ] = studentRow [ 0 ] [ 'id' ] ;
334+ teamData [ schoolTeam ] [ 'Students' ] . push ( temp ) ;
335+ }
336+ else {
337+ teamData [ schoolTeam ] [ 'Students' ] . push ( studentRow [ 0 ] [ 'id' ] ) ;
338+ }
339+ }
340+ else if ( schoolTeam != '' ) {
341+ teamData [ schoolTeam ] = { } ;
342+ teamData [ schoolTeam ] [ 'Competition' ] = [ row [ 0 ] [ 'id' ] ] ;
343+ teamData [ schoolTeam ] [ 'Students' ] = [ studentRow [ 0 ] [ 'id' ] ] ;
344+ }
345+ }
346+ else {
347+ const row = await competitionsTable . read ( {
348+ filterByFormula : 'Name = "Division ' + schoolData [ 'Division' ] + ' Creative Thinking"' ,
349+ maxRecords : 1
350+ } ) ;
351+
352+ const studentRow = await studentsTable . read ( {
353+ filterByFormula : 'Name = "' + student + '"' ,
354+ maxRecords : 1
355+ } ) ;
356+
357+ // Never hurts to check for null
358+ const schoolTeam = school + team . slice ( 0 , - 14 ) ;
359+ console . log ( schoolTeam )
360+
361+ if ( teamData . hasOwnProperty ( schoolTeam ) ) {
362+ // Switch in person if necessary
363+ if ( team . charAt ( team . length - 1 ) === '1' ) {
364+ const temp = teamData [ schoolTeam ] [ 'Students' ] [ 0 ] ;
365+
366+ teamData [ schoolTeam ] [ 'Students' ] [ 0 ] = studentRow [ 0 ] [ 'id' ] ;
367+ teamData [ schoolTeam ] [ 'Students' ] . push ( temp ) ;
368+ }
369+ else {
370+ teamData [ schoolTeam ] [ 'Students' ] . push ( studentRow [ 0 ] [ 'id' ] ) ;
371+ }
372+ }
373+ else if ( schoolTeam != '' ) {
374+ teamData [ schoolTeam ] = { } ;
375+ teamData [ schoolTeam ] [ 'Competition' ] = [ row [ 0 ] [ 'id' ] ] ;
376+ teamData [ schoolTeam ] [ 'Students' ] = [ studentRow [ 0 ] [ 'id' ] ] ;
377+ }
378+ }
371379 }
372380 }
373381 }
374382
375- console . log ( teamData ) ;
376-
377- for ( var record in teamData ) {
378- // await testsTable.create(teamData[record]);
379- }
383+ console . log ( teamData ) ;
380384
381- // console.log(teamData);
385+ for ( var record in teamData ) {
386+ await testsTable . create ( teamData [ record ] ) ;
382387 }
388+
389+ // console.log(teamData);
383390 }
384391 catch ( e ) {
385392 console . error ( e ) ;
0 commit comments