- Removed detailed event routes from the API. - Added new report request routes for creating and fetching report requests. - Introduced new domain models for report requests, including metadata and status handling. - Implemented report request processing logic, including CSV generation for event interval reports. - Enhanced company statistics handling with new domain models and service methods. - Updated repository interfaces and implementations to support new report functionalities. - Added error handling and logging for report file operations and notifications.
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
package repository
|
|
|
|
import (
|
|
"context"
|
|
|
|
dbgen "github.com/SamuelTariku/FortuneBet-Backend/gen/db"
|
|
"github.com/SamuelTariku/FortuneBet-Backend/internal/domain"
|
|
)
|
|
|
|
func (s *Store) GetTotalEventStats(ctx context.Context, filter domain.EventStatsFilter) (domain.EventStats, error) {
|
|
stats, err := s.queries.GetTotalEventStats(ctx, dbgen.GetTotalEventStatsParams{
|
|
LeagueID: filter.LeagueID.ToPG(),
|
|
SportID: filter.SportID.ToPG(),
|
|
})
|
|
if err != nil {
|
|
return domain.EventStats{}, err
|
|
}
|
|
|
|
return domain.ConvertDBEventStats(stats), nil
|
|
}
|
|
|
|
func (s *Store) GetTotalEventStatsByInterval(ctx context.Context, filter domain.EventStatsByIntervalFilter) ([]domain.EventStatsByInterval, error) {
|
|
stats, err := s.queries.GetTotalEventStatsByInterval(ctx, dbgen.GetTotalEventStatsByIntervalParams{
|
|
Interval: filter.Interval.ToPG(),
|
|
LeagueID: filter.LeagueID.ToPG(),
|
|
SportID: filter.SportID.ToPG(),
|
|
})
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return domain.ConvertDBEventStatsByIntervalList(stats), nil
|
|
}
|
|
|
|
func (s *Store) UpdateEventBetStats(ctx context.Context) error {
|
|
return s.queries.UpdateEventBetStats(ctx)
|
|
}
|