1st sync Full
This commit is contained in:
@@ -99,15 +99,15 @@ export async function fetchQSOsFromLoTW(lotwUsername, lotwPassword, sinceDate =
|
|||||||
qso_withown: 'yes', // Include own callsign
|
qso_withown: 'yes', // Include own callsign
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add date filter - ALWAYS send qso_qslsince to get all QSOs
|
// Add date filter - only add qso_qslsince if we have a last QSL date
|
||||||
// LoTW default behavior only returns QSOs since last download, so we must
|
// For first sync (no QSOs in DB), don't filter by date to get ALL QSOs
|
||||||
// explicitly send a date to get QSOs since that date
|
if (sinceDate) {
|
||||||
const dateStr = sinceDate
|
const dateStr = sinceDate.toISOString().split('T')[0];
|
||||||
? sinceDate.toISOString().split('T')[0]
|
|
||||||
: '2026-01-01'; // Default: Get QSOs since 2026-01-01
|
|
||||||
params.append('qso_qslsince', dateStr);
|
params.append('qso_qslsince', dateStr);
|
||||||
|
console.error('Date filter:', dateStr, '(Incremental sync since last QSL date)');
|
||||||
console.error('Date filter:', dateStr, sinceDate ? '(User-specified date)' : '(Default: since 2026-01-01)');
|
} else {
|
||||||
|
console.error('No date filter - fetching ALL QSOs (first sync)');
|
||||||
|
}
|
||||||
|
|
||||||
const fullUrl = `${url}?${params.toString()}`;
|
const fullUrl = `${url}?${params.toString()}`;
|
||||||
|
|
||||||
@@ -623,9 +623,16 @@ export async function syncQSOsForJob(jobId, userId, data) {
|
|||||||
|
|
||||||
// Get last LoTW QSL date for incremental sync
|
// Get last LoTW QSL date for incremental sync
|
||||||
const lastQSLDate = await getLastLoTWQSLDate(userId);
|
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
|
// Fetch from LoTW
|
||||||
const adifQSOs = await fetchQSOsFromLoTW(lotwUsername, lotwPassword, sinceDate);
|
const adifQSOs = await fetchQSOsFromLoTW(lotwUsername, lotwPassword, sinceDate);
|
||||||
|
|||||||
Reference in New Issue
Block a user