Improve Stats group by
This commit is contained in:
parent
cd78de96b4
commit
2e360f4b20
1 changed files with 6 additions and 6 deletions
|
@ -69,7 +69,7 @@ func generateStats(ctx context.Context) ([]ChartData, error) {
|
|||
`SELECT COALESCE(jsonb_path_query_first(ffprobe_data, '$.streams[*] ? (@.codec_type == "video") ? (@.disposition.attached_pic == 0).codec_name')::text, 'Unknown') AS name, COUNT(*) AS value
|
||||
FROM files
|
||||
WHERE ffprobe_data IS NOT NULL
|
||||
GROUP BY jsonb_path_query_first(ffprobe_data, '$.streams[*] ? (@.codec_type == "video") ? (@.disposition.attached_pic == 0).codec_name');`)
|
||||
GROUP BY 1;`)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Query Codecs: %w", err)
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ func generateStats(ctx context.Context) ([]ChartData, error) {
|
|||
`SELECT COALESCE(jsonb_path_query_first(ffprobe_data, '$.streams[*] ? (@.codec_type == "video") ? (@.disposition.attached_pic == 0).width')::text, 'Unknown') AS name, COUNT(*) AS value
|
||||
FROM files
|
||||
WHERE ffprobe_data IS NOT NULL
|
||||
GROUP BY jsonb_path_query_first(ffprobe_data, '$.streams[*] ? (@.codec_type == "video") ? (@.disposition.attached_pic == 0).width');`)
|
||||
GROUP BY 1;`)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Query Resolution: %w", err)
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ func generateStats(ctx context.Context) ([]ChartData, error) {
|
|||
`SELECT COALESCE(jsonb_path_query_first(ffprobe_data, '$.format.format_name')::text, 'Unknown') AS name, COUNT(*) AS value
|
||||
FROM files
|
||||
WHERE ffprobe_data IS NOT NULL
|
||||
GROUP BY jsonb_path_query_first(ffprobe_data, '$.format.format_name');`)
|
||||
GROUP BY 1;`)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Query Container: %w", err)
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ func generateStats(ctx context.Context) ([]ChartData, error) {
|
|||
rows, err = db.Query(ctx,
|
||||
`SELECT health AS id, COUNT(*) AS value
|
||||
FROM files
|
||||
GROUP BY health;`)
|
||||
GROUP BY 1;`)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Query Health: %w", err)
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ func generateStats(ctx context.Context) ([]ChartData, error) {
|
|||
rows, err = db.Query(ctx,
|
||||
`SELECT transcode AS id, COUNT(*) AS value
|
||||
FROM files
|
||||
GROUP BY transcode;`)
|
||||
GROUP BY 1;`)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Query Transcode: %w", err)
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ func generateStats(ctx context.Context) ([]ChartData, error) {
|
|||
rows, err = db.Query(ctx,
|
||||
`SELECT status AS id, COUNT(*) AS value
|
||||
FROM tasks
|
||||
GROUP BY status;`)
|
||||
GROUP BY 1;`)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Query Task Status: %w", err)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue