Hotfixes and CI/CD
Some checks failed
Build and Deploy / build-and-deploy (push) Failing after 3m51s

This commit is contained in:
Antoni Nuñez Romeu
2026-04-17 15:33:19 +02:00
parent b3f7d6bf98
commit 114fda056d
24 changed files with 2806 additions and 53 deletions

51
scripts/closeSessions.js Normal file
View File

@@ -0,0 +1,51 @@
// Script to manually close active sessions
// Usage: node scripts/closeSessions.js
const { createClient } = require('@supabase/supabase-js');
// Load environment variables
require('dotenv').config();
// Supabase configuration
const supabaseUrl = process.env.REACT_APP_SUPABASE_URL;
const supabaseAnonKey = process.env.REACT_APP_SUPABASE_ANON_KEY;
if (!supabaseUrl || !supabaseAnonKey) {
console.error('Missing Supabase credentials. Please check your .env file.');
process.exit(1);
}
// Create Supabase client
const supabase = createClient(supabaseUrl, supabaseAnonKey);
async function closeActiveSessions() {
try {
console.log('Closing active sessions...');
// Get current timestamp at midnight
const now = new Date();
const midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate());
// Update all active sessions (where end_time is NULL)
const { data, error } = await supabase
.from('timers')
.update({
end_time: midnight.toISOString(),
})
.eq('end_time', null)
.lt('start_time', midnight.toISOString())
.select();
if (error) {
console.error('Error closing sessions:', error);
return;
}
console.log(`Successfully closed ${data.length} active sessions (history preserved).`);
} catch (error) {
console.error('Error:', error);
}
}
// Run the function
closeActiveSessions();