MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / PageAlert

Method PageAlert

agent/app/service/alert.go:64–106  ·  view source on GitHub ↗
(search dto.AlertSearch)

Source from the content-addressed store, hash-verified

62}
63
64func (a AlertService) PageAlert(search dto.AlertSearch) (int64, []dto.AlertDTO, error) {
65 var (
66 opts []repo.DBOption
67 result []dto.AlertDTO
68 )
69 if global.CONF.Base.IsEnterprise {
70 opts = append(opts, alertRepo.WithByTypeNotIn(eeHiddenAlertTypes))
71 }
72 if search.Status != "" {
73 opts = append(opts, repo.WithByStatus(search.Status))
74 }
75 if search.Type != "" {
76 opts = append(opts, alertRepo.WithByType(search.Type))
77 }
78 opts = append(opts, repo.WithOrderDesc("created_at"))
79
80 total, alerts, err := alertRepo.Page(search.Page, search.PageSize, opts...)
81 if err != nil {
82 return 0, nil, err
83 }
84
85 for _, item := range alerts {
86
87 result = append(result, dto.AlertDTO{
88 ID: item.ID,
89 Type: item.Type,
90 Cycle: item.Cycle,
91 Count: item.Count,
92 Method: item.Method,
93 Title: item.Title,
94 Project: item.Project,
95 Status: item.Status,
96 SendCount: item.SendCount,
97 AdvancedParams: item.AdvancedParams,
98 CreateUser: item.CreateUser,
99 UpdateUser: item.UpdateUser,
100 CreatedAt: item.CreatedAt,
101 UpdatedAt: item.UpdatedAt,
102 })
103 }
104
105 return total, result, err
106}
107
108func (a AlertService) GetAlerts() ([]dto.AlertDTO, error) {
109 var (

Callers

nothing calls this directly

Calls 4

WithByTypeNotInMethod · 0.65
WithByStatusMethod · 0.65
WithByTypeMethod · 0.65
PageMethod · 0.65

Tested by

no test coverage detected