Added announcement support and list migrations.

This commit is contained in:
Benjamin A. Shelton 2026-10-26 15:27:46 -06:00
commit c85a59d2ad
Signed by: zancarius
GPG key ID: 8BD42DBD6C337E01
4 changed files with 52 additions and 9 deletions

View file

@ -9,13 +9,14 @@ import (
)
type Birthday struct {
ID int `db:"id"`
UserID *int `db:"userid"`
ChatID int64 `db:"chatid"`
Name string `db:"name"`
Month int `db:"month"`
Day int `db:"day"`
Delta int `db:"leap_delta"`
ID int `db:"id"`
UserID *int `db:"userid"`
ChatID int64 `db:"chatid"`
Name string `db:"name"`
Month int `db:"month"`
Day int `db:"day"`
Delta int `db:"leap_delta"`
Announce bool `db:"announce"`
// Birthdate; computed field.
Birthdate string `db:"birthdate"`
@ -61,6 +62,7 @@ func (bm *BirthdayModel) BirthdaysThisWeek(chatid int64) ([]*Birthday, error) {
format('%02d', month), '-',
format('%02d', day))) as birthdate
from birthdays where
announce = true and
chatid = ? and
birthdate != date('now', 'localtime') and
(birthdate >= date('now', 'localtime', 'weekday 0') and
@ -89,6 +91,7 @@ func (bm *BirthdayModel) BirthdaysToday(chatid int64) ([]*Birthday, error) {
format('%02d', month), '-',
format('%02d', day))) as birthdate
from birthdays where
announce = true and
chatid = ? and
birthdate == date('now', 'localtime')
order by name;`
@ -111,7 +114,7 @@ func (bm *BirthdayModel) BirthdaysToday(chatid int64) ([]*Birthday, error) {
func (bm *BirthdayModel) ListBirthdays(chatid int64) ([]*Birthday, error) {
var bdays []*Birthday
q := `select
id, userid, chatid, name, leap_delta,
id, userid, chatid, name, announce, leap_delta,
date(concat(strftime('%Y',
date('now', 'localtime')), '-',
format('%02d', month), '-',