make UID unique

This commit is contained in:
Fabrice Lamant
2024-07-21 09:16:28 +01:00
parent 16fc8cb75c
commit a3e3f1e382
261 changed files with 5219 additions and 5215 deletions

View File

@ -78,6 +78,10 @@ const generateCalendars = () => {
});
};
const slugify = (text) => text.toLowerCase().replace(/\s/g, "-")
.replace(/[^a-z0-9-]/g, "")
.replace(/-+/g, "-");
const extractSportCalendar = async (sportKey) => {
const data = await downloadSchedule(sportKey);
const sportName = data.query.pDisciplineLabel;
@ -89,7 +93,7 @@ const extractSportCalendar = async (sportKey) => {
unit.endDateTimeUtc = new Date(unit.endDate).toISOString().replace(".000", "");
const event = {
UID: `${sportKey}-${unit.startDateTimeUtc.replace(/[:-]/g, "")}`,
UID: `${sportKey}-${unit.startDateTimeUtc.replace(/[:-]/g, "")}-${slugify(unit.eventUnitName).toUpperCase()}`,
DTSTAMP: unit.startDateTimeUtc.replace(/[:-]/g, ""),
DTSTART: unit.startDateTimeUtc.replace(/[:-]/g, ""),
DTEND: unit.endDateTimeUtc.replace(/[:-]/g, ""),