mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-28 10:32:55 +01:00
feat(channelserver): add daily noon resets for gacha stepup and guild RP
Gacha stepup progress now resets when queried after the most recent noon boundary, using a new created_at column on gacha_stepup. Guild member rp_today rolls into rp_yesterday lazily when members are enumerated after noon, using a new rp_reset_at column on guilds. Both follow the established lazy-reset pattern from the cafe handler.
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package channelserver
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
@@ -96,6 +100,21 @@ func (r *GachaRepository) GetStepupStep(gachaID uint32, charID uint32) (uint8, e
|
||||
return step, err
|
||||
}
|
||||
|
||||
// GetStepupWithTime returns the current step and creation time for a stepup entry.
|
||||
// Returns sql.ErrNoRows if no entry exists.
|
||||
func (r *GachaRepository) GetStepupWithTime(gachaID uint32, charID uint32) (uint8, time.Time, error) {
|
||||
var step uint8
|
||||
var createdAt time.Time
|
||||
err := r.db.QueryRow(
|
||||
`SELECT step, COALESCE(created_at, '2000-01-01'::timestamptz) FROM gacha_stepup WHERE gacha_id = $1 AND character_id = $2`,
|
||||
gachaID, charID,
|
||||
).Scan(&step, &createdAt)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return 0, time.Time{}, err
|
||||
}
|
||||
return step, createdAt, err
|
||||
}
|
||||
|
||||
// HasEntryType returns whether a gacha has any entries of the given type.
|
||||
func (r *GachaRepository) HasEntryType(gachaID uint32, entryType uint8) (bool, error) {
|
||||
var count int
|
||||
|
||||
Reference in New Issue
Block a user