scheduler-node-models 1.2.82 → 1.2.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scheduler-node-models",
3
- "version": "1.2.82",
3
+ "version": "1.2.84",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "files": [
@@ -21,5 +21,5 @@ export declare class ExcelRowIngest {
21
21
  * @returns A list of labor codes that can be assigned to an employee.
22
22
  */
23
23
  getForecast(date: Date): Promise<LaborCode[]>;
24
- readExcelRow(row: Row, c: number, emp: Employee): Promise<ExcelRow[]>;
24
+ readExcelRow(row: Row, c: number, colDate: Date, emp: Employee): Promise<ExcelRow[]>;
25
25
  }
@@ -48,6 +48,10 @@ class ExcelRowIngest {
48
48
  const workbook = new exceljs_1.Workbook();
49
49
  await workbook.xlsx.load(fileBinary.buffer);
50
50
  const worksheet = workbook.getWorksheet('Sheet1');
51
+ const monthDates = [];
52
+ for (let d = 0; d <= 31; d++) {
53
+ monthDates.push(new Date(this.docDate.getTime() + (d * 24 * 3600000)));
54
+ }
51
55
  if (worksheet) {
52
56
  worksheet.eachRow(async (row, r) => {
53
57
  if (row.getCell(1) && row.getCell(1) !== null && row.getCell(1).value !== null) {
@@ -56,12 +60,13 @@ class ExcelRowIngest {
56
60
  if (this.site.employees) {
57
61
  const emp = this.site.employees.find(e => e.name.getLastFirst().toLowerCase() === name.toLowerCase());
58
62
  if (emp) {
59
- for (let c = 3; c < 34; c++) {
60
- const results = await this.readExcelRow(row, c, emp);
61
- results.forEach(r => {
62
- result.push(new excelRow_1.ExcelRow(r));
63
+ const rowPromises = monthDates.map(async (day, d) => {
64
+ const results = await this.readExcelRow(row, d + 3, day, emp);
65
+ results.forEach(eRow => {
66
+ result.push(new excelRow_1.ExcelRow(eRow));
63
67
  });
64
- }
68
+ });
69
+ await Promise.allSettled(rowPromises);
65
70
  }
66
71
  }
67
72
  else {
@@ -96,13 +101,12 @@ class ExcelRowIngest {
96
101
  });
97
102
  return laborcodes;
98
103
  }
99
- async readExcelRow(row, c, emp) {
104
+ async readExcelRow(row, c, colDate, emp) {
100
105
  const result = [];
101
106
  // create test patterns for hours, if value doesn't match the hours pattern, it will
102
107
  // be assumed to be a leave code
103
108
  const hPattern = "^[0-9]{1,2}(\.[0-9]+)?$";
104
109
  const hourRE = new RegExp(hPattern);
105
- const colDate = new Date(this.docDate.getTime() + (24 * 3600000 * (c - 3)));
106
110
  // Step through the days of the month to create the excel rows to add
107
111
  // for this employee
108
112
  const sValue = row.getCell(c).toString().trim();
@@ -152,6 +156,7 @@ class ExcelRowIngest {
152
156
  });
153
157
  }
154
158
  }
159
+ console.log(`result: ${result.length}`);
155
160
  return result;
156
161
  }
157
162
  }