Skip to content

Commit

Permalink
DB fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aceberg committed Oct 6, 2023
1 parent a4a0fb2 commit c11e7a6
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions internal/db/sqlite.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package db

import (
"log"
"sync"

"github.com/jmoiron/sqlx"
Expand Down Expand Up @@ -40,17 +39,15 @@ func Select(path string) (dbHosts []models.Host) {
err := db.Select(&dbHosts, sqlStatement)
mu.Unlock()

if err != nil {
log.Fatal("ERROR: db.Select: ", err)
}
check.IfError(err)

return dbHosts
}

// SelectHist - select all history
func SelectHist(path string) (hist []models.History) {

sqlStatement := `SELECT * FROM "history" ORDER BY DATE DESC`
sqlStatement := `SELECT * FROM "history" ORDER BY ID DESC`

mu.Lock()
db, _ := sqlx.Connect("sqlite", path)
Expand All @@ -59,9 +56,7 @@ func SelectHist(path string) (hist []models.History) {
err := db.Select(&hist, sqlStatement)
mu.Unlock()

if err != nil {
log.Fatal("ERROR: db.SelectHist: ", err)
}
check.IfError(err)

return hist
}

0 comments on commit c11e7a6

Please sign in to comment.