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,20 +101,15 @@ func getNewAPILocations() {
// Apend Omicron if Omicron in advice // Apend Omicron if Omicron in advice
copy.EventName = copy.EventName + " (Omicron)" copy.EventName = copy.EventName + " (Omicron)"
newItems[item.Location.City] = append(newItems[item.Location.City], copy) 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) { } else if item.PublishedAt.After(previousUpdatedTime) {
// Clone the item to put in our own lil slice // Clone the item to put in our own lil slice
copy := item copy := item
newItems[item.Location.City] = append(newItems[item.Location.City], copy) newItems[item.Location.City] = append(newItems[item.Location.City], copy)
}
// Always keep the latest // Always keep the latest
if item.PublishedAt.After(newUpdatedTime) { if item.PublishedAt.After(newUpdatedTime) {
newUpdatedTime = item.PublishedAt newUpdatedTime = item.PublishedAt
}
} }
} }