diff --git a/Dockerfile b/Dockerfile index a378682..58daaa2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,15 @@ -FROM golang:1.21-bullseye as builder +FROM golang:1.21-bullseye AS builder WORKDIR /app COPY . . RUN mkdir ./bin; go build -buildvcs=false -o ./bin ./cmd/... -FROM ubuntu:23.10 as litestream +FROM ubuntu:24.04 AS litestream WORKDIR /download RUN apt update -y && apt install -y wget tar RUN wget https://github.com/benbjohnson/litestream/releases/download/v0.3.9/litestream-v0.3.9-linux-amd64.tar.gz; \ tar -zxf litestream-v0.3.9-linux-amd64.tar.gz; -FROM ubuntu:23.10 +FROM ubuntu:24.04 WORKDIR /themis COPY --from=builder /app/bin/themis-server /usr/local/bin/themis-server COPY --from=litestream /download/litestream /usr/local/bin/litestream diff --git a/absences_test.go b/absences_test.go index 24d5dff..5cce5b0 100644 --- a/absences_test.go +++ b/absences_test.go @@ -18,7 +18,7 @@ func TestAddAbsence(t *testing.T) { store, err := NewStore(db, zerolog.Nop()) require.NoError(t, err) - now := NextMonday() + now := NextWednesday() assert.NoError(t, store.AddAbsence(context.TODO(), now, "foobarbaz")) absentees, err := store.GetAbsentees(context.TODO(), now) assert.NoError(t, err) @@ -40,7 +40,7 @@ func TestGetSchedule(t *testing.T) { store, err := NewStore(db, zerolog.Nop()) require.NoError(t, err) - now := NextMonday() + now := NextWednesday() _ = store.AddAbsence(context.TODO(), now.Add(7*24*time.Hour), "foobar") diff --git a/cmd/themis-server/main.go b/cmd/themis-server/main.go index 9283e4b..1175bc3 100644 --- a/cmd/themis-server/main.go +++ b/cmd/themis-server/main.go @@ -581,7 +581,7 @@ func main() { }, "schedule": func(ctx context.Context, s *discordgo.Session, i *discordgo.InteractionCreate) error { // get schedule from now to 4 mondays into the future - sched, err := store.GetSchedule(ctx, themis.NextMonday(), themis.NextMonday().Add(4*7*24*time.Hour)) + sched, err := store.GetSchedule(ctx, themis.NextWednesday(), themis.NextWednesday().Add(4*7*24*time.Hour)) if err != nil { if err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ Type: discordgo.InteractionResponseChannelMessageWithSource, @@ -643,7 +643,7 @@ func main() { "absent": func(ctx context.Context, s *discordgo.Session, i *discordgo.InteractionCreate) error { var rawDate string if len(i.ApplicationCommandData().Options) == 0 { - rawDate = themis.NextMonday().Format(time.DateOnly) + rawDate = themis.NextWednesday().Format(time.DateOnly) } else { rawDate = i.ApplicationCommandData().Options[0].StringValue() } @@ -739,7 +739,7 @@ func main() { defer span.End() log.Info().Msg("sending weekly reminder") - absentees, err := store.GetAbsentees(ctx, themis.NextMonday()) + absentees, err := store.GetAbsentees(ctx, themis.NextWednesday()) if err != nil { log.Error().Err(err).Msg("failed to get absentees for next session") return @@ -884,7 +884,7 @@ func registerHandlers(sess *discordgo.Session, handlers map[string]Handler) { userId := i.Member.User.ID log.Info().Ctx(ctx).Str("message_component", "schedule-response").Str("userid", userId).Msg("handling message component interaction") - if err := store.AddAbsence(ctx, themis.NextMonday(), userId); err != nil { + if err := store.AddAbsence(ctx, themis.NextWednesday(), userId); err != nil { if err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ Type: discordgo.InteractionResponseChannelMessageWithSource, Data: &discordgo.InteractionResponseData{ diff --git a/notify.go b/notify.go index 71f511d..791ed9d 100644 --- a/notify.go +++ b/notify.go @@ -26,8 +26,8 @@ func NewNotifier(c chan context.Context) *Notifier { } func (n *Notifier) Start(ctx context.Context) { - m := NextMonday() - sat := m.AddDate(0, 0, -2) + m := NextWednesday() + sat := m.AddDate(0, 0, -4) if sat.Before(time.Now()) { sat = sat.AddDate(0, 0, 7) } diff --git a/time.go b/time.go index 22b1eaa..dd60a99 100644 --- a/time.go +++ b/time.go @@ -11,3 +11,7 @@ func init() { func NextMonday() time.Time { return now().AddDate(0, 0, int((8-now().Weekday())%7)) } + +func NextWednesday() time.Time { + return now().AddDate(0, 0, int((10-now().Weekday())%7)) +}