1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

feat: per-user heartbeats count metrics

This commit is contained in:
Ferdinand Mütsch
2021-02-12 23:06:48 +01:00
parent 703805412b
commit 301cab4be4
8 changed files with 148 additions and 61 deletions

View File

@@ -4,6 +4,7 @@ import (
"errors"
"github.com/muety/wakapi/models"
"gorm.io/gorm"
"time"
)
type UserRepository struct {
@@ -40,6 +41,16 @@ func (r *UserRepository) GetAll() ([]*models.User, error) {
return users, nil
}
func (r *UserRepository) GetByLoggedInAfter(t time.Time) ([]*models.User, error) {
var users []*models.User
if err := r.db.
Where("last_logged_in_at >= ?", t).
Find(&users).Error; err != nil {
return nil, err
}
return users, nil
}
func (r *UserRepository) Count() (int64, error) {
var count int64
if err := r.db.