code for privacy corner is "c"

This commit is contained in:
tree🌴 2024-02-24 03:42:27 +01:00
parent 85bad09cb2
commit 27e4d6c46a
2 changed files with 37 additions and 2 deletions

View File

@ -333,7 +333,7 @@
speakers: speakers:
- mykola-siusko - mykola-siusko
- id: pc24rom - id: c24rom
issue: 23 issue: 23
type: privacy-corner type: privacy-corner
date: "2024-10-04" date: "2024-10-04"
@ -364,7 +364,7 @@
- pg - pg
- tree - tree
- id: pc24brn - id: c24brn
issue: 24 issue: 24
type: privacy-corner type: privacy-corner
date: "2024-10-25" date: "2024-10-25"

View File

@ -23,3 +23,38 @@ function checkCollection(name, schema, data) {
// check index // check index
checkCollection("index", engine.schemas.index, engine.rendered); checkCollection("index", engine.schemas.index, engine.rendered);
// check events
const eventTypes = {
summit: { code: "s" },
meetup: { code: "m" },
hackathon: { code: "h" },
"privacy-corner": { code: "c" },
};
const usedIds = [];
for (const event of engine.rendered.events) {
Deno.test(`event: ${event.id}`, () => {
// check id duplicates
if (usedIds.includes(event.id)) {
throw `Duplicate ID: ${event.id}`;
}
usedIds.push(event.id);
// check id
const codes = Object.keys(eventTypes).map((et) => eventTypes[et].code);
const match = event.id.match(
new RegExp(`^(${codes.join("|")})(\\d{2})(\\w{2,3})$`),
);
if (!match) {
throw `Bad event id: ${event.id}`;
}
const [_, type, year, location] = match;
if (eventTypes[event.type].code !== type) {
throw `ID doesnt reflect event type: id=${event.id} type=${event.type}`;
}
const eventYear = event.date.match(/^\d{2}(\d{2})/)[1];
if (year !== eventYear) {
throw `ID doesnt reflect event year: id=${event.id} date=${event.date}`;
}
});
}