forked from mtusi2026/mtusi2026lab6
30 lines
766 B
Go
30 lines
766 B
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: observability.sql
|
|
|
|
package queries
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const pipelineMetrics = `-- name: PipelineMetrics :one
|
|
SELECT count(*)::bigint AS depth,
|
|
COALESCE(EXTRACT(EPOCH FROM clock_timestamp()-min(j.created_at)),0)::float8 AS oldest
|
|
FROM attachments a JOIN attachment_jobs j ON j.attachment_id=a.id AND j.pipeline_version=a.pipeline_version
|
|
WHERE a.status IN ('queued','processing') AND NOT j.completed
|
|
`
|
|
|
|
type PipelineMetricsRow struct {
|
|
Depth int64
|
|
Oldest float64
|
|
}
|
|
|
|
func (q *Queries) PipelineMetrics(ctx context.Context) (PipelineMetricsRow, error) {
|
|
row := q.db.QueryRow(ctx, pipelineMetrics)
|
|
var i PipelineMetricsRow
|
|
err := row.Scan(&i.Depth, &i.Oldest)
|
|
return i, err
|
|
}
|