[raffle] Insert newly created raffles with NULL reminder time

as MySQL 8 in opposite to MariaDB 10 does not support the time `0000-00-00 00:00:00`

fixes #51

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2023-08-26 19:11:49 +02:00
parent 29df9e59b5
commit db3c4f4efa
Signed by: luzifer
GPG key ID: D91C3E91E4CAD6F5

View file

@ -56,7 +56,7 @@ type (
TextEntryFailPost bool `json:"textEntryFailPost"` TextEntryFailPost bool `json:"textEntryFailPost"`
TextReminder string `json:"textReminder"` TextReminder string `json:"textReminder"`
TextReminderInterval time.Duration `json:"textReminderInterval"` TextReminderInterval time.Duration `json:"textReminderInterval"`
TextReminderNextSend time.Time `json:"-"` TextReminderNextSend *time.Time `json:"-"`
TextReminderPost bool `json:"textReminderPost"` TextReminderPost bool `json:"textReminderPost"`
TextWin string `json:"textWin"` TextWin string `json:"textWin"`
TextWinPost bool `json:"textWinPost"` TextWinPost bool `json:"textWinPost"`
@ -143,7 +143,7 @@ func (d *dbClient) AutoSendReminders() (err error) {
var rr []raffle var rr []raffle
if err = d.db.DB(). if err = d.db.DB().
Where("status = ? AND text_reminder_post = ? AND text_reminder_next_send < ?", raffleStatusActive, true, time.Now().UTC()). Where("status = ? AND text_reminder_post = ? AND (text_reminder_next_send IS NULL OR text_reminder_next_send < ?)", raffleStatusActive, true, time.Now().UTC()).
Find(&rr). Find(&rr).
Error; err != nil { Error; err != nil {
return errors.Wrap(err, "fetching raffles to send reminders") return errors.Wrap(err, "fetching raffles to send reminders")