chore: clarifying comments

This commit is contained in:
arc-alex
2025-09-06 11:50:29 +02:00
committed by Alex Christoffer Rasmussen
parent 9e78ff4d1c
commit 9d6ec3758b
2 changed files with 16 additions and 16 deletions
@@ -389,7 +389,7 @@ export async function upload(sheetId: string, options: ImportMap) {
// update the corresponding row with event data
rundown.order.forEach((entryId, index) => {
const entry = rundown.entries[entryId];
return updateRundown.push(cellRequestFromEvent(entry, index, worksheetId, sheetMetadata));
updateRundown.push(cellRequestFromEvent(entry, index, worksheetId, sheetMetadata));
});
const writeResponse = await sheets({ version: 'v4', auth: currentAuthClient }).spreadsheets.batchUpdate({
@@ -89,21 +89,19 @@ export function cellRequestFromEvent(
worksheetId: number,
metadata: object,
): sheets_v4.Schema$Request {
const rowData = Object.entries(metadata)
.filter(([_, value]) => value !== undefined)
.sort(([_a, a], [_b, b]) => a['col'] - b['col']) as [keyof OntimeEntry | 'blank', { col: number; row: number }][];
const titleCol = rowData[0][1].col;
const rowData = Object.entries(metadata) // check what headings are available in the sheet
.filter(([_, value]) => value !== undefined) // drop anything that is undefined
.sort(([_a, a], [_b, b]) => a['col'] - b['col']) as [keyof OntimeEntry | 'blank', { col: number; row: number }][]; // sort the array by the column index
// inset blank data is there is spacing between relevant ontime columns
for (const [index, e] of rowData.entries()) {
if (index !== 0) {
const prevCol = rowData[index - 1][1].col;
const thisCol = e[1].col;
const diff = thisCol - prevCol;
if (diff > 1) {
const fillArr = new Array<(typeof rowData)[0]>(1).fill(['blank', { row: e[1].row, col: prevCol + 1 }]);
rowData.splice(index, 0, ...fillArr);
}
if (index === 0) continue;
const prevCol = rowData[index - 1][1].col;
const thisCol = e[1].col;
const diff = thisCol - prevCol;
if (diff > 1) {
const fillArr = new Array<(typeof rowData)[0]>(1).fill(['blank', { row: e[1].row, col: prevCol + 1 }]);
rowData.splice(index, 0, ...fillArr);
}
}
@@ -129,12 +127,14 @@ export function cellRequestFromEvent(
return { ...getCellData(key, entry), ...cellColor };
});
const headerLocation = rowData[0][1];
return {
updateCells: {
start: {
sheetId: worksheetId,
rowIndex: index + rowData[0][1]['row'] + 1,
columnIndex: titleCol,
rowIndex: index + headerLocation.row + 1,
columnIndex: headerLocation.col,
},
fields: 'userEnteredValue,userEnteredFormat',
rows: [