// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.29.0 // source: events_stat.sql package dbgen import ( "context" "github.com/jackc/pgx/v5/pgtype" ) const GetTotalMontlyEventStat = `-- name: GetTotalMontlyEventStat :many SELECT DATE_TRUNC('month', start_time) AS month, COUNT(*) AS event_count FROM events JOIN leagues ON leagues.id = events.league_id WHERE ( events.is_featured = $1 OR $1 IS NULL ) AND ( leagues.is_featured = $2 OR $2 IS NULL ) AND ( events.league_id = $3 OR $3 IS NULL ) GROUP BY month ORDER BY month ` type GetTotalMontlyEventStatParams struct { IsEventFeatured pgtype.Bool `json:"is_event_featured"` IsLeagueFeatured pgtype.Bool `json:"is_league_featured"` LeagueID pgtype.Int4 `json:"league_id"` } type GetTotalMontlyEventStatRow struct { Month pgtype.Interval `json:"month"` EventCount int64 `json:"event_count"` } func (q *Queries) GetTotalMontlyEventStat(ctx context.Context, arg GetTotalMontlyEventStatParams) ([]GetTotalMontlyEventStatRow, error) { rows, err := q.db.Query(ctx, GetTotalMontlyEventStat, arg.IsEventFeatured, arg.IsLeagueFeatured, arg.LeagueID) if err != nil { return nil, err } defer rows.Close() var items []GetTotalMontlyEventStatRow for rows.Next() { var i GetTotalMontlyEventStatRow if err := rows.Scan(&i.Month, &i.EventCount); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil }