1st sync Full

This commit is contained in:
2026-01-15 22:05:09 +01:00
parent f82fc876ce
commit dde0c18f51

View File

@@ -99,15 +99,15 @@ export async function fetchQSOsFromLoTW(lotwUsername, lotwPassword, sinceDate =
qso_withown: 'yes', // Include own callsign
});
// Add date filter - ALWAYS send qso_qslsince to get all QSOs
// LoTW default behavior only returns QSOs since last download, so we must
// explicitly send a date to get QSOs since that date
const dateStr = sinceDate
? sinceDate.toISOString().split('T')[0]
: '2026-01-01'; // Default: Get QSOs since 2026-01-01
// Add date filter - only add qso_qslsince if we have a last QSL date
// For first sync (no QSOs in DB), don't filter by date to get ALL QSOs
if (sinceDate) {
const dateStr = sinceDate.toISOString().split('T')[0];
params.append('qso_qslsince', dateStr);
console.error('Date filter:', dateStr, sinceDate ? '(User-specified date)' : '(Default: since 2026-01-01)');
console.error('Date filter:', dateStr, '(Incremental sync since last QSL date)');
} else {
console.error('No date filter - fetching ALL QSOs (first sync)');
}
const fullUrl = `${url}?${params.toString()}`;
@@ -623,9 +623,16 @@ export async function syncQSOsForJob(jobId, userId, data) {
// Get last LoTW QSL date for incremental sync
const lastQSLDate = await getLastLoTWQSLDate(userId);
const sinceDate = lastQSLDate || new Date('2026-01-01'); // Default as per Wavelog
console.error(`[Job ${jobId}] Syncing LoTW QSOs since ${sinceDate.toISOString().split('T')[0]}`);
// If no QSOs exist, use a far past date to get ALL QSOs (first sync)
// Otherwise, use the last QSL date for incremental sync
const sinceDate = lastQSLDate || new Date('2000-01-01');
if (lastQSLDate) {
console.error(`[Job ${jobId}] Incremental sync since ${sinceDate.toISOString().split('T')[0]}`);
} else {
console.error(`[Job ${jobId}] Full sync - fetching ALL QSOs since 2000-01-01`);
}
// Fetch from LoTW
const adifQSOs = await fetchQSOsFromLoTW(lotwUsername, lotwPassword, sinceDate);