Commit ef39ae15 authored by ale's avatar ale
Browse files

Small fixes to the /sources page

parent 88297a9f
Pipeline #20866 passed with stages
in 1 minute and 37 seconds
......@@ -7,6 +7,7 @@ import (
"fmt"
"html/template"
"io"
"log"
"net/http"
"time"
......@@ -183,7 +184,6 @@ var (
<h3>Backup size by source</h3>
// select a.dataset_source, sum(a.dataset_total_bytes) from log as a left join (select backup_id from log group by dataset_source, backup_host having backup_timestamp = max(backup_timestamp)) as b on a.backup_id = b.backup_id group by a.dataset_source;
<table>
<thead>
<tr>
......@@ -420,7 +420,7 @@ func (s *httpServer) fetchLatestBackupsBySource(ctx context.Context) ([]*latestB
var out []*latestBackup
err := retryBusy(ctx, func() error {
return withTX(ctx, s.db, func(tx *sql.Tx) error {
stmt := s.stmts.get(tx, "get_latest_backup_by_source")
stmt := s.stmts.get(tx, "get_latest_backups_by_source")
defer stmt.Close()
rows, err := stmt.Query()
......@@ -475,11 +475,13 @@ func (s *httpServer) fetchSourcesSize(ctx context.Context) ([]*sourceSize, error
func (s *httpServer) handleDebugAllSources(w http.ResponseWriter, r *http.Request) {
latest, err := s.fetchLatestBackupsBySource(r.Context())
if err != nil {
log.Printf("debug(/sources): error: %v", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
sizes, err := s.fetchSourcesSize(r.Context())
if err != nil {
log.Printf("debug(/sources): error: %v", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
......
......@@ -301,7 +301,7 @@ var statements = map[string]string{
`,
"get_latest_backups_by_source": `
SELECT
backup_id, dataset_source, backup_host, backup_timestamp
backup_id, backup_timestamp, backup_host, dataset_source
FROM log
GROUP BY dataset_source, backup_host
HAVING backup_timestamp = max(backup_timestamp)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment