From ade147a6f1f0e5f3cc9cd2b20e34326561fcb395 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Tue, 3 Oct 2023 10:07:04 +0900 Subject: [PATCH 1/4] =?UTF-8?q?chore:=20=E6=99=82=E9=96=93=E5=89=B2?= =?UTF-8?q?=E6=83=85=E5=A0=B1=E3=81=AE=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/cron.go | 8 ++++---- utils/cron_test.go | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/utils/cron.go b/utils/cron.go index bbaecc01..7a4577cb 100644 --- a/utils/cron.go +++ b/utils/cron.go @@ -122,10 +122,10 @@ func createMessage(t time.Time, rooms []*domain.Room, events []*db.Event, origin {"1-2", setTimeFromString(t, "08:50:00"), true}, {"3-4", setTimeFromString(t, "10:45:00"), true}, {"昼", setTimeFromString(t, "12:25:00"), true}, - {"5-6", setTimeFromString(t, "13:45:00"), true}, - {"7-8", setTimeFromString(t, "15:40:00"), true}, - {"9-10", setTimeFromString(t, "17:30:00"), true}, - {":crescent_moon:", setTimeFromString(t, "19:10:00"), false}, + {"5-6", setTimeFromString(t, "13:30:00"), true}, + {"7-8", setTimeFromString(t, "15:25:00"), true}, + {"9-10", setTimeFromString(t, "17:15:00"), true}, + {":crescent_moon:", setTimeFromString(t, "18:55:00"), false}, } roomAvailable := makeRoomAvailableByTimeTable(rooms, timeTables, t) diff --git a/utils/cron_test.go b/utils/cron_test.go index afa39629..c38b6062 100644 --- a/utils/cron_test.go +++ b/utils/cron_test.go @@ -15,10 +15,10 @@ func Test_makeRoomAvailableByTimeTable(t *testing.T) { {"1-2", setTimeFromString(today, "08:50:00"), true}, {"3-4", setTimeFromString(today, "10:45:00"), true}, {"昼", setTimeFromString(today, "12:25:00"), true}, - {"5-6", setTimeFromString(today, "13:45:00"), true}, - {"7-8", setTimeFromString(today, "15:40:00"), true}, - {"9-10", setTimeFromString(today, "17:30:00"), true}, - {":crescent_moon:", setTimeFromString(today, "19:10:00"), false}, + {"5-6", setTimeFromString(today, "13:30:00"), true}, + {"7-8", setTimeFromString(today, "15:25:00"), true}, + {"9-10", setTimeFromString(today, "17:15:00"), true}, + {":crescent_moon:", setTimeFromString(today, "18:55:00"), false}, } stampAvailable := ":white_check_mark:" @@ -33,7 +33,7 @@ func Test_makeRoomAvailableByTimeTable(t *testing.T) { Place: "traP-001", Verified: true, TimeStart: setTimeFromString(today, "08:50:00"), - TimeEnd: setTimeFromString(today, "19:10:00"), + TimeEnd: setTimeFromString(today, "18:55:00"), }, }, want: []map[string]string{ @@ -53,13 +53,13 @@ func Test_makeRoomAvailableByTimeTable(t *testing.T) { Place: "traP-001", Verified: true, TimeStart: setTimeFromString(today, "08:50:00"), - TimeEnd: setTimeFromString(today, "19:10:00"), + TimeEnd: setTimeFromString(today, "18:55:00"), }, { Place: "unverified", Verified: false, TimeStart: setTimeFromString(today, "08:50:00"), - TimeEnd: setTimeFromString(today, "19:10:00"), + TimeEnd: setTimeFromString(today, "18:55:00"), }, }, want: []map[string]string{ @@ -99,7 +99,7 @@ func Test_makeRoomAvailableByTimeTable(t *testing.T) { Place: "traP-001", Verified: true, TimeStart: setTimeFromString(today, "12:25:00"), - TimeEnd: setTimeFromString(today, "19:10:00"), + TimeEnd: setTimeFromString(today, "18:55:00"), }, { Place: "traP-002", @@ -110,8 +110,8 @@ func Test_makeRoomAvailableByTimeTable(t *testing.T) { { Place: "traP-002", Verified: true, - TimeStart: setTimeFromString(today, "13:45:00"), - TimeEnd: setTimeFromString(today, "19:10:00"), + TimeStart: setTimeFromString(today, "13:30:00"), + TimeEnd: setTimeFromString(today, "18:55:00"), }, }, want: []map[string]string{ From 8f38c3a87e7caddcd0cc77f12a48af6cdf3f3ff6 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Tue, 3 Oct 2023 10:43:35 +0900 Subject: [PATCH 2/4] =?UTF-8?q?chore:=20daily=20notify=20=E3=81=AE?= =?UTF-8?q?=E6=96=87=E9=9D=A2=E3=82=92=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/cron.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/utils/cron.go b/utils/cron.go index 7a4577cb..e58491d4 100644 --- a/utils/cron.go +++ b/utils/cron.go @@ -30,7 +30,10 @@ func InitPostEventToTraQ(repo *db.GormRepository, secret, channelID, webhookID, rooms, _ := repo.GetAllRooms(now, tomorrow, uuid.Nil) events, _ := repo.GetAllEvents(filter.FilterTime(now, tomorrow)) message := createMessage(now, rooms, events, origin) - _ = RequestWebhook(message, secret, channelID, webhookID, 1) + err := RequestWebhook(message, secret, channelID, webhookID, 1) + if err != nil { + fmt.Println(err) + } } return job @@ -106,7 +109,7 @@ func createMessage(t time.Time, rooms []*domain.Room, events []*db.Event, origin var verifiedRoomNames []string if len(rooms) == 0 { - roomMessage = fmt.Sprintf("%sの進捗部屋は、予約を取っていないようです。\n", date) + roomMessage = fmt.Sprintf("本日は予約を取っていないようです。\n") } else { for _, room := range rooms { if room.Verified && !slices.Contains(verifiedRoomNames, room.Place) { @@ -115,7 +118,7 @@ func createMessage(t time.Time, rooms []*domain.Room, events []*db.Event, origin } if len(verifiedRoomNames) == 0 { - roomMessage = fmt.Sprintf("%sの進捗部屋は、予約を取っていないようです。\n", date) + roomMessage = fmt.Sprintf("本日は予約を取っていないようです。\n") } else { timeTables := []timeTable{ {":sunny:", setTimeFromString(t, "00:00:00"), false}, @@ -166,5 +169,7 @@ func createMessage(t time.Time, rooms []*domain.Room, events []*db.Event, origin } } - return roomMessage + eventMessage + + message := fmt.Sprintf("## %s の進捗部屋\n%s## %s 開催予定のイベント\n%s", date, roomMessage, date, eventMessage) + return message } From 9120f3c8f16785a211c8971d04dda6550cde505e Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Tue, 3 Oct 2023 11:06:48 +0900 Subject: [PATCH 3/4] lint: fix lint --- utils/cron.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/cron.go b/utils/cron.go index e58491d4..4a1655c0 100644 --- a/utils/cron.go +++ b/utils/cron.go @@ -109,7 +109,7 @@ func createMessage(t time.Time, rooms []*domain.Room, events []*db.Event, origin var verifiedRoomNames []string if len(rooms) == 0 { - roomMessage = fmt.Sprintf("本日は予約を取っていないようです。\n") + roomMessage = "本日は予約を取っていないようです。\n" } else { for _, room := range rooms { if room.Verified && !slices.Contains(verifiedRoomNames, room.Place) { @@ -118,7 +118,7 @@ func createMessage(t time.Time, rooms []*domain.Room, events []*db.Event, origin } if len(verifiedRoomNames) == 0 { - roomMessage = fmt.Sprintf("本日は予約を取っていないようです。\n") + roomMessage = "本日は予約を取っていないようです。\n" } else { timeTables := []timeTable{ {":sunny:", setTimeFromString(t, "00:00:00"), false}, From 0562d6c08b1514101418c4816d1b8fd9830d0758 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Thu, 5 Oct 2023 14:15:17 +0900 Subject: [PATCH 4/4] =?UTF-8?q?refactor:=20=E5=A4=89=E6=95=B0=E3=82=92?= =?UTF-8?q?=E4=BB=8B=E3=81=95=E3=81=9A=E7=9B=B4=E6=8E=A5=E8=BF=94=E3=81=99?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/cron.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/utils/cron.go b/utils/cron.go index 4a1655c0..7edb6e52 100644 --- a/utils/cron.go +++ b/utils/cron.go @@ -170,6 +170,5 @@ func createMessage(t time.Time, rooms []*domain.Room, events []*db.Event, origin } - message := fmt.Sprintf("## %s の進捗部屋\n%s## %s 開催予定のイベント\n%s", date, roomMessage, date, eventMessage) - return message + return fmt.Sprintf("## %s の進捗部屋\n%s## %s 開催予定のイベント\n%s", date, roomMessage, date, eventMessage) }