update sqlc gen
This commit is contained in:
parent
bec22dd0b5
commit
1b82e14c43
@ -59,6 +59,46 @@ func (q *Queries) AccountPagination(ctx context.Context, arg AccountPaginationPa
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const allServiceStatistics = `-- name: AllServiceStatistics :one
|
||||
WITH Registrations AS (
|
||||
SELECT COUNT(*) AS registration_count
|
||||
FROM account
|
||||
WHERE created_at >= to_timestamp($1) AND created_at <= to_timestamp($2)
|
||||
),
|
||||
Quizes AS (
|
||||
SELECT COUNT(*) AS quiz_count
|
||||
FROM quiz
|
||||
WHERE deleted = false AND created_at >= to_timestamp($1) AND created_at <= to_timestamp($2)
|
||||
),
|
||||
Results AS (
|
||||
SELECT COUNT(*) AS result_count
|
||||
FROM answer
|
||||
WHERE result = true AND created_at >= to_timestamp($1) AND created_at <= to_timestamp($2)
|
||||
)
|
||||
SELECT
|
||||
(SELECT registration_count FROM Registrations) AS registrations,
|
||||
(SELECT quiz_count FROM Quizes) AS quizes,
|
||||
(SELECT result_count FROM Results) AS results
|
||||
`
|
||||
|
||||
type AllServiceStatisticsParams struct {
|
||||
ToTimestamp float64 `db:"to_timestamp" json:"to_timestamp"`
|
||||
ToTimestamp_2 float64 `db:"to_timestamp_2" json:"to_timestamp_2"`
|
||||
}
|
||||
|
||||
type AllServiceStatisticsRow struct {
|
||||
Registrations int64 `db:"registrations" json:"registrations"`
|
||||
Quizes int64 `db:"quizes" json:"quizes"`
|
||||
Results int64 `db:"results" json:"results"`
|
||||
}
|
||||
|
||||
func (q *Queries) AllServiceStatistics(ctx context.Context, arg AllServiceStatisticsParams) (AllServiceStatisticsRow, error) {
|
||||
row := q.db.QueryRowContext(ctx, allServiceStatistics, arg.ToTimestamp, arg.ToTimestamp_2)
|
||||
var i AllServiceStatisticsRow
|
||||
err := row.Scan(&i.Registrations, &i.Quizes, &i.Results)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const archiveQuiz = `-- name: ArchiveQuiz :exec
|
||||
UPDATE quiz SET archived = true WHERE id=$1 AND accountId=$2
|
||||
`
|
||||
|
Loading…
Reference in New Issue
Block a user