Skip to content

Commit

Permalink
Refactor code to skip empty details and improve notifications for wor…
Browse files Browse the repository at this point in the history
…k and school closures
  • Loading branch information
a3510377 committed Sep 30, 2024
1 parent 7d59ef1 commit e95be9e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,19 @@ func checkAndNotification() error {

if len(notifications) > 0 {
text := ""
sendNotifications := []WorkSchoolCloseData{}
for _, v := range notifications {
if len(v.Details) == 0 {
continue
}

text += fmt.Sprintf("%s: \n %s\n", v.County, strings.Join(v.Details, "\n "))
}

sendNotifications := []WorkSchoolCloseData{}
for _, data := range notifications {
if !areaNamesMap[data.County] || len(data.Details) == 0 {
if !areaNamesMap[v.County] {
continue
}

sendNotifications = append(sendNotifications, data)
sendNotifications = append(sendNotifications, v)
}

if len(sendNotifications) > 0 {
Expand Down

0 comments on commit e95be9e

Please sign in to comment.