Keep latest event always

This commit is contained in:
Daniel Mason 2022-01-16 14:39:40 +13:00
parent 8423c83f2c
commit 51163b15e6

View file

@ -101,22 +101,17 @@ func getNewAPILocations() {
// Apend Omicron if Omicron in advice
copy.EventName = copy.EventName + " (Omicron)"
newItems[item.Location.City] = append(newItems[item.Location.City], copy)
// Always keep the latest
if item.PublishedAt.After(newUpdatedTime) {
newUpdatedTime = item.PublishedAt
}
} else if item.PublishedAt.After(previousUpdatedTime) {
// Clone the item to put in our own lil slice
copy := item
newItems[item.Location.City] = append(newItems[item.Location.City], copy)
}
// Always keep the latest
if item.PublishedAt.After(newUpdatedTime) {
newUpdatedTime = item.PublishedAt
}
}
}
// Make sure to clear out the previous list and append new data in a map based on location
newLocations = PostResponse{}