Use Library Size for Counter
This commit is contained in:
parent
595efd0c66
commit
4153e48eb3
1 changed files with 9 additions and 4 deletions
|
@ -22,8 +22,6 @@ type IndexWorker struct {
|
|||
Status *types.WorkerStatus
|
||||
}
|
||||
|
||||
var count = 123456789
|
||||
|
||||
type Task struct {
|
||||
ID int `db:"id"`
|
||||
Library int `db:"library"`
|
||||
|
@ -36,10 +34,8 @@ type Task struct {
|
|||
func handleIndex(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
data := IndexData{
|
||||
Counter: splitInt(count),
|
||||
Workers: []IndexWorker{},
|
||||
}
|
||||
count++
|
||||
func() {
|
||||
WorkersMutex.Lock()
|
||||
defer WorkersMutex.Unlock()
|
||||
|
@ -66,6 +62,15 @@ func handleIndex(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}()
|
||||
|
||||
var size int
|
||||
err := db.QueryRow(r.Context(), "SELECT SUM(size) AS size FROM files WHERE missing = $1", false).Scan(&size)
|
||||
if err != nil {
|
||||
slog.ErrorContext(r.Context(), "Query File Size Sum", "err", err)
|
||||
http.Error(w, "Error Query File Size Sum: "+err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
data.Counter = splitInt(size)
|
||||
|
||||
rows, err := db.Query(r.Context(), "SELECT t.id AS id, l.id AS library, t.worker_id AS worker, t.type AS type, t.status AS status, f.path AS file FROM tasks t INNER JOIN files f ON f.id = t.file_id INNER JOIN libraries l ON l.id = f.library_id")
|
||||
if err != nil {
|
||||
slog.ErrorContext(r.Context(), "Query Tasks", "err", err)
|
||||
|
|
Loading…
Add table
Reference in a new issue