Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | 44x 1x 1x 2x 2x 1x 1x 2x 2x 2x 2x 2x 1x 1x 1x | import { first } from "remeda";
import {
checkUnknownKeys,
parseProgramItem,
} from "server/kompassi/getProgramItemsFromKompassi";
import { logger } from "server/utils/logger";
import { config } from "shared/config";
import {
KompassiProgramItemSchema,
KompassiProgramItem,
KompassiKonstiProgramType,
} from "server/kompassi/kompassiProgramItem";
export const getProgramItemsFromFullProgramSolmukohta = (
programItems: unknown[],
): KompassiProgramItem[] => {
checkUnknownKeys(programItems, KompassiProgramItemSchema);
const kompassiProgramItems = programItems.flatMap((programItem) => {
const result = parseProgramItem(programItem, KompassiProgramItemSchema);
return result ?? [];
});
logger.info(`Found ${kompassiProgramItems.length} valid program items`);
const matchingProgramItems = kompassiProgramItems.flatMap((programItem) => {
// These program items are hand picked to be exported from Kompassi
Iif (config.event().addToKonstiOther.includes(programItem.slug)) {
return programItem;
}
// Take program items with Konsti dimension and valid program type
const programType = first(programItem.cachedDimensions.konsti);
const validProgramType =
programType &&
Object.values(KompassiKonstiProgramType).includes(programType);
Iif (!validProgramType) {
return [];
}
/*
// Take program items with tag "sk-advance-signup"
if (!programItem.tags.includes(KompassiTag.ADVANCE_SIGNUP)) {
return [];
}
*/
return programItem;
});
Iif (matchingProgramItems.length === 0) {
logger.error(new Error("No program items with known categories found"));
return [];
}
logger.info(`Found ${matchingProgramItems.length} matching program items`);
return matchingProgramItems;
};
|