Change game day to Wednesday

main
William Perron 2 months ago
parent 2b3ff1aa04
commit 589ef1a207
No known key found for this signature in database
GPG Key ID: F701727E6034EEC9

@ -1,15 +1,15 @@
FROM golang:1.21-bullseye as builder FROM golang:1.21-bullseye AS builder
WORKDIR /app WORKDIR /app
COPY . . COPY . .
RUN mkdir ./bin; go build -buildvcs=false -o ./bin ./cmd/... RUN mkdir ./bin; go build -buildvcs=false -o ./bin ./cmd/...
FROM ubuntu:23.10 as litestream FROM ubuntu:24.04 AS litestream
WORKDIR /download WORKDIR /download
RUN apt update -y && apt install -y wget tar 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; \ 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; tar -zxf litestream-v0.3.9-linux-amd64.tar.gz;
FROM ubuntu:23.10 FROM ubuntu:24.04
WORKDIR /themis WORKDIR /themis
COPY --from=builder /app/bin/themis-server /usr/local/bin/themis-server COPY --from=builder /app/bin/themis-server /usr/local/bin/themis-server
COPY --from=litestream /download/litestream /usr/local/bin/litestream COPY --from=litestream /download/litestream /usr/local/bin/litestream

@ -18,7 +18,7 @@ func TestAddAbsence(t *testing.T) {
store, err := NewStore(db, zerolog.Nop()) store, err := NewStore(db, zerolog.Nop())
require.NoError(t, err) require.NoError(t, err)
now := NextMonday() now := NextWednesday()
assert.NoError(t, store.AddAbsence(context.TODO(), now, "foobarbaz")) assert.NoError(t, store.AddAbsence(context.TODO(), now, "foobarbaz"))
absentees, err := store.GetAbsentees(context.TODO(), now) absentees, err := store.GetAbsentees(context.TODO(), now)
assert.NoError(t, err) assert.NoError(t, err)
@ -40,7 +40,7 @@ func TestGetSchedule(t *testing.T) {
store, err := NewStore(db, zerolog.Nop()) store, err := NewStore(db, zerolog.Nop())
require.NoError(t, err) require.NoError(t, err)
now := NextMonday() now := NextWednesday()
_ = store.AddAbsence(context.TODO(), now.Add(7*24*time.Hour), "foobar") _ = store.AddAbsence(context.TODO(), now.Add(7*24*time.Hour), "foobar")

@ -581,7 +581,7 @@ func main() {
}, },
"schedule": func(ctx context.Context, s *discordgo.Session, i *discordgo.InteractionCreate) error { "schedule": func(ctx context.Context, s *discordgo.Session, i *discordgo.InteractionCreate) error {
// get schedule from now to 4 mondays into the future // 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 != nil {
if err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ if err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource, Type: discordgo.InteractionResponseChannelMessageWithSource,
@ -643,7 +643,7 @@ func main() {
"absent": func(ctx context.Context, s *discordgo.Session, i *discordgo.InteractionCreate) error { "absent": func(ctx context.Context, s *discordgo.Session, i *discordgo.InteractionCreate) error {
var rawDate string var rawDate string
if len(i.ApplicationCommandData().Options) == 0 { if len(i.ApplicationCommandData().Options) == 0 {
rawDate = themis.NextMonday().Format(time.DateOnly) rawDate = themis.NextWednesday().Format(time.DateOnly)
} else { } else {
rawDate = i.ApplicationCommandData().Options[0].StringValue() rawDate = i.ApplicationCommandData().Options[0].StringValue()
} }
@ -739,7 +739,7 @@ func main() {
defer span.End() defer span.End()
log.Info().Msg("sending weekly reminder") log.Info().Msg("sending weekly reminder")
absentees, err := store.GetAbsentees(ctx, themis.NextMonday()) absentees, err := store.GetAbsentees(ctx, themis.NextWednesday())
if err != nil { if err != nil {
log.Error().Err(err).Msg("failed to get absentees for next session") log.Error().Err(err).Msg("failed to get absentees for next session")
return return
@ -884,7 +884,7 @@ func registerHandlers(sess *discordgo.Session, handlers map[string]Handler) {
userId := i.Member.User.ID userId := i.Member.User.ID
log.Info().Ctx(ctx).Str("message_component", "schedule-response").Str("userid", userId).Msg("handling message component interaction") 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{ if err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource, Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{ Data: &discordgo.InteractionResponseData{

@ -26,8 +26,8 @@ func NewNotifier(c chan context.Context) *Notifier {
} }
func (n *Notifier) Start(ctx context.Context) { func (n *Notifier) Start(ctx context.Context) {
m := NextMonday() m := NextWednesday()
sat := m.AddDate(0, 0, -2) sat := m.AddDate(0, 0, -4)
if sat.Before(time.Now()) { if sat.Before(time.Now()) {
sat = sat.AddDate(0, 0, 7) sat = sat.AddDate(0, 0, 7)
} }

@ -11,3 +11,7 @@ func init() {
func NextMonday() time.Time { func NextMonday() time.Time {
return now().AddDate(0, 0, int((8-now().Weekday())%7)) return now().AddDate(0, 0, int((8-now().Weekday())%7))
} }
func NextWednesday() time.Time {
return now().AddDate(0, 0, int((10-now().Weekday())%7))
}

Loading…
Cancel
Save