From 07d0e82dffe7da2e94fa1460baa6904299e0679b Mon Sep 17 00:00:00 2001 From: Daniel Mason Date: Mon, 17 Jan 2022 16:25:26 +1300 Subject: [PATCH] standardize macrons --- .gitlab-ci.yml | 1 + CHANGELOG.md | 1 + internal/nzcovidbot/api.go | 15 +++++++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c65006c..dca47c5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,3 +15,4 @@ build-go: expire_in: 1 month paths: - nzcovidbot +app \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index eadbe83..d3de0c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ # 1.3 - Omicron related ones will post with an asterisk to indicate +- Group different spelling locations together ## 1.2 - Change lastUpdated to pointer reference and use built in .After() functions diff --git a/internal/nzcovidbot/api.go b/internal/nzcovidbot/api.go index 576fc7b..f6e2bca 100644 --- a/internal/nzcovidbot/api.go +++ b/internal/nzcovidbot/api.go @@ -102,7 +102,8 @@ func getNewAPILocations() { if strings.Contains(strings.ToLower(item.PublicAdvice), "omicron") { copy.EventName = copy.EventName + " (Omicron)" } - newItems[item.Location.City] = append(newItems[item.Location.City], copy) + locationParse := parseCity(item.Location.City) + newItems[locationParse] = append(newItems[locationParse], copy) // Always keep the latest if item.PublishedAt.After(newUpdatedTime) { @@ -113,7 +114,8 @@ func getNewAPILocations() { copy := item // Apend Omicron if Omicron in advice copy.EventName = copy.EventName + " (Omicron)" - newItems[item.Location.City] = append(newItems[item.Location.City], copy) + locationParse := parseCity(item.Location.City) + newItems[locationParse] = append(newItems[locationParse], copy) // Always keep the latest if item.UpdatedAt.After(newUpdatedTime) { @@ -198,3 +200,12 @@ func getDaySuffix(t time.Time) string { } return suffix } + +func parseCity(c string) string { + switch city := c; city { + case "Whangarei": + return "Whangārei" + default: + return city + } +}