diff --git a/build.js b/build.js index 67ca648..8775f14 100644 --- a/build.js +++ b/build.js @@ -49,7 +49,7 @@ function getBinType(key) { } function formatAlternativeName(name) { - return name.replace('Day', '').replace('(Changed Collection)', '').replace('Garden Waste Collection', 'Garden Bin').trim(); + return name.replace(/Day|\(Changed Collection\)/gi, '').replace('Garden Waste Collection', 'Garden Bin').trim(); } function getWeekdayFromDate(date) { @@ -83,6 +83,7 @@ calendars.forEach(function(filepath) { "lastGenerated": new Date().toJSON(), "lastModified": fileProperties.modifyTime, "totalCollections": 0, + "totalChangedCollections": 0, "collectionDates": [] }; @@ -110,6 +111,10 @@ calendars.forEach(function(filepath) { .sort((a,b) => new Date(a.collectionDate) - new Date(b.collectionDate)); jsonData['totalCollections'] = allEvents.length; + jsonData['totalChangedCollections'] = allEvents.filter(function(item){ + return item.name.includes("Changed Collection"); + }).length; + jsonData['collectionDates'] = allEvents; // Write to JSON folder for public API diff --git a/json-endpoints.html b/json-endpoints.html index 6e27a21..726f765 100644 --- a/json-endpoints.html +++ b/json-endpoints.html @@ -23,6 +23,7 @@

{{ page.title }}

  • lastGenerated - The last time the JSON data was generated from a deployment.
  • lastModified - The last time the calendar data was modified, this is based on the modified date of the original iCal source.
  • totalCollections - The total items within the collectionDates.
  • +
  • totalChangedCollections - The total of one-off changed collection dates that differ from the collectionWeekday.
  • collectionDates - The array containing all bin collection dates, with occurrences expanded to single events.
  • @@ -38,6 +39,7 @@

    {{ page.title }}

    "lastGenerated": "2024-06-29T18:45:14.023Z", "lastModified": "2024-06-17T14:12:39.206Z", "totalCollections": 53, + "totalChangedCollections": 1, "collectionDates": [ ... ]