scheduler-node-models 1.2.83 → 1.2.85

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.83",
3
+ "version": "1.2.85",
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) {
100
- const result = [];
104
+ async readExcelRow(row, c, colDate, emp) {
105
+ const answer = [];
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();
@@ -133,7 +137,7 @@ class ExcelRowIngest {
133
137
  eRow.extension = laborcode.extension;
134
138
  eRow.premium = '1';
135
139
  eRow.hours = Number(sValue);
136
- result.push(eRow);
140
+ answer.push(eRow);
137
141
  }
138
142
  }
139
143
  else {
@@ -147,12 +151,13 @@ class ExcelRowIngest {
147
151
  eRow.employee = emp.companyinfo.employeeid;
148
152
  eRow.code = wc.id;
149
153
  eRow.hours = emp.getStandardWorkday(colDate);
150
- result.push(eRow);
154
+ answer.push(eRow);
151
155
  }
152
156
  });
153
157
  }
154
158
  }
155
- return result;
159
+ console.log(`Answer: ${answer.length}`);
160
+ return answer;
156
161
  }
157
162
  }
158
163
  exports.ExcelRowIngest = ExcelRowIngest;