Refactor getAllExecutorNames function to accept sourceSheet as a parameter, ensuring proper data retrieval and enhancing error handling for empty sheets in completed tasks report.
This commit is contained in:
parent
157f452b60
commit
fdc95aeee0
|
|
@ -74,8 +74,9 @@ function findSingleTodayReport(prefix: string) {
|
||||||
return found[0];
|
return found[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllExecutorNames(): any[] {
|
function getAllExecutorNames(sourceSheet: GoogleAppsScript.Spreadsheet.Sheet): any[] {
|
||||||
const sourceSheet = getSourceSheet();
|
if (!sourceSheet) return [];
|
||||||
|
|
||||||
const dataRange = sourceSheet.getDataRange();
|
const dataRange = sourceSheet.getDataRange();
|
||||||
const sourceSheetHeader = sourceSheet.getRange(1, 1, 1, dataRange.getNumColumns()).getValues()[0];
|
const sourceSheetHeader = sourceSheet.getRange(1, 1, 1, dataRange.getNumColumns()).getValues()[0];
|
||||||
const executorColumnIndex = sourceSheetHeader.indexOf('Исполнитель');
|
const executorColumnIndex = sourceSheetHeader.indexOf('Исполнитель');
|
||||||
|
|
@ -125,7 +126,7 @@ function loadCompletedTasks(afterDate: Date) {
|
||||||
throw new Error('На листе выгрузки завершенных задач не найдены колонки: ' + missingColumns.join(', '));
|
throw new Error('На листе выгрузки завершенных задач не найдены колонки: ' + missingColumns.join(', '));
|
||||||
}
|
}
|
||||||
|
|
||||||
const performerNames = getAllExecutorNames().map(name => String(name ?? '').trim()).filter(Boolean);
|
const performerNames = getAllExecutorNames(sheet).map(name => String(name ?? '').trim()).filter(Boolean);
|
||||||
const result = new Map<string, any[]>();
|
const result = new Map<string, any[]>();
|
||||||
performerNames.forEach(name => result.set(name, []));
|
performerNames.forEach(name => result.set(name, []));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue