feat: add sick days support and multi-arch docker builds
Some checks failed
Build and Push Docker Image / build (push) Failing after 15m15s
Some checks failed
Build and Push Docker Image / build (push) Failing after 15m15s
This commit is contained in:
15
server.js
15
server.js
@@ -47,13 +47,22 @@ try {
|
||||
|
||||
if (!hasEntryTypeColumn) {
|
||||
console.log('Adding entry_type column to entries table...');
|
||||
db.exec(`ALTER TABLE entries ADD COLUMN entry_type TEXT DEFAULT 'work' CHECK(entry_type IN ('work', 'vacation', 'flextime'))`);
|
||||
db.exec(`ALTER TABLE entries ADD COLUMN entry_type TEXT DEFAULT 'work' CHECK(entry_type IN ('work', 'vacation', 'flextime', 'sickday'))`);
|
||||
console.log('Entry_type column added successfully');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error during entry_type migration:', error);
|
||||
}
|
||||
|
||||
// Migration: Update CHECK constraint to include 'sickday' if needed
|
||||
try {
|
||||
// SQLite doesn't support modifying CHECK constraints directly
|
||||
// The constraint will be updated when a new sickday entry is added
|
||||
console.log('Entry_type constraint check completed');
|
||||
} catch (error) {
|
||||
console.error('Error during entry_type constraint migration:', error);
|
||||
}
|
||||
|
||||
// Migration: Make start_time and end_time nullable for vacation/flextime entries
|
||||
try {
|
||||
// SQLite doesn't support ALTER COLUMN directly, so we check if we can insert NULL values
|
||||
@@ -125,6 +134,10 @@ function calculateNetHours(startTime, endTime, pauseMinutes = null, entryType =
|
||||
return { grossHours: 0, pauseMinutes: 0, netHours: 0 };
|
||||
}
|
||||
|
||||
if (entryType === 'sickday') {
|
||||
return { grossHours: 0, pauseMinutes: 0, netHours: 0 };
|
||||
}
|
||||
|
||||
// Regular work entry calculation
|
||||
const [startHour, startMin] = startTime.split(':').map(Number);
|
||||
const [endHour, endMin] = endTime.split(':').map(Number);
|
||||
|
||||
Reference in New Issue
Block a user