forked from mtusi2026/mtusi2026lab6
47 lines
1.5 KiB
Go
47 lines
1.5 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: slo.sql
|
|
|
|
package queries
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const readySLI = `-- name: ReadySLI :one
|
|
WITH clock AS (SELECT clock_timestamp() AS now), cohort AS (
|
|
SELECT a.accepted_at,a.first_ready_at,c.now FROM attachments a CROSS JOIN clock c
|
|
WHERE a.accepted_at>c.now-interval '310 seconds' AND a.accepted_at<=c.now-interval '10 seconds'
|
|
)
|
|
SELECT count(*) FILTER(WHERE accepted_at>now-interval '20 seconds')::bigint AS matured10,
|
|
count(*) FILTER(WHERE accepted_at>now-interval '20 seconds' AND first_ready_at>=accepted_at AND first_ready_at<=accepted_at+interval '10 seconds')::bigint AS timely10,
|
|
count(*) FILTER(WHERE accepted_at>now-interval '40 seconds')::bigint AS matured30,
|
|
count(*) FILTER(WHERE accepted_at>now-interval '40 seconds' AND first_ready_at>=accepted_at AND first_ready_at<=accepted_at+interval '10 seconds')::bigint AS timely30,
|
|
count(*)::bigint AS matured300,
|
|
count(*) FILTER(WHERE first_ready_at>=accepted_at AND first_ready_at<=accepted_at+interval '10 seconds')::bigint AS timely300 FROM cohort
|
|
`
|
|
|
|
type ReadySLIRow struct {
|
|
Matured10 int64
|
|
Timely10 int64
|
|
Matured30 int64
|
|
Timely30 int64
|
|
Matured300 int64
|
|
Timely300 int64
|
|
}
|
|
|
|
func (q *Queries) ReadySLI(ctx context.Context) (ReadySLIRow, error) {
|
|
row := q.db.QueryRow(ctx, readySLI)
|
|
var i ReadySLIRow
|
|
err := row.Scan(
|
|
&i.Matured10,
|
|
&i.Timely10,
|
|
&i.Matured30,
|
|
&i.Timely30,
|
|
&i.Matured300,
|
|
&i.Timely300,
|
|
)
|
|
return i, err
|
|
}
|