fix: anchor growth forecasts to real Tehran date
This commit is contained in:
@@ -47,10 +47,13 @@ type Builder interface {
|
||||
Build(ctx context.Context, merchantID int64, terminalID string) (Analysis, error)
|
||||
}
|
||||
|
||||
type PostgreSQLBuilder struct{ pool *pgxpool.Pool }
|
||||
type PostgreSQLBuilder struct {
|
||||
pool *pgxpool.Pool
|
||||
now func() time.Time
|
||||
}
|
||||
|
||||
func NewPostgreSQLBuilder(pool *pgxpool.Pool) *PostgreSQLBuilder {
|
||||
return &PostgreSQLBuilder{pool: pool}
|
||||
return &PostgreSQLBuilder{pool: pool, now: time.Now}
|
||||
}
|
||||
|
||||
func (b *PostgreSQLBuilder) Build(ctx context.Context, merchantID int64, terminalID string) (Analysis, error) {
|
||||
@@ -88,7 +91,7 @@ func (b *PostgreSQLBuilder) Build(ctx context.Context, merchantID int64, termina
|
||||
if err := b.pool.QueryRow(ctx, `SELECT max(created_at AT TIME ZONE 'Asia/Tehran')::date FROM payment_sessions`).Scan(&latest); err != nil {
|
||||
return Analysis{}, fmt.Errorf("loading dataset watermark date: %w", err)
|
||||
}
|
||||
forecastStart := latest.AddDate(0, 0, 1)
|
||||
forecastStart := tehranToday(b.now())
|
||||
peer, err := b.loadPeer(ctx, merchantID, terminalID)
|
||||
if err != nil {
|
||||
return Analysis{}, err
|
||||
|
||||
Reference in New Issue
Block a user