Filters
This commit is contained in:
@@ -148,6 +148,7 @@ function convertQSODatabaseFormat(adifQSO, userId) {
|
||||
mode: normalizeMode(adifQSO.mode),
|
||||
freq: adifQSO.freq ? parseInt(adifQSO.freq) : null,
|
||||
freqRx: adifQSO.freq_rx ? parseInt(adifQSO.freq_rx) : null,
|
||||
// DCL may or may not include DXCC fields - use them if available
|
||||
entity: adifQSO.country || adifQSO.dxcc_country || '',
|
||||
entityId: adifQSO.dxcc ? parseInt(adifQSO.dxcc) : null,
|
||||
grid: adifQSO.gridsquare || '',
|
||||
@@ -252,7 +253,6 @@ export async function syncQSOs(userId, dclApiKey, sinceDate = null, jobId = null
|
||||
|
||||
if (dataChanged) {
|
||||
// Update existing QSO with changed DCL confirmation and DOK data
|
||||
// Only update DOK/grid fields if DCL actually sent values (non-empty)
|
||||
const updateData = {
|
||||
dclQslRdate: dbQSO.dclQslRdate,
|
||||
dclQslRstatus: dbQSO.dclQslRstatus,
|
||||
@@ -268,6 +268,24 @@ export async function syncQSOs(userId, dclApiKey, sinceDate = null, jobId = null
|
||||
updateData.gridSource = dbQSO.gridSource;
|
||||
}
|
||||
|
||||
// DXCC priority: LoTW > DCL
|
||||
// Only update entity fields from DCL if:
|
||||
// 1. QSO is NOT LoTW confirmed, AND
|
||||
// 2. DCL actually sent entity data, AND
|
||||
// 3. Current entity is missing
|
||||
const hasLoTWConfirmation = existingQSO.lotwQslRstatus === 'Y';
|
||||
const hasDCLData = dbQSO.entity || dbQSO.entityId;
|
||||
const missingEntity = !existingQSO.entity || existingQSO.entity === '';
|
||||
|
||||
if (!hasLoTWConfirmation && hasDCLData && missingEntity) {
|
||||
// Fill in entity data from DCL (only if DCL provides it)
|
||||
if (dbQSO.entity) updateData.entity = dbQSO.entity;
|
||||
if (dbQSO.entityId) updateData.entityId = dbQSO.entityId;
|
||||
if (dbQSO.continent) updateData.continent = dbQSO.continent;
|
||||
if (dbQSO.cqZone) updateData.cqZone = dbQSO.cqZone;
|
||||
if (dbQSO.ituZone) updateData.ituZone = dbQSO.ituZone;
|
||||
}
|
||||
|
||||
await db
|
||||
.update(qsos)
|
||||
.set(updateData)
|
||||
|
||||
Reference in New Issue
Block a user