Skip to content

Commit

Permalink
refactor: order functions according to execution flow
Browse files Browse the repository at this point in the history
  • Loading branch information
xurxodev committed Dec 16, 2023
1 parent fe542de commit e11e2f6
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/data/repositories/ProductExportSpreadsheetRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,6 @@ export class ProductExportSpreadsheetRepository implements ProductExportReposito
this.saveWorkbook(wb, workbook.name);
}

private buildExcelWorkbook(workbook: Workbook) {
const wb = new ExcelJS.Workbook();

workbook.sheets.forEach(sheet => {
const sh = wb.addWorksheet(sheet.name);

sh.addRow(sheet.columns);
sh.addRows(sheet.rows);
});

return wb;
}

private splitProducts(products: Product[]) {
const productsSortedByTitle = _c(products)
.uniqWith((product1, product2) => product1.equals(product2))
Expand Down Expand Up @@ -105,6 +92,19 @@ export class ProductExportSpreadsheetRepository implements ProductExportReposito
};
}

private buildExcelWorkbook(workbook: Workbook) {
const wb = new ExcelJS.Workbook();

workbook.sheets.forEach(sheet => {
const sh = wb.addWorksheet(sheet.name);

sh.addRow(sheet.columns);
sh.addRows(sheet.rows);
});

return wb;
}

protected async saveWorkbook(wb: ExcelJS.Workbook, name: string): Promise<void> {
wb.xlsx.writeFile(name);
}
Expand Down

0 comments on commit e11e2f6

Please sign in to comment.