dyomedea/helper.ts

54 lines
1.4 KiB
TypeScript
Raw Normal View History

import { legacyOverlayDefinitions } from './src/components/overlays/overlay-definitions';
2023-01-31 10:56:40 +00:00
let filters: any[] = ['any'];
Object.keys(legacyOverlayDefinitions).forEach((key) => {
const definition = legacyOverlayDefinitions[key];
2023-01-31 10:56:40 +00:00
let filter: any[] = ['in', key];
Object.keys(definition).forEach((subKey) => {
filter = [...filter, subKey];
});
filters = [...filters, filter];
});
// One timer
2023-06-09 10:21:11 +00:00
let tags = {};
let overlays = {};
2023-06-09 10:21:11 +00:00
for (const tagName of Object.keys(legacyOverlayDefinitions)) {
for (const tagValue of Object.keys(legacyOverlayDefinitions[tagName])) {
tags[tagValue] = { name: tagName, value: tagValue };
for (const activity of Object.keys(
legacyOverlayDefinitions[tagName][tagValue]
)) {
if (!overlays[activity]) {
overlays[activity] = {};
}
for (const category of Object.keys(
legacyOverlayDefinitions[tagName][tagValue][activity]
)) {
if (!overlays[activity][category]) {
overlays[activity][category] = [];
}
overlays[activity][category].push(tagValue);
}
}
}
}
console.log({
caller: 'onetimer / result',
2023-06-09 10:21:11 +00:00
tags: JSON.stringify(tags),
overlays: JSON.stringify(overlays),
});
// End of one timer
2023-06-09 10:21:11 +00:00
// console.log({
// legacyOverlayDefinitions,
// filters,
// json: JSON.stringify(filters),
// overlays: JSON.stringify(overlays),
// });