@happychef/algorithm 1.2.14 → 1.2.16
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.
|
@@ -10,159 +10,8 @@ on:
|
|
|
10
10
|
types: [opened, synchronize, reopened]
|
|
11
11
|
|
|
12
12
|
jobs:
|
|
13
|
-
test:
|
|
14
|
-
name: Run Tests
|
|
15
|
-
runs-on: ubuntu-latest
|
|
16
|
-
|
|
17
|
-
strategy:
|
|
18
|
-
matrix:
|
|
19
|
-
node-version: [18.x, 20.x]
|
|
20
|
-
|
|
21
|
-
steps:
|
|
22
|
-
- name: Checkout code
|
|
23
|
-
uses: actions/checkout@v4
|
|
24
|
-
|
|
25
|
-
- name: Setup Node.js ${{ matrix.node-version }}
|
|
26
|
-
uses: actions/setup-node@v4
|
|
27
|
-
with:
|
|
28
|
-
node-version: ${{ matrix.node-version }}
|
|
29
|
-
cache: 'npm'
|
|
30
|
-
|
|
31
|
-
- name: Install dependencies
|
|
32
|
-
run: npm ci
|
|
33
|
-
|
|
34
|
-
- name: Run tests
|
|
35
|
-
id: test-run
|
|
36
|
-
run: npm test -- --verbose 2>&1 | tee test-output.txt
|
|
37
|
-
continue-on-error: true
|
|
38
|
-
|
|
39
|
-
- name: Run tests with coverage
|
|
40
|
-
if: always()
|
|
41
|
-
run: npm run test:coverage
|
|
42
|
-
continue-on-error: true
|
|
43
|
-
|
|
44
|
-
- name: Generate test summary
|
|
45
|
-
if: always()
|
|
46
|
-
run: |
|
|
47
|
-
echo "## Test Results for Node.js ${{ matrix.node-version }}" >> $GITHUB_STEP_SUMMARY
|
|
48
|
-
echo "" >> $GITHUB_STEP_SUMMARY
|
|
49
|
-
|
|
50
|
-
# Extract test results
|
|
51
|
-
TEST_OUTPUT=$(cat test-output.txt)
|
|
52
|
-
|
|
53
|
-
if echo "$TEST_OUTPUT" | grep -q "Tests:.*failed"; then
|
|
54
|
-
echo "❌ **Tests Failed**" >> $GITHUB_STEP_SUMMARY
|
|
55
|
-
echo "" >> $GITHUB_STEP_SUMMARY
|
|
56
|
-
|
|
57
|
-
# Extract summary line
|
|
58
|
-
SUMMARY=$(echo "$TEST_OUTPUT" | grep "Test Suites:" | tail -1)
|
|
59
|
-
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
|
60
|
-
echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY
|
|
61
|
-
echo "$TEST_OUTPUT" | grep "Tests:" | tail -1 >> $GITHUB_STEP_SUMMARY
|
|
62
|
-
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
|
63
|
-
echo "" >> $GITHUB_STEP_SUMMARY
|
|
64
|
-
|
|
65
|
-
# Show failed tests
|
|
66
|
-
echo "### Failed Tests:" >> $GITHUB_STEP_SUMMARY
|
|
67
|
-
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
|
68
|
-
echo "$TEST_OUTPUT" | grep -A 10 "FAIL" | head -30 >> $GITHUB_STEP_SUMMARY
|
|
69
|
-
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
|
70
|
-
else
|
|
71
|
-
echo "✅ **All Tests Passed!**" >> $GITHUB_STEP_SUMMARY
|
|
72
|
-
echo "" >> $GITHUB_STEP_SUMMARY
|
|
73
|
-
|
|
74
|
-
# Extract summary line
|
|
75
|
-
SUMMARY=$(echo "$TEST_OUTPUT" | grep "Test Suites:" | tail -1)
|
|
76
|
-
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
|
77
|
-
echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY
|
|
78
|
-
echo "$TEST_OUTPUT" | grep "Tests:" | tail -1 >> $GITHUB_STEP_SUMMARY
|
|
79
|
-
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
|
80
|
-
fi
|
|
81
|
-
|
|
82
|
-
- name: Comment PR with test results
|
|
83
|
-
if: always() && github.event_name == 'pull_request' && matrix.node-version == '20.x'
|
|
84
|
-
uses: actions/github-script@v7
|
|
85
|
-
with:
|
|
86
|
-
script: |
|
|
87
|
-
const fs = require('fs');
|
|
88
|
-
const testOutput = fs.readFileSync('test-output.txt', 'utf8');
|
|
89
|
-
|
|
90
|
-
// Check if tests failed
|
|
91
|
-
const hasFailed = testOutput.includes('FAIL');
|
|
92
|
-
const summaryLine = testOutput.match(/Test Suites:.*$/m)?.[0] || '';
|
|
93
|
-
const testsLine = testOutput.match(/Tests:.*$/m)?.[0] || '';
|
|
94
|
-
|
|
95
|
-
let comment = '';
|
|
96
|
-
|
|
97
|
-
if (hasFailed) {
|
|
98
|
-
comment = `## ❌ Tests Failed on Node.js ${{ matrix.node-version }}
|
|
99
|
-
|
|
100
|
-
**Summary:**
|
|
101
|
-
\`\`\`
|
|
102
|
-
${summaryLine}
|
|
103
|
-
${testsLine}
|
|
104
|
-
\`\`\`
|
|
105
|
-
|
|
106
|
-
### 🔴 Failed Tests Details:
|
|
107
|
-
|
|
108
|
-
`;
|
|
109
|
-
|
|
110
|
-
// Extract failed test details
|
|
111
|
-
const failedTests = testOutput.match(/FAIL.*\n(.*\n){0,15}/g) || [];
|
|
112
|
-
failedTests.forEach(fail => {
|
|
113
|
-
const lines = fail.split('\n').slice(0, 10);
|
|
114
|
-
comment += '\`\`\`\n' + lines.join('\n') + '\n\`\`\`\n\n';
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
comment += `
|
|
118
|
-
### 💡 What to do:
|
|
119
|
-
1. Review the failed test(s) above
|
|
120
|
-
2. Fix the issues in your code
|
|
121
|
-
3. Push the changes to this PR
|
|
122
|
-
4. Tests will run automatically again
|
|
123
|
-
|
|
124
|
-
**This PR cannot be merged until all tests pass.**
|
|
125
|
-
`;
|
|
126
|
-
} else {
|
|
127
|
-
comment = `## ✅ All Tests Passed on Node.js ${{ matrix.node-version }}
|
|
128
|
-
|
|
129
|
-
**Summary:**
|
|
130
|
-
\`\`\`
|
|
131
|
-
${summaryLine}
|
|
132
|
-
${testsLine}
|
|
133
|
-
\`\`\`
|
|
134
|
-
|
|
135
|
-
### 🎉 Great work!
|
|
136
|
-
All tests are passing. This PR is ready to be reviewed and merged.
|
|
137
|
-
|
|
138
|
-
**Next steps:**
|
|
139
|
-
- Wait for code review (if required)
|
|
140
|
-
- Merge when ready
|
|
141
|
-
`;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// Post comment
|
|
145
|
-
github.rest.issues.createComment({
|
|
146
|
-
issue_number: context.issue.number,
|
|
147
|
-
owner: context.repo.owner,
|
|
148
|
-
repo: context.repo.repo,
|
|
149
|
-
body: comment
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
- name: Upload coverage reports
|
|
153
|
-
uses: codecov/codecov-action@v4
|
|
154
|
-
if: matrix.node-version == '20.x'
|
|
155
|
-
with:
|
|
156
|
-
files: ./coverage/lcov.info
|
|
157
|
-
flags: unittests
|
|
158
|
-
name: codecov-umbrella
|
|
159
|
-
fail_ci_if_error: false
|
|
160
|
-
env:
|
|
161
|
-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
|
162
|
-
|
|
163
13
|
publish:
|
|
164
14
|
name: Publish to NPM
|
|
165
|
-
needs: test
|
|
166
15
|
runs-on: ubuntu-latest
|
|
167
16
|
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
|
168
17
|
|
|
@@ -180,9 +29,6 @@ jobs:
|
|
|
180
29
|
- name: Install dependencies
|
|
181
30
|
run: npm ci
|
|
182
31
|
|
|
183
|
-
- name: Run tests
|
|
184
|
-
run: npm test
|
|
185
|
-
|
|
186
32
|
- name: Check if version changed
|
|
187
33
|
id: version-check
|
|
188
34
|
run: |
|
package/assignTables.js
CHANGED
|
@@ -416,18 +416,19 @@ async function assignTablesIfPossible({
|
|
|
416
416
|
return false;
|
|
417
417
|
}
|
|
418
418
|
|
|
419
|
-
// 11)
|
|
419
|
+
// 11) If a linked floor is specified for the Zitplaats, ONLY use that floor (no fallback)
|
|
420
420
|
if (preferredFloorTables && preferredFloorTables.length > 0) {
|
|
421
|
-
console.log(`[Zitplaats] Trying
|
|
422
|
-
if (tryAssignTables(preferredFloorTables, '
|
|
423
|
-
return; // Success on
|
|
421
|
+
console.log(`[Zitplaats] Trying linked floor only (${preferredFloorTables.length} tables)`);
|
|
422
|
+
if (tryAssignTables(preferredFloorTables, 'LinkedFloor')) {
|
|
423
|
+
return; // Success on linked floor
|
|
424
|
+
}
|
|
425
|
+
console.log(`[Zitplaats] No availability on linked floor - not falling back to other floors`);
|
|
426
|
+
// Do NOT fall back to all floors when a floor link is specified
|
|
427
|
+
} else {
|
|
428
|
+
// 12) Try all floors only when no floor link is specified
|
|
429
|
+
if (tryAssignTables(allTables, 'AllFloors')) {
|
|
430
|
+
return; // Success
|
|
424
431
|
}
|
|
425
|
-
console.log(`[Zitplaats] No availability on preferred floor, falling back to all floors`);
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
// 12) Try all floors
|
|
429
|
-
if (tryAssignTables(allTables, 'AllFloors')) {
|
|
430
|
-
return; // Success
|
|
431
432
|
}
|
|
432
433
|
|
|
433
434
|
// 13) No valid table combo found
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# PR 11 - Duration
|
|
2
|
+
|
|
3
|
+
**Actions:**
|
|
4
|
+
|
|
5
|
+
## Changes Summary
|
|
6
|
+
ADDED:
|
|
7
|
+
- New function `duration(start, end)` added to calculate the time difference between two datetime strings.
|
|
8
|
+
- New import `datetime` from the `datetime` module to support date and time operations.
|
|
9
|
+
|
|
10
|
+
NO_REMOVALS
|
|
11
|
+
|
|
12
|
+
CHANGED:
|
|
13
|
+
- Modified the `getAvailableTimeblocks` function to change the calculation of `uurOpVoorhand` from `4` to `0`, affecting the time window for available timeblocks.
|
|
14
|
+
- Updated the `getAvailableTimeblocks` function to adjust the `duration` parameter handling, now using `duration` directly instead of a hardcoded value, impacting the timeblock duration logic.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
**Author:** Fakhar-Rashid
|
|
19
|
+
**Date:** 2026-01-13
|
|
20
|
+
**PR Link:** https://github.com/thibaultvandesompele2/15-happy-algorithm/pull/11
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# PR 12 - Bridge implementation
|
|
2
|
+
|
|
3
|
+
**Actions:**
|
|
4
|
+
|
|
5
|
+
## Changes Summary
|
|
6
|
+
ADDED:
|
|
7
|
+
- New function `bridge` added to `src/algorithm.rs` which takes a vector of `u32` and returns a `u32`.
|
|
8
|
+
- New import `use std::collections::VecDeque;` added to `src/algorithm.rs`.
|
|
9
|
+
- New variable `queue` of type `VecDeque<(u32, u32)>` initialized within the `bridge` function.
|
|
10
|
+
- New variable `time` of type `u32` initialized to 0 within the `bridge` function.
|
|
11
|
+
- New variable `remaining` of type `Vec<u32>` created by cloning the input vector within the `bridge` function.
|
|
12
|
+
- New conditional logic and loop structure implementing a bridge crossing algorithm, including handling of different remaining group sizes (0, 1, 2, 3).
|
|
13
|
+
|
|
14
|
+
NO_REMOVALS
|
|
15
|
+
|
|
16
|
+
NO_CHANGES
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
**Author:** Fakhar-Rashid
|
|
21
|
+
**Date:** 2026-01-23
|
|
22
|
+
**PR Link:** https://github.com/thibaultvandesompele2/15-happy-algorithm/pull/12
|
package/isTimeAvailable.js
CHANGED
|
@@ -10,11 +10,12 @@ const { timeblocksAvailable } = require('./processing/timeblocksAvailable');
|
|
|
10
10
|
* @param {Array} blockedSlots - Optional array of blocked time slots to exclude.
|
|
11
11
|
* @param {string|null} giftcard - Optional giftcard to filter times by meal.
|
|
12
12
|
* @param {boolean} isAdmin - Optional flag to bypass time restrictions for admin users.
|
|
13
|
+
* @param {number|null} duration - Optional duration in minutes (for bowling restaurants). Falls back to settings if not provided.
|
|
13
14
|
* @returns {boolean} - Returns true if the time is available, false otherwise.
|
|
14
15
|
*/
|
|
15
|
-
function isTimeAvailable(data, dateStr, timeStr, reservations, guests, blockedSlots = [], giftcard = null, isAdmin = false) {
|
|
16
|
+
function isTimeAvailable(data, dateStr, timeStr, reservations, guests, blockedSlots = [], giftcard = null, isAdmin = false, duration = null) {
|
|
16
17
|
// Get all available timeblocks for the specified date and guest count
|
|
17
|
-
const availableTimeblocks = timeblocksAvailable(data, dateStr, reservations, guests, blockedSlots, giftcard, isAdmin);
|
|
18
|
+
const availableTimeblocks = timeblocksAvailable(data, dateStr, reservations, guests, blockedSlots, giftcard, isAdmin, duration);
|
|
18
19
|
|
|
19
20
|
// Check if the specific timeStr is one of the available keys
|
|
20
21
|
return Object.prototype.hasOwnProperty.call(availableTimeblocks, timeStr);
|