Compare commits
5 Commits
developmen
...
e78902d79f
| Author | SHA1 | Date | |
|---|---|---|---|
| e78902d79f | |||
|
|
e52aea9dd3 | ||
| cdc8b89916 | |||
| 9dd79514f5 | |||
|
|
cd37d8da0f |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "scan-wave",
|
"name": "scan-wave",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.2",
|
"version": "0.0.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
|
|||||||
@@ -138,64 +138,35 @@
|
|||||||
|
|
||||||
if (rows.length === 0) throw new Error('No data found in sheet');
|
if (rows.length === 0) throw new Error('No data found in sheet');
|
||||||
|
|
||||||
// --- Start of new logic to handle duplicates ---
|
// Extract participant data based on column mapping
|
||||||
|
const names: string[] = [];
|
||||||
|
const surnames: string[] = [];
|
||||||
|
const emails: string[] = [];
|
||||||
|
|
||||||
// First, extract all potential participants from the sheet
|
// Skip header row (start from index 1)
|
||||||
const potentialParticipants = [];
|
|
||||||
for (let i = 1; i < rows.length; i++) {
|
for (let i = 1; i < rows.length; i++) {
|
||||||
const row = rows[i];
|
const row = rows[i];
|
||||||
if (row.length > 0) {
|
if (row.length > 0) {
|
||||||
const name = row[event.name_column - 1] || '';
|
const name = row[event.name_column - 1] || '';
|
||||||
const surname = row[event.surname_column - 1] || '';
|
const surname = row[event.surname_column - 1] || '';
|
||||||
const email = (row[event.email_column - 1] || '').trim();
|
const email = row[event.email_column - 1] || '';
|
||||||
const confirmation = row[event.confirmation_column - 1] || '';
|
const confirmation = row[event.confirmation_column - 1] || '';
|
||||||
|
|
||||||
|
// Only add if the row has meaningful data (not all empty) AND confirmation is TRUE
|
||||||
const isConfirmed =
|
const isConfirmed =
|
||||||
confirmation.toString().toLowerCase() === 'true' ||
|
confirmation.toString().toLowerCase() === 'true' ||
|
||||||
confirmation.toString().toLowerCase() === 'yes' ||
|
confirmation.toString().toLowerCase() === 'yes' ||
|
||||||
confirmation === '1' ||
|
confirmation === '1' ||
|
||||||
confirmation === 'x';
|
confirmation === 'x';
|
||||||
|
|
||||||
if ((name.trim() || surname.trim() || email) && isConfirmed) {
|
if ((name.trim() || surname.trim() || email.trim()) && isConfirmed) {
|
||||||
potentialParticipants.push({ name: name.trim(), surname: surname.trim(), email });
|
names.push(name.trim());
|
||||||
|
surnames.push(surname.trim());
|
||||||
|
emails.push(email.trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a map to count occurrences of each unique participant combination
|
|
||||||
const participantCounts = new Map<string, number>();
|
|
||||||
for (const p of potentialParticipants) {
|
|
||||||
const key = `${p.name}|${p.surname}|${p.email}`.toLowerCase(); // Create a unique key
|
|
||||||
participantCounts.set(key, (participantCounts.get(key) || 0) + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create final arrays, modifying duplicate surnames to be unique
|
|
||||||
const names: string[] = [];
|
|
||||||
const surnames: string[] = [];
|
|
||||||
const emails: string[] = [];
|
|
||||||
const processedParticipants = new Map<string, number>();
|
|
||||||
|
|
||||||
for (const p of potentialParticipants) {
|
|
||||||
const key = `${p.name}|${p.surname}|${p.email}`.toLowerCase();
|
|
||||||
let finalSurname = p.surname;
|
|
||||||
|
|
||||||
// If this participant is a duplicate
|
|
||||||
if (participantCounts.get(key)! > 1) {
|
|
||||||
const count = (processedParticipants.get(key) || 0) + 1;
|
|
||||||
processedParticipants.set(key, count);
|
|
||||||
|
|
||||||
// If it's not the first occurrence, append a counter to the surname
|
|
||||||
if (count > 1) {
|
|
||||||
finalSurname = `${p.surname} (${count})`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
names.push(p.name);
|
|
||||||
surnames.push(finalSurname);
|
|
||||||
emails.push(p.email); // Keep the original email
|
|
||||||
}
|
|
||||||
// --- End of new logic ---
|
|
||||||
|
|
||||||
// Call database function to add participants
|
// Call database function to add participants
|
||||||
const { error: syncError } = await data.supabase.rpc('participants_add_bulk', {
|
const { error: syncError } = await data.supabase.rpc('participants_add_bulk', {
|
||||||
p_event: eventId,
|
p_event: eventId,
|
||||||
|
|||||||
@@ -1,71 +1,87 @@
|
|||||||
/// <reference lib="webworker" />
|
|
||||||
/// <reference types="@sveltejs/kit" />
|
/// <reference types="@sveltejs/kit" />
|
||||||
import { build, files, version } from '$service-worker';
|
import { build, files, version } from '$service-worker';
|
||||||
|
|
||||||
declare const self: ServiceWorkerGlobalScope;
|
// Create a unique cache name for this deployment
|
||||||
|
|
||||||
const CACHE = `cache-${version}`;
|
const CACHE = `cache-${version}`;
|
||||||
|
|
||||||
const ASSETS = [
|
const ASSETS = [
|
||||||
...build,
|
...build, // the app itself
|
||||||
...files
|
...files // everything in `static`
|
||||||
];
|
];
|
||||||
|
|
||||||
self.addEventListener('install', (event: ExtendableEvent) => {
|
self.addEventListener('install', (event) => {
|
||||||
const addFilesToCache = async () => {
|
// Create a new cache and add all files to it
|
||||||
|
async function addFilesToCache() {
|
||||||
const cache = await caches.open(CACHE);
|
const cache = await caches.open(CACHE);
|
||||||
await cache.addAll(ASSETS);
|
await cache.addAll(ASSETS);
|
||||||
};
|
}
|
||||||
|
|
||||||
console.log("[SW] Installing new service worker");
|
|
||||||
|
|
||||||
event.waitUntil(addFilesToCache());
|
event.waitUntil(addFilesToCache());
|
||||||
self.skipWaiting();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener('activate', (event: ExtendableEvent) => {
|
self.addEventListener('activate', (event) => {
|
||||||
const deleteOldCaches = async () => {
|
// Remove previous cached data from disk
|
||||||
|
async function deleteOldCaches() {
|
||||||
for (const key of await caches.keys()) {
|
for (const key of await caches.keys()) {
|
||||||
if (key !== CACHE) await caches.delete(key);
|
if (key !== CACHE) await caches.delete(key);
|
||||||
console.log("[SW] Removing old service worker")
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
event.waitUntil(deleteOldCaches());
|
event.waitUntil(deleteOldCaches());
|
||||||
self.clients.claim();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener('fetch', (event: FetchEvent) => {
|
self.addEventListener('fetch', (event) => {
|
||||||
|
// ignore POST requests etc
|
||||||
if (event.request.method !== 'GET') return;
|
if (event.request.method !== 'GET') return;
|
||||||
|
|
||||||
|
async function respond() {
|
||||||
const url = new URL(event.request.url);
|
const url = new URL(event.request.url);
|
||||||
|
|
||||||
// Never cache private routes
|
// Skip caching for auth routes
|
||||||
if (url.pathname.startsWith('/private')) {
|
if (url.pathname.startsWith('/auth/')) {
|
||||||
event.respondWith(fetch(event.request));
|
return fetch(event.request);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const respond = async () => {
|
|
||||||
const cache = await caches.open(CACHE);
|
const cache = await caches.open(CACHE);
|
||||||
|
|
||||||
|
// `build`/`files` can always be served from the cache
|
||||||
if (ASSETS.includes(url.pathname)) {
|
if (ASSETS.includes(url.pathname)) {
|
||||||
const cached = await cache.match(url.pathname);
|
const response = await cache.match(url.pathname);
|
||||||
if (cached) return cached;
|
|
||||||
|
if (response) {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// for everything else, try the network first, but
|
||||||
|
// fall back to the cache if we're offline
|
||||||
try {
|
try {
|
||||||
const response = await fetch(event.request);
|
const response = await fetch(event.request);
|
||||||
if (response.status === 200 && build.length > 0 && url.pathname.startsWith(`/${build[0]}/`)) {
|
|
||||||
cache.put(event.request, response.clone());
|
// if we're offline, fetch can return a value that is not a Response
|
||||||
}
|
// instead of throwing - and we can't pass this non-Response to respondWith
|
||||||
return response;
|
if (!(response instanceof Response)) {
|
||||||
} catch {
|
throw new Error('invalid response from fetch');
|
||||||
const cached = await cache.match(event.request);
|
|
||||||
if (cached) return cached;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Response('Not found', { status: 404 });
|
// Do not cache private pages
|
||||||
};
|
if (response.status === 200 && !url.pathname.startsWith('/private')) {
|
||||||
|
cache.put(event.request, response.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
} catch (err) {
|
||||||
|
const response = await cache.match(event.request);
|
||||||
|
|
||||||
|
if (response) {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if there's no cache, then just error out
|
||||||
|
// as there is nothing we can do to respond to this request
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
event.respondWith(respond());
|
event.respondWith(respond());
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user