fix: sync sadhna calendar with local timezone
This commit is contained in:
@@ -15,6 +15,20 @@ type SadhnaRepo struct{ pg *Postgres }
|
||||
|
||||
func NewSadhnaRepo(pg *Postgres) *SadhnaRepo { return &SadhnaRepo{pg: pg} }
|
||||
|
||||
// UserTimezone returns the user's stored IANA timezone, or "" if unset — the
|
||||
// caller falls back to a default. Kept here so the sādhana day boundary can
|
||||
// be the user's local midnight.
|
||||
func (r *SadhnaRepo) UserTimezone(ctx context.Context, userID string) (string, error) {
|
||||
var tz string
|
||||
err := r.pg.Pool.QueryRow(ctx,
|
||||
`SELECT COALESCE(NULLIF(timezone, ''), '') FROM users WHERE id = $1`, userID,
|
||||
).Scan(&tz)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return tz, nil
|
||||
}
|
||||
|
||||
// UpsertToday records (or updates) the given day's chanting progress for
|
||||
// the user. The caller passes the UTC calendar date explicitly (rather
|
||||
// than relying on the DB's CURRENT_DATE) so day bucketing stays identical
|
||||
|
||||
Reference in New Issue
Block a user