I have a script that takes a fuel price increase in a single cell and applies it in each cell in a row of fuel prices at various Fuel Stations. The code is copied below. How can i optimise the code to run in as little time as possible?
let table = base.getTable("Customer Deals");
let queryResult = await table.selectRecordsAsync({fields: ["Petrol Price", "Price Increase"], sorts: [{field: "Price Increase", direction: "desc"}]});
let firstRecord = queryResult.records[0];
let increase = firstRecord.getCellValue("Price Increase");
if (!(increase === 0)) {
for (let record of queryResult.records) {
let newPetrolPrice = record.getCellValue("Petrol Price") + increase;
await table.updateRecordAsync(record, {'Petrol Price': newPetrolPrice});
}
await table.updateRecordAsync(firstRecord, {'Price Increase': 0});
}