wcif-helpers
Version:
Some helpers for WCIF
56 lines • 1.83 kB
JavaScript
export const getActivityInfoFromSchedule = (roundId, wcif) => {
let activityToReturn = null;
wcif.schedule.venues.forEach((venue) => {
venue.rooms.forEach((room) => {
room.activities.forEach((activity) => {
if (activity.activityCode === roundId) {
activityToReturn = activity;
}
activity.childActivities.forEach((childActivity) => {
if (childActivity.activityCode === roundId) {
activityToReturn = childActivity;
}
});
});
});
});
return activityToReturn;
};
export const getGroupInfoByActivityId = (activityId, wcif) => {
let groupInfo = null;
wcif.schedule.venues.forEach((venue) => {
venue.rooms.forEach((room) => {
room.activities.forEach((activity) => {
if (activity.id === activityId) {
groupInfo = activity;
}
activity.childActivities.forEach((childActivity) => {
if (childActivity.id === activityId) {
groupInfo = childActivity;
}
});
});
});
});
return groupInfo;
};
export const prettyRoundFormat = (format, cutoffAttempts) => {
switch (format) {
case "1":
return "Best of 1";
case "2":
return "Best of 2";
case "3":
return "Best of 3";
case "a":
if (!cutoffAttempts) {
return `Average of 5`;
}
return `Best of ${cutoffAttempts} / Average of 5`;
case "m":
return "Mean of 3";
default:
return "Unknown";
}
};
//# sourceMappingURL=schedule.js.map