diff options
| author | Xe Iaso <me@xeiaso.net> | 2024-05-24 15:01:03 -0400 |
|---|---|---|
| committer | Xe Iaso <me@xeiaso.net> | 2024-05-24 15:32:00 -0400 |
| commit | 29d67647732f554e03a2a95164365a6ad8c825f7 (patch) | |
| tree | c034e0f01d9b750d605a2c8e382f9cf84e0735ed /cmd/mi/models | |
| parent | 1a8ffb24870c5371023a8ce2202c30b7143264a6 (diff) | |
| download | x-29d67647732f554e03a2a95164365a6ad8c825f7.tar.xz x-29d67647732f554e03a2a95164365a6ad8c825f7.zip | |
cmd/mi/models: fix querying past switches
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'cmd/mi/models')
| -rw-r--r-- | cmd/mi/models/dao.go | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/cmd/mi/models/dao.go b/cmd/mi/models/dao.go index 2d77b98..e747a0d 100644 --- a/cmd/mi/models/dao.go +++ b/cmd/mi/models/dao.go @@ -11,19 +11,12 @@ import ( "github.com/ncruces/go-sqlite3/gormlite" "github.com/oklog/ulid/v2" slogGorm "github.com/orandin/slog-gorm" - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/client_golang/prometheus/promauto" "gorm.io/gorm" gormPrometheus "gorm.io/plugin/prometheus" ) var ( ErrCantSwitchToYourself = errors.New("models: you can't switch to yourself") - - pingCount = promauto.NewGauge(prometheus.GaugeOpts{ - Name: "mi_db_ping", - Help: "Number of times the database has been pinged.", - }) ) type DAO struct { @@ -39,8 +32,6 @@ func (d *DAO) Ping(ctx context.Context) error { return err } - pingCount.Inc() - return nil } @@ -145,7 +136,7 @@ func (d *DAO) ListSwitches(ctx context.Context, count, page int) ([]Switch, erro var switches []Switch if err := d.db.WithContext(ctx). Joins("Member"). - Order("rowid DESC"). + Order("created_at DESC"). Limit(count). Offset(count * page). Find(&switches).Error; err != nil { |
