optimize user information filling
This commit is contained in:
parent
c4b5d13348
commit
01420ff1d8
|
@ -314,6 +314,12 @@ func TeamGets(query string, limit, offset int) ([]Team, error) {
|
||||||
return objs, err
|
return objs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func AllTeams() ([]Team, error) {
|
||||||
|
var teams []Team
|
||||||
|
err := DB["rdb"].Find(&teams)
|
||||||
|
return teams, err
|
||||||
|
}
|
||||||
|
|
||||||
func TeamGetsInIds(ids []int64, query string, limit, offset int) ([]Team, error) {
|
func TeamGetsInIds(ids []int64, query string, limit, offset int) ([]Team, error) {
|
||||||
session := DB["rdb"].In("id", ids).Limit(limit, offset).OrderBy("ident")
|
session := DB["rdb"].In("id", ids).Limit(limit, offset).OrderBy("ident")
|
||||||
if query != "" {
|
if query != "" {
|
||||||
|
|
|
@ -3,7 +3,6 @@ package models
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -680,29 +679,6 @@ func (u *User) NopriResIdents(resIds []int64, op string) ([]string, error) {
|
||||||
return ResourceIdentsByIds(nopris)
|
return ResourceIdentsByIds(nopris)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetUsersNameByIds(ids string) ([]string, error) {
|
|
||||||
var names []string
|
|
||||||
ids = strings.Replace(ids, "[", "", -1)
|
|
||||||
ids = strings.Replace(ids, "]", "", -1)
|
|
||||||
idsStrArr := strings.Split(ids, ",")
|
|
||||||
|
|
||||||
userIds := []int64{}
|
|
||||||
for _, userId := range idsStrArr {
|
|
||||||
id, _ := strconv.ParseInt(userId, 10, 64)
|
|
||||||
userIds = append(userIds, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
users, err := UserGetByIds(userIds)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return names, err
|
|
||||||
}
|
|
||||||
for _, user := range users {
|
|
||||||
names = append(names, user.Username)
|
|
||||||
}
|
|
||||||
return names, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func UsersGet(where string, args ...interface{}) ([]User, error) {
|
func UsersGet(where string, args ...interface{}) ([]User, error) {
|
||||||
var objs []User
|
var objs []User
|
||||||
err := DB["rdb"].Where(where, args...).Find(&objs)
|
err := DB["rdb"].Where(where, args...).Find(&objs)
|
||||||
|
|
|
@ -27,6 +27,11 @@ func Init(regions []string) {
|
||||||
ApiCollectCache = NewApiCollectCache()
|
ApiCollectCache = NewApiCollectCache()
|
||||||
SnmpCollectCache = NewSnmpCollectCache()
|
SnmpCollectCache = NewSnmpCollectCache()
|
||||||
SnmpHWCache = NewSnmpHWCache()
|
SnmpHWCache = NewSnmpHWCache()
|
||||||
|
TeamUsersCache = NewTeamUsersCache()
|
||||||
|
TeamCache = NewTeamCache()
|
||||||
|
UserCache = NewUserCache()
|
||||||
|
TreeNodeCache = NewTreeNodeCache()
|
||||||
|
|
||||||
LoadMetrics()
|
LoadMetrics()
|
||||||
|
|
||||||
go InitJudgeHashRing()
|
go InitJudgeHashRing()
|
||||||
|
|
|
@ -11,7 +11,7 @@ type TeamUsersMap struct {
|
||||||
|
|
||||||
var TeamUsersCache *TeamUsersMap
|
var TeamUsersCache *TeamUsersMap
|
||||||
|
|
||||||
func NewTeamCache() *TeamUsersMap {
|
func NewTeamUsersCache() *TeamUsersMap {
|
||||||
return &TeamUsersMap{Data: make(map[int64][]int64)}
|
return &TeamUsersMap{Data: make(map[int64][]int64)}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,9 +27,13 @@ func (s *TeamUsersMap) GetByTeamIds(ids []int64) []int64 {
|
||||||
defer s.RUnlock()
|
defer s.RUnlock()
|
||||||
m := make(map[int64]struct{})
|
m := make(map[int64]struct{})
|
||||||
var userIds []int64
|
var userIds []int64
|
||||||
|
|
||||||
for _, id := range ids {
|
for _, id := range ids {
|
||||||
m[id] = struct{}{}
|
for _, uid := range s.Data[id] {
|
||||||
|
m[uid] = struct{}{}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for id, _ := range m {
|
for id, _ := range m {
|
||||||
userIds = append(userIds, id)
|
userIds = append(userIds, id)
|
||||||
}
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
package cache
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/didi/nightingale/v4/src/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
type TeamMap struct {
|
||||||
|
sync.RWMutex
|
||||||
|
Data map[int64]*models.Team
|
||||||
|
}
|
||||||
|
|
||||||
|
var TeamCache *TeamMap
|
||||||
|
|
||||||
|
func NewTeamCache() *TeamMap {
|
||||||
|
return &TeamMap{Data: make(map[int64]*models.Team)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *TeamMap) GetBy(id int64) *models.Team {
|
||||||
|
s.RLock()
|
||||||
|
defer s.RUnlock()
|
||||||
|
|
||||||
|
return s.Data[id]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *TeamMap) GetByIds(ids []int64) []*models.Team {
|
||||||
|
s.RLock()
|
||||||
|
defer s.RUnlock()
|
||||||
|
var objs []*models.Team
|
||||||
|
for _, id := range ids {
|
||||||
|
if s.Data[id] == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
objs = append(objs, s.Data[id])
|
||||||
|
}
|
||||||
|
|
||||||
|
return objs
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *TeamMap) SetAll(objs map[int64]*models.Team) {
|
||||||
|
s.Lock()
|
||||||
|
defer s.Unlock()
|
||||||
|
|
||||||
|
s.Data = objs
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *TeamMap) GetTeamNamesByIds(ids string) []string {
|
||||||
|
var names []string
|
||||||
|
ids = strings.Replace(ids, "[", "", -1)
|
||||||
|
ids = strings.Replace(ids, "]", "", -1)
|
||||||
|
idsStrArr := strings.Split(ids, ",")
|
||||||
|
|
||||||
|
teamIds := []int64{}
|
||||||
|
for _, teamId := range idsStrArr {
|
||||||
|
id, _ := strconv.ParseInt(teamId, 10, 64)
|
||||||
|
teamIds = append(teamIds, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
objs := s.GetByIds(teamIds)
|
||||||
|
for _, obj := range objs {
|
||||||
|
names = append(names, obj.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
return names
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
package cache
|
package cache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/didi/nightingale/v4/src/models"
|
"github.com/didi/nightingale/v4/src/models"
|
||||||
|
@ -29,6 +31,9 @@ func (s *UserMap) GetByIds(ids []int64) []*models.User {
|
||||||
defer s.RUnlock()
|
defer s.RUnlock()
|
||||||
var users []*models.User
|
var users []*models.User
|
||||||
for _, id := range ids {
|
for _, id := range ids {
|
||||||
|
if s.Data[id] == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
users = append(users, s.Data[id])
|
users = append(users, s.Data[id])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,3 +47,23 @@ func (s *UserMap) SetAll(users map[int64]*models.User) {
|
||||||
s.Data = users
|
s.Data = users
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *UserMap) GetUsernamesByIds(ids string) []string {
|
||||||
|
var names []string
|
||||||
|
ids = strings.Replace(ids, "[", "", -1)
|
||||||
|
ids = strings.Replace(ids, "]", "", -1)
|
||||||
|
idsStrArr := strings.Split(ids, ",")
|
||||||
|
|
||||||
|
userIds := []int64{}
|
||||||
|
for _, userId := range idsStrArr {
|
||||||
|
id, _ := strconv.ParseInt(userId, 10, 64)
|
||||||
|
userIds = append(userIds, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
users := s.GetByIds(userIds)
|
||||||
|
for _, user := range users {
|
||||||
|
names = append(names, user.Username)
|
||||||
|
}
|
||||||
|
|
||||||
|
return names
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
package cache
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/didi/nightingale/v4/src/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
type TreeNodeMap struct {
|
||||||
|
sync.RWMutex
|
||||||
|
Data map[int64]*models.Node
|
||||||
|
}
|
||||||
|
|
||||||
|
var TreeNodeCache *TreeNodeMap
|
||||||
|
|
||||||
|
func NewTreeNodeCache() *TreeNodeMap {
|
||||||
|
return &TreeNodeMap{Data: make(map[int64]*models.Node)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TreeNodeMap) GetBy(id int64) *models.Node {
|
||||||
|
t.RLock()
|
||||||
|
defer t.RUnlock()
|
||||||
|
|
||||||
|
return t.Data[id]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TreeNodeMap) GetByIds(ids []int64) []*models.Node {
|
||||||
|
t.RLock()
|
||||||
|
defer t.RUnlock()
|
||||||
|
var objs []*models.Node
|
||||||
|
for _, id := range ids {
|
||||||
|
objs = append(objs, t.Data[id])
|
||||||
|
}
|
||||||
|
|
||||||
|
return objs
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TreeNodeMap) SetAll(objs map[int64]*models.Node) {
|
||||||
|
t.Lock()
|
||||||
|
defer t.Unlock()
|
||||||
|
|
||||||
|
t.Data = objs
|
||||||
|
return
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ func Init() {
|
||||||
go CleanStraLoop()
|
go CleanStraLoop()
|
||||||
go SyncCollects()
|
go SyncCollects()
|
||||||
go SyncUsers()
|
go SyncUsers()
|
||||||
|
go SyncTeams()
|
||||||
go SyncTeamUsers()
|
go SyncTeamUsers()
|
||||||
go CleanCollectLoop()
|
go CleanCollectLoop()
|
||||||
|
|
||||||
|
|
|
@ -8,31 +8,28 @@ import (
|
||||||
"github.com/toolkits/pkg/logger"
|
"github.com/toolkits/pkg/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
func SyncTeamUsers() {
|
func SyncTeams() {
|
||||||
t1 := time.NewTicker(time.Duration(cache.CHECK_INTERVAL) * time.Second)
|
t1 := time.NewTicker(time.Duration(cache.CHECK_INTERVAL) * time.Second)
|
||||||
|
|
||||||
syncTeamUsers()
|
syncTeam()
|
||||||
logger.Info("[cron] sync team start...")
|
logger.Info("[cron] sync team start...")
|
||||||
for {
|
for {
|
||||||
<-t1.C
|
<-t1.C
|
||||||
syncTeamUsers()
|
syncTeam()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func syncTeamUsers() {
|
func syncTeam() {
|
||||||
teamUsers, err := models.TeamUsers()
|
teams, err := models.AllTeams()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warningf("get Teams err:%v %v", err)
|
logger.Warningf("get teams err:%v %v", err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
teamUsersMap := make(map[int64][]int64)
|
teamsMap := make(map[int64]*models.Team)
|
||||||
for _, teamUser := range teamUsers {
|
for _, team := range teams {
|
||||||
if _, exists := teamUsersMap[teamUser.TeamId]; exists {
|
teamsMap[team.Id] = &team
|
||||||
teamUsersMap[teamUser.TeamId] = append(teamUsersMap[teamUser.TeamId], teamUser.UserId)
|
|
||||||
} else {
|
|
||||||
teamUsersMap[teamUser.TeamId] = []int64{teamUser.UserId}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
cache.TeamUsersCache.SetAll(teamUsersMap)
|
|
||||||
|
cache.TeamCache.SetAll(teamsMap)
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package cron
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/didi/nightingale/v4/src/models"
|
||||||
|
"github.com/didi/nightingale/v4/src/modules/server/cache"
|
||||||
|
"github.com/toolkits/pkg/logger"
|
||||||
|
)
|
||||||
|
|
||||||
|
func SyncTeamUsers() {
|
||||||
|
t1 := time.NewTicker(time.Duration(cache.CHECK_INTERVAL) * time.Second)
|
||||||
|
|
||||||
|
syncTeamUsers()
|
||||||
|
logger.Info("[cron] sync team start...")
|
||||||
|
for {
|
||||||
|
<-t1.C
|
||||||
|
syncTeamUsers()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func syncTeamUsers() {
|
||||||
|
teamUsers, err := models.TeamUsers()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logger.Warningf("get Teams err:%v %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
teamUsersMap := make(map[int64][]int64)
|
||||||
|
for _, teamUser := range teamUsers {
|
||||||
|
if _, exists := teamUsersMap[teamUser.TeamId]; exists {
|
||||||
|
teamUsersMap[teamUser.TeamId] = append(teamUsersMap[teamUser.TeamId], teamUser.UserId)
|
||||||
|
} else {
|
||||||
|
teamUsersMap[teamUser.TeamId] = []int64{teamUser.UserId}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cache.TeamUsersCache.SetAll(teamUsersMap)
|
||||||
|
}
|
|
@ -21,9 +21,9 @@ func SyncUsers() {
|
||||||
|
|
||||||
func syncUsers() {
|
func syncUsers() {
|
||||||
users, err := models.AllUsers()
|
users, err := models.AllUsers()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warningf("get users err:%v %v", err)
|
logger.Warningf("get users err:%v %v", err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
usersMap := make(map[int64]*models.User)
|
usersMap := make(map[int64]*models.User)
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/didi/nightingale/v4/src/models"
|
"github.com/didi/nightingale/v4/src/models"
|
||||||
|
"github.com/didi/nightingale/v4/src/modules/server/cache"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/toolkits/pkg/errors"
|
"github.com/toolkits/pkg/errors"
|
||||||
|
@ -84,14 +85,11 @@ func eventCurGets(c *gin.Context) {
|
||||||
|
|
||||||
datList := []eventData{}
|
datList := []eventData{}
|
||||||
for i := 0; i < len(events); i++ {
|
for i := 0; i < len(events); i++ {
|
||||||
users, err := models.GetUsersNameByIds(events[i].Users)
|
users := cache.UserCache.GetUsernamesByIds(events[i].Users)
|
||||||
errors.Dangerous(err)
|
|
||||||
|
|
||||||
groups, err := models.GetTeamsNameByIds(events[i].Groups)
|
groups := cache.TeamCache.GetTeamNamesByIds(events[i].Groups)
|
||||||
errors.Dangerous(err)
|
|
||||||
|
|
||||||
claimants, err := models.GetUsersNameByIds(events[i].Claimants)
|
claimants := cache.UserCache.GetUsernamesByIds(events[i].Claimants)
|
||||||
errors.Dangerous(err)
|
|
||||||
|
|
||||||
var detail []models.EventDetail
|
var detail []models.EventDetail
|
||||||
err = json.Unmarshal([]byte(events[i].Detail), &detail)
|
err = json.Unmarshal([]byte(events[i].Detail), &detail)
|
||||||
|
@ -110,11 +108,9 @@ func eventCurGets(c *gin.Context) {
|
||||||
alertUpgrade, err := models.EventAlertUpgradeUnMarshal(events[i].AlertUpgrade)
|
alertUpgrade, err := models.EventAlertUpgradeUnMarshal(events[i].AlertUpgrade)
|
||||||
errors.Dangerous(err)
|
errors.Dangerous(err)
|
||||||
|
|
||||||
alertUsers, err := models.GetUsersNameByIds(alertUpgrade.Users)
|
alertUsers := cache.UserCache.GetUsernamesByIds(alertUpgrade.Users)
|
||||||
errors.Dangerous(err)
|
|
||||||
|
|
||||||
alertGroups, err := models.GetTeamsNameByIds(alertUpgrade.Groups)
|
alertGroups := cache.TeamCache.GetTeamNamesByIds(alertUpgrade.Groups)
|
||||||
errors.Dangerous(err)
|
|
||||||
|
|
||||||
dat := eventData{
|
dat := eventData{
|
||||||
Id: events[i].Id,
|
Id: events[i].Id,
|
||||||
|
@ -195,11 +191,9 @@ func eventHisGets(c *gin.Context) {
|
||||||
|
|
||||||
datList := []eventData{}
|
datList := []eventData{}
|
||||||
for i := 0; i < len(events); i++ {
|
for i := 0; i < len(events); i++ {
|
||||||
users, err := models.GetUsersNameByIds(events[i].Users)
|
users := cache.UserCache.GetUsernamesByIds(events[i].Users)
|
||||||
errors.Dangerous(err)
|
|
||||||
|
|
||||||
groups, err := models.GetTeamsNameByIds(events[i].Groups)
|
groups := cache.TeamCache.GetTeamNamesByIds(events[i].Groups)
|
||||||
errors.Dangerous(err)
|
|
||||||
|
|
||||||
var detail []models.EventDetail
|
var detail []models.EventDetail
|
||||||
err = json.Unmarshal([]byte(events[i].Detail), &detail)
|
err = json.Unmarshal([]byte(events[i].Detail), &detail)
|
||||||
|
@ -218,11 +212,9 @@ func eventHisGets(c *gin.Context) {
|
||||||
alertUpgrade, err := models.EventAlertUpgradeUnMarshal(events[i].AlertUpgrade)
|
alertUpgrade, err := models.EventAlertUpgradeUnMarshal(events[i].AlertUpgrade)
|
||||||
errors.Dangerous(err)
|
errors.Dangerous(err)
|
||||||
|
|
||||||
alertUsers, err := models.GetUsersNameByIds(alertUpgrade.Users)
|
alertUsers := cache.UserCache.GetUsernamesByIds(alertUpgrade.Users)
|
||||||
errors.Dangerous(err)
|
|
||||||
|
|
||||||
alertGroups, err := models.GetTeamsNameByIds(alertUpgrade.Groups)
|
alertGroups := cache.TeamCache.GetTeamNamesByIds(alertUpgrade.Groups)
|
||||||
errors.Dangerous(err)
|
|
||||||
|
|
||||||
dat := eventData{
|
dat := eventData{
|
||||||
Id: events[i].Id,
|
Id: events[i].Id,
|
||||||
|
@ -274,14 +266,12 @@ func eventHisGetById(c *gin.Context) {
|
||||||
|
|
||||||
event := mustEvent(urlParamInt64(c, "id"))
|
event := mustEvent(urlParamInt64(c, "id"))
|
||||||
|
|
||||||
users, err := models.GetUsersNameByIds(event.Users)
|
users := cache.UserCache.GetUsernamesByIds(event.Users)
|
||||||
errors.Dangerous(err)
|
|
||||||
|
|
||||||
groups, err := models.GetTeamsNameByIds(event.Groups)
|
groups := cache.TeamCache.GetTeamNamesByIds(event.Groups)
|
||||||
errors.Dangerous(err)
|
|
||||||
|
|
||||||
var detail []models.EventDetail
|
var detail []models.EventDetail
|
||||||
err = json.Unmarshal([]byte(event.Detail), &detail)
|
err := json.Unmarshal([]byte(event.Detail), &detail)
|
||||||
errors.Dangerous(err)
|
errors.Dangerous(err)
|
||||||
|
|
||||||
tagsList := []string{}
|
tagsList := []string{}
|
||||||
|
@ -294,11 +284,9 @@ func eventHisGetById(c *gin.Context) {
|
||||||
alertUpgrade, err := models.EventAlertUpgradeUnMarshal(event.AlertUpgrade)
|
alertUpgrade, err := models.EventAlertUpgradeUnMarshal(event.AlertUpgrade)
|
||||||
errors.Dangerous(err)
|
errors.Dangerous(err)
|
||||||
|
|
||||||
alertUsers, err := models.GetUsersNameByIds(alertUpgrade.Users)
|
alertUsers := cache.UserCache.GetUsernamesByIds(alertUpgrade.Users)
|
||||||
errors.Dangerous(err)
|
|
||||||
|
|
||||||
alertGroups, err := models.GetTeamsNameByIds(alertUpgrade.Groups)
|
alertGroups := cache.TeamCache.GetTeamNamesByIds(alertUpgrade.Groups)
|
||||||
errors.Dangerous(err)
|
|
||||||
|
|
||||||
dat := eventData{
|
dat := eventData{
|
||||||
Id: event.Id,
|
Id: event.Id,
|
||||||
|
@ -339,17 +327,14 @@ func eventCurGetById(c *gin.Context) {
|
||||||
|
|
||||||
eventCur := mustEventCur(urlParamInt64(c, "id"))
|
eventCur := mustEventCur(urlParamInt64(c, "id"))
|
||||||
|
|
||||||
users, err := models.GetUsersNameByIds(eventCur.Users)
|
users := cache.UserCache.GetUsernamesByIds(eventCur.Users)
|
||||||
errors.Dangerous(err)
|
|
||||||
|
|
||||||
groups, err := models.GetTeamsNameByIds(eventCur.Groups)
|
groups := cache.TeamCache.GetTeamNamesByIds(eventCur.Groups)
|
||||||
errors.Dangerous(err)
|
|
||||||
|
|
||||||
claimants, err := models.GetUsersNameByIds(eventCur.Claimants)
|
claimants := cache.UserCache.GetUsernamesByIds(eventCur.Claimants)
|
||||||
errors.Dangerous(err)
|
|
||||||
|
|
||||||
var detail []models.EventDetail
|
var detail []models.EventDetail
|
||||||
err = json.Unmarshal([]byte(eventCur.Detail), &detail)
|
err := json.Unmarshal([]byte(eventCur.Detail), &detail)
|
||||||
errors.Dangerous(err)
|
errors.Dangerous(err)
|
||||||
|
|
||||||
tagsList := []string{}
|
tagsList := []string{}
|
||||||
|
@ -362,10 +347,9 @@ func eventCurGetById(c *gin.Context) {
|
||||||
alertUpgrade, err := models.EventAlertUpgradeUnMarshal(eventCur.AlertUpgrade)
|
alertUpgrade, err := models.EventAlertUpgradeUnMarshal(eventCur.AlertUpgrade)
|
||||||
errors.Dangerous(err)
|
errors.Dangerous(err)
|
||||||
|
|
||||||
alertUsers, err := models.GetUsersNameByIds(alertUpgrade.Users)
|
alertUsers := cache.UserCache.GetUsernamesByIds(alertUpgrade.Users)
|
||||||
errors.Dangerous(err)
|
|
||||||
|
|
||||||
alertGroups, err := models.GetTeamsNameByIds(alertUpgrade.Groups)
|
alertGroups := cache.TeamCache.GetTeamNamesByIds(alertUpgrade.Groups)
|
||||||
|
|
||||||
dat := eventData{
|
dat := eventData{
|
||||||
Id: eventCur.Id,
|
Id: eventCur.Id,
|
||||||
|
|
Loading…
Reference in New Issue