feat: expose complete Iranian reporting periods
This commit is contained in:
@@ -51,7 +51,7 @@ func New(pool *pgxpool.Pool) *Service { return &Service{pool: pool, runs: map[st
|
||||
|
||||
func (s *Service) Periods(ctx context.Context) ([]Period, error) {
|
||||
var start, end time.Time
|
||||
err := s.pool.QueryRow(ctx, `SELECT date_trunc('day',min(created_at)),date_trunc('day',max(created_at))+interval '1 day' FROM payment_sessions`).Scan(&start, &end)
|
||||
err := s.pool.QueryRow(ctx, `SELECT min(created_at),max(created_at) FROM payment_sessions`).Scan(&start, &end)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("loading dataset period: %w", err)
|
||||
}
|
||||
@@ -59,10 +59,7 @@ func (s *Service) Periods(ctx context.Context) ([]Period, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("loading tehran timezone: %w", err)
|
||||
}
|
||||
period := Period{PeriodID: "dataset-all", PeriodType: "DAY", StartAt: start.UTC(), EndAt: end.UTC(),
|
||||
LocalStartAt: start.In(location), LocalEndAt: end.In(location), Timezone: "Asia/Tehran",
|
||||
JalaliLabelFA: "کل دادههای واردشده", IsComplete: true, IsDefault: true}
|
||||
return []Period{period}, nil
|
||||
return latestCompletePeriods(start, end, location), nil
|
||||
}
|
||||
|
||||
func (s *Service) Start(ctx context.Context, merchantID int64, period Period) (Run, error) {
|
||||
|
||||
Reference in New Issue
Block a user