Hello Everybody,
I have created a scripted code that populates episodic shows from season level.
so I have Show Title, Season, Eps count, Start Date, Pattern Release per Week
So this script gives me each date for each episode depending on the pattern release /Eps count and start date.
The Scripting app works perfectly except that it keeps freezes at some point
Like I have 2000 Eps to create, sometimes, it stops at Episode 560, other times it stopped at 916
and it always stops at the same count of episodes, I tried to make sure that everything is in a text mode, no special characters and no odd thing in the lines
still, stop at the same point.
1- Can you please help me figure this out, Why does it stop at all?
2- Can anyone help me in modifying the code, If anything Changes in the fields that are included in the script like " Release Date", āEPSā, āOriginā, Windowing", it modifies only on these fields, keeping the same record, not to create a new record with the updated ones.
let importTable = base.getTable("Titles Release Table"); let importQuery = await importTable.selectRecordsAsync(); let episodesscheduletable = base.getTable('Episodes Schedule'); const episodesScheduleQuery = await episodesscheduletable.selectRecordsAsync() const episodesScheduleNames = episodesScheduleQuery.records.map(x => x.name) for (let record of importQuery.records) { let myDate = new Date(); myDate = new Date(record.getCellValue('Release Date')); let rowcount =0; let EpsNum =0; let cnt = 0; let fullName=''; let ShowOrigin=record.getCellValue('Origin'); let ShowType=record.getCellValue('Type'); let ShowPlatform=record.getCellValue('Platform'); let ShowWindowing=record.getCellValue('Windowing'); let ShowRating=record.getCellValue('Rating'); rowcount= record.getCellValue('EPS') ; let EpsCount =0; EpsCount = record.getCellValue('EPS') ; let Pattern=record.getCellValue('Pattern Release'); if (rowcount==0) {} else if (rowcount==1) { fullName = record.getCellValue('English Title') ; myDate.setDate(myDate.getDate()); await episodesscheduletable.createRecordAsync( { "Name": fullName,"Release Date": myDate }) rowcount=rowcount-1 ; } else { while (rowcount>0) { if (Pattern==5) { EpsNum = cnt + 1; if (cnt==0) { fullName = record.getCellValue('English Title') + ' ' + record.getCellValue('Season') + ' EP' + EpsNum + '-' + 'First' ; myDate.setDate(myDate.getDate()); if (myDate.getDay()==5 || myDate.getDay()==6) { continue; } else {} } else { if (EpsNum == EpsCount) { fullName = record.getCellValue('English Title') + ' ' + record.getCellValue('Season') + ' EP' + EpsNum + '-' + 'Last' ; } else { fullName = record.getCellValue('English Title') + ' ' + record.getCellValue('Season') + ' EP' + EpsNum ; } myDate.setDate(myDate.getDate() + 1); if (myDate.getDay()==5 || myDate.getDay()==6) { continue; } else {} } } else if (Pattern == null || Pattern == 0 || Pattern > 7) { EpsNum = cnt + 1; output.text('NULL EpsNum ' + EpsNum + 'EpsCount ' + EpsCount + 'rowCount' + rowcount) if (cnt==0) { fullName = record.getCellValue('English Title') + ' ' + record.getCellValue('Season') + ' EP' + EpsNum + '-' + 'First' ; } else { if (EpsNum == EpsCount) { fullName = record.getCellValue('English Title') + ' ' + record.getCellValue('Season') + ' EP' + EpsNum + '-' + 'Last' ; } else { fullName = record.getCellValue('English Title') + ' ' + record.getCellValue('Season') + ' EP' + EpsNum ; } } myDate.setDate(myDate.getDate()); } else { EpsNum = EpsNum + 1; fullName = record.getCellValue('English Title') + ' ' + record.getCellValue('Season') + ' EP' + EpsNum ; if (cnt==Pattern) { cnt = 0; output.text('EpsNum ' + EpsNum + 'EpsCount ' + EpsCount) if (EpsNum == EpsCount) { fullName = record.getCellValue('English Title') + ' ' + record.getCellValue('Season') + ' EP' + EpsNum + '-' + 'Last' ; } else { fullName = record.getCellValue('English Title') + ' ' + record.getCellValue('Season') + ' EP' + EpsNum ; } myDate.setDate(myDate.getDate() + (8-Pattern)); } else { if (cnt==0) { fullName = record.getCellValue('English Title') + ' ' + record.getCellValue('Season') + ' EP' + EpsNum + '-' + 'First' ; myDate.setDate(myDate.getDate()); } else { output.text('EpsNum ' + EpsNum + 'EpsCount ' + EpsCount) if (EpsNum == EpsCount) { fullName = record.getCellValue('English Title') + ' ' + record.getCellValue('Season') + ' EP' + EpsNum + '-' + 'Last' ; } else { fullName = record.getCellValue('English Title') + ' ' + record.getCellValue('Season') + ' EP' + EpsNum ; } myDate.setDate(myDate.getDate() + 1); } } } cnt=cnt+1; if(!episodesScheduleNames.includes(fullName)) { await episodesscheduletable.createRecordAsync( { "Name": fullName,"Release Date": myDate ,"Windowing": ShowWindowing ,"Origin": ShowOrigin ,"Type": ShowType ,"Platform": ShowPlatform ,"Rating": ShowRating })} rowcount=rowcount-1 ; // output.text(`New record created!`); } } }