feat: add allowed_bands filter to award definitions
Adds a new "allowed_bands" key to award definitions that restricts which bands count toward an award. If absent, all bands are allowed (default behavior). Applied to DXCC award to only count HF bands (160m-10m), excluding VHF/UHF bands like 6m, 2m, and 70cm. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -139,11 +139,21 @@ export async function calculateAwardProgress(userId, award, options = {}) {
|
||||
logger.debug('QSOs after filters', { count: filteredQSOs.length });
|
||||
}
|
||||
|
||||
// Apply allowed_bands filter if present
|
||||
let finalQSOs = filteredQSOs;
|
||||
if (rules.allowed_bands && Array.isArray(rules.allowed_bands) && rules.allowed_bands.length > 0) {
|
||||
finalQSOs = filteredQSOs.filter(qso => {
|
||||
const band = qso.band;
|
||||
return rules.allowed_bands.includes(band);
|
||||
});
|
||||
logger.debug('QSOs after allowed_bands filter', { count: finalQSOs.length });
|
||||
}
|
||||
|
||||
// Calculate worked and confirmed entities
|
||||
const workedEntities = new Set();
|
||||
const confirmedEntities = new Set();
|
||||
|
||||
for (const qso of filteredQSOs) {
|
||||
for (const qso of finalQSOs) {
|
||||
const entity = getEntityValue(qso, rules.entityType);
|
||||
|
||||
if (entity) {
|
||||
@@ -708,11 +718,20 @@ export async function getAwardEntityBreakdown(userId, awardId) {
|
||||
// Apply filters
|
||||
const filteredQSOs = applyFilters(allQSOs, rules.filters);
|
||||
|
||||
// Apply allowed_bands filter if present
|
||||
let finalQSOs = filteredQSOs;
|
||||
if (rules.allowed_bands && Array.isArray(rules.allowed_bands) && rules.allowed_bands.length > 0) {
|
||||
finalQSOs = filteredQSOs.filter(qso => {
|
||||
const band = qso.band;
|
||||
return rules.allowed_bands.includes(band);
|
||||
});
|
||||
}
|
||||
|
||||
// Group by (entity, band, mode) slot for entity awards
|
||||
// This allows showing multiple QSOs per entity on different bands/modes
|
||||
const slotMap = new Map(); // Key: "entity/band/mode" -> slot object
|
||||
|
||||
for (const qso of filteredQSOs) {
|
||||
for (const qso of finalQSOs) {
|
||||
const entity = getEntityValue(qso, rules.entityType);
|
||||
|
||||
if (!entity) continue;
|
||||
|
||||
Reference in New Issue
Block a user