feat: store last seen date for users and present in stats and user lists, closes #9007

This commit is contained in:
Torkel Ödegaard
2017-08-09 10:36:41 +02:00
parent 26ad025705
commit e8a20643d6
15 changed files with 249 additions and 84 deletions
+20 -7
View File
@@ -33,8 +33,9 @@ type User struct {
IsAdmin bool
OrgId int64
Created time.Time
Updated time.Time
Created time.Time
Updated time.Time
LastSeenAt time.Time
}
func (u *User) NameOrFallback() string {
@@ -127,6 +128,7 @@ type GetUserProfileQuery struct {
}
type SearchUsersQuery struct {
OrgId int64
Query string
Page int
Limit int
@@ -160,6 +162,15 @@ type SignedInUser struct {
ApiKeyId int64
IsGrafanaAdmin bool
HelpFlags1 HelpFlags1
LastSeenAt time.Time
}
func (u *SignedInUser) ShouldUpdateLastSeenAt() bool {
return u.UserId > 0 && time.Since(u.LastSeenAt) > time.Minute*5
}
type UpdateUserLastSeenAtCommand struct {
UserId int64
}
type UserProfileDTO struct {
@@ -173,11 +184,13 @@ type UserProfileDTO struct {
}
type UserSearchHitDTO struct {
Id int64 `json:"id"`
Name string `json:"name"`
Login string `json:"login"`
Email string `json:"email"`
IsAdmin bool `json:"isAdmin"`
Id int64 `json:"id"`
Name string `json:"name"`
Login string `json:"login"`
Email string `json:"email"`
IsAdmin bool `json:"isAdmin"`
LastSeenAt time.Time `json:"lastSeenAt"`
LastSeenAtAge string `json:"lastSeenAtAge"`
}
type UserIdDTO struct {