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 // update the corresponding row with event data
rundown.order.forEach((entryId, index) => { rundown.order.forEach((entryId, index) => {
const entry = rundown.entries[entryId]; 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({ const writeResponse = await sheets({ version: 'v4', auth: currentAuthClient }).spreadsheets.batchUpdate({
@@ -89,21 +89,19 @@ export function cellRequestFromEvent(
worksheetId: number, worksheetId: number,
metadata: object, metadata: object,
): sheets_v4.Schema$Request { ): sheets_v4.Schema$Request {
const rowData = Object.entries(metadata) const rowData = Object.entries(metadata) // check what headings are available in the sheet
.filter(([_, value]) => value !== undefined) .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(([_a, a], [_b, b]) => a['col'] - b['col']) as [keyof OntimeEntry | 'blank', { col: number; row: number }][]; // sort the array by the column index
const titleCol = rowData[0][1].col;
// inset blank data is there is spacing between relevant ontime columns
for (const [index, e] of rowData.entries()) { for (const [index, e] of rowData.entries()) {
if (index !== 0) { if (index === 0) continue;
const prevCol = rowData[index - 1][1].col; const prevCol = rowData[index - 1][1].col;
const thisCol = e[1].col; const thisCol = e[1].col;
const diff = thisCol - prevCol; const diff = thisCol - prevCol;
if (diff > 1) { if (diff > 1) {
const fillArr = new Array<(typeof rowData)[0]>(1).fill(['blank', { row: e[1].row, col: prevCol + 1 }]); const fillArr = new Array<(typeof rowData)[0]>(1).fill(['blank', { row: e[1].row, col: prevCol + 1 }]);
rowData.splice(index, 0, ...fillArr); rowData.splice(index, 0, ...fillArr);
}
} }
} }
@@ -129,12 +127,14 @@ export function cellRequestFromEvent(
return { ...getCellData(key, entry), ...cellColor }; return { ...getCellData(key, entry), ...cellColor };
}); });
const headerLocation = rowData[0][1];
return { return {
updateCells: { updateCells: {
start: { start: {
sheetId: worksheetId, sheetId: worksheetId,
rowIndex: index + rowData[0][1]['row'] + 1, rowIndex: index + headerLocation.row + 1,
columnIndex: titleCol, columnIndex: headerLocation.col,
}, },
fields: 'userEnteredValue,userEnteredFormat', fields: 'userEnteredValue,userEnteredFormat',
rows: [ rows: [