mirror of
https://gitee.com/wanwujie/sub2api
synced 2026-05-04 21:20:51 +08:00
feat(channel-monitor): aggregate history to daily rollups + soft delete
明细只保留 1 天,超过 1 天聚合到新表 channel_monitor_daily_rollups(按 monitor_id/model/bucket_date 维度),聚合保留 30 天。两张表都用 SoftDeleteMixin 软删除(DELETE 自动改为 UPDATE deleted_at = NOW())。 聚合 + 清理任务由 OpsCleanupService 的 cron 统一调度,与运维监控的清理共享 schedule(默认 0 2 * * *)和 leader lock。ChannelMonitorRunner 的 cleanupLoop 被移除,只保留 dueCheckLoop。 读取路径 ComputeAvailability* 改为 UNION 明细(今天 deleted_at IS NULL)+ 聚合(过去 windowDays 天 deleted_at IS NULL),SUM(ok)/SUM(total) 自然加权 计算可用率,AVG latency 用 SUM(sum_latency_ms)/SUM(count_latency)。 watermark 表 channel_monitor_aggregation_watermark 单行(id=1),记录 last_aggregated_date,重启后从该日期 +1 继续聚合,首次为 nil 则从 today - 30d 开始回填,单次最多 35 天上限避免长事务。 raw SQL 的 ListLatestPerModel / ListLatestForMonitorIDs / ListRecentHistoryForMonitors 都补上 deleted_at IS NULL 过滤(SoftDeleteMixin interceptor 只对 ent query 生效)。 bump version to 0.1.114.28 GroupBadge 在 MonitorKeyPickerDialog 中复用平台主题色 + 倍率/专属倍率 (顺手优化)。
This commit is contained in:
@@ -252,7 +252,7 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
|
|||||||
opsMetricsCollector := service.ProvideOpsMetricsCollector(opsRepository, settingRepository, accountRepository, concurrencyService, db, redisClient, configConfig)
|
opsMetricsCollector := service.ProvideOpsMetricsCollector(opsRepository, settingRepository, accountRepository, concurrencyService, db, redisClient, configConfig)
|
||||||
opsAggregationService := service.ProvideOpsAggregationService(opsRepository, settingRepository, db, redisClient, configConfig)
|
opsAggregationService := service.ProvideOpsAggregationService(opsRepository, settingRepository, db, redisClient, configConfig)
|
||||||
opsAlertEvaluatorService := service.ProvideOpsAlertEvaluatorService(opsService, opsRepository, emailService, redisClient, configConfig)
|
opsAlertEvaluatorService := service.ProvideOpsAlertEvaluatorService(opsService, opsRepository, emailService, redisClient, configConfig)
|
||||||
opsCleanupService := service.ProvideOpsCleanupService(opsRepository, db, redisClient, configConfig)
|
opsCleanupService := service.ProvideOpsCleanupService(opsRepository, db, redisClient, configConfig, channelMonitorService)
|
||||||
opsScheduledReportService := service.ProvideOpsScheduledReportService(opsService, userService, emailService, redisClient, configConfig)
|
opsScheduledReportService := service.ProvideOpsScheduledReportService(opsService, userService, emailService, redisClient, configConfig)
|
||||||
tokenRefreshService := service.ProvideTokenRefreshService(accountRepository, oAuthService, openAIOAuthService, geminiOAuthService, antigravityOAuthService, compositeTokenCacheInvalidator, schedulerCache, configConfig, tempUnschedCache, privacyClientFactory, proxyRepository, oAuthRefreshAPI)
|
tokenRefreshService := service.ProvideTokenRefreshService(accountRepository, oAuthService, openAIOAuthService, geminiOAuthService, antigravityOAuthService, compositeTokenCacheInvalidator, schedulerCache, configConfig, tempUnschedCache, privacyClientFactory, proxyRepository, oAuthRefreshAPI)
|
||||||
accountExpiryService := service.ProvideAccountExpiryService(accountRepository)
|
accountExpiryService := service.ProvideAccountExpiryService(accountRepository)
|
||||||
|
|||||||
@@ -54,9 +54,11 @@ type ChannelMonitor struct {
|
|||||||
type ChannelMonitorEdges struct {
|
type ChannelMonitorEdges struct {
|
||||||
// History holds the value of the history edge.
|
// History holds the value of the history edge.
|
||||||
History []*ChannelMonitorHistory `json:"history,omitempty"`
|
History []*ChannelMonitorHistory `json:"history,omitempty"`
|
||||||
|
// DailyRollups holds the value of the daily_rollups edge.
|
||||||
|
DailyRollups []*ChannelMonitorDailyRollup `json:"daily_rollups,omitempty"`
|
||||||
// loadedTypes holds the information for reporting if a
|
// loadedTypes holds the information for reporting if a
|
||||||
// type was loaded (or requested) in eager-loading or not.
|
// type was loaded (or requested) in eager-loading or not.
|
||||||
loadedTypes [1]bool
|
loadedTypes [2]bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// HistoryOrErr returns the History value or an error if the edge
|
// HistoryOrErr returns the History value or an error if the edge
|
||||||
@@ -68,6 +70,15 @@ func (e ChannelMonitorEdges) HistoryOrErr() ([]*ChannelMonitorHistory, error) {
|
|||||||
return nil, &NotLoadedError{edge: "history"}
|
return nil, &NotLoadedError{edge: "history"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DailyRollupsOrErr returns the DailyRollups value or an error if the edge
|
||||||
|
// was not loaded in eager-loading.
|
||||||
|
func (e ChannelMonitorEdges) DailyRollupsOrErr() ([]*ChannelMonitorDailyRollup, error) {
|
||||||
|
if e.loadedTypes[1] {
|
||||||
|
return e.DailyRollups, nil
|
||||||
|
}
|
||||||
|
return nil, &NotLoadedError{edge: "daily_rollups"}
|
||||||
|
}
|
||||||
|
|
||||||
// scanValues returns the types for scanning values from sql.Rows.
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
func (*ChannelMonitor) scanValues(columns []string) ([]any, error) {
|
func (*ChannelMonitor) scanValues(columns []string) ([]any, error) {
|
||||||
values := make([]any, len(columns))
|
values := make([]any, len(columns))
|
||||||
@@ -203,6 +214,11 @@ func (_m *ChannelMonitor) QueryHistory() *ChannelMonitorHistoryQuery {
|
|||||||
return NewChannelMonitorClient(_m.config).QueryHistory(_m)
|
return NewChannelMonitorClient(_m.config).QueryHistory(_m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// QueryDailyRollups queries the "daily_rollups" edge of the ChannelMonitor entity.
|
||||||
|
func (_m *ChannelMonitor) QueryDailyRollups() *ChannelMonitorDailyRollupQuery {
|
||||||
|
return NewChannelMonitorClient(_m.config).QueryDailyRollups(_m)
|
||||||
|
}
|
||||||
|
|
||||||
// Update returns a builder for updating this ChannelMonitor.
|
// Update returns a builder for updating this ChannelMonitor.
|
||||||
// Note that you need to call ChannelMonitor.Unwrap() before calling this method if this ChannelMonitor
|
// Note that you need to call ChannelMonitor.Unwrap() before calling this method if this ChannelMonitor
|
||||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ const (
|
|||||||
FieldCreatedBy = "created_by"
|
FieldCreatedBy = "created_by"
|
||||||
// EdgeHistory holds the string denoting the history edge name in mutations.
|
// EdgeHistory holds the string denoting the history edge name in mutations.
|
||||||
EdgeHistory = "history"
|
EdgeHistory = "history"
|
||||||
|
// EdgeDailyRollups holds the string denoting the daily_rollups edge name in mutations.
|
||||||
|
EdgeDailyRollups = "daily_rollups"
|
||||||
// Table holds the table name of the channelmonitor in the database.
|
// Table holds the table name of the channelmonitor in the database.
|
||||||
Table = "channel_monitors"
|
Table = "channel_monitors"
|
||||||
// HistoryTable is the table that holds the history relation/edge.
|
// HistoryTable is the table that holds the history relation/edge.
|
||||||
@@ -52,6 +54,13 @@ const (
|
|||||||
HistoryInverseTable = "channel_monitor_histories"
|
HistoryInverseTable = "channel_monitor_histories"
|
||||||
// HistoryColumn is the table column denoting the history relation/edge.
|
// HistoryColumn is the table column denoting the history relation/edge.
|
||||||
HistoryColumn = "monitor_id"
|
HistoryColumn = "monitor_id"
|
||||||
|
// DailyRollupsTable is the table that holds the daily_rollups relation/edge.
|
||||||
|
DailyRollupsTable = "channel_monitor_daily_rollups"
|
||||||
|
// DailyRollupsInverseTable is the table name for the ChannelMonitorDailyRollup entity.
|
||||||
|
// It exists in this package in order to avoid circular dependency with the "channelmonitordailyrollup" package.
|
||||||
|
DailyRollupsInverseTable = "channel_monitor_daily_rollups"
|
||||||
|
// DailyRollupsColumn is the table column denoting the daily_rollups relation/edge.
|
||||||
|
DailyRollupsColumn = "monitor_id"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Columns holds all SQL columns for channelmonitor fields.
|
// Columns holds all SQL columns for channelmonitor fields.
|
||||||
@@ -214,6 +223,20 @@ func ByHistory(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
|||||||
sqlgraph.OrderByNeighborTerms(s, newHistoryStep(), append([]sql.OrderTerm{term}, terms...)...)
|
sqlgraph.OrderByNeighborTerms(s, newHistoryStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ByDailyRollupsCount orders the results by daily_rollups count.
|
||||||
|
func ByDailyRollupsCount(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return func(s *sql.Selector) {
|
||||||
|
sqlgraph.OrderByNeighborsCount(s, newDailyRollupsStep(), opts...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByDailyRollups orders the results by daily_rollups terms.
|
||||||
|
func ByDailyRollups(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||||
|
return func(s *sql.Selector) {
|
||||||
|
sqlgraph.OrderByNeighborTerms(s, newDailyRollupsStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||||
|
}
|
||||||
|
}
|
||||||
func newHistoryStep() *sqlgraph.Step {
|
func newHistoryStep() *sqlgraph.Step {
|
||||||
return sqlgraph.NewStep(
|
return sqlgraph.NewStep(
|
||||||
sqlgraph.From(Table, FieldID),
|
sqlgraph.From(Table, FieldID),
|
||||||
@@ -221,3 +244,10 @@ func newHistoryStep() *sqlgraph.Step {
|
|||||||
sqlgraph.Edge(sqlgraph.O2M, false, HistoryTable, HistoryColumn),
|
sqlgraph.Edge(sqlgraph.O2M, false, HistoryTable, HistoryColumn),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
func newDailyRollupsStep() *sqlgraph.Step {
|
||||||
|
return sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(Table, FieldID),
|
||||||
|
sqlgraph.To(DailyRollupsInverseTable, FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.O2M, false, DailyRollupsTable, DailyRollupsColumn),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -708,6 +708,29 @@ func HasHistoryWith(preds ...predicate.ChannelMonitorHistory) predicate.ChannelM
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasDailyRollups applies the HasEdge predicate on the "daily_rollups" edge.
|
||||||
|
func HasDailyRollups() predicate.ChannelMonitor {
|
||||||
|
return predicate.ChannelMonitor(func(s *sql.Selector) {
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(Table, FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.O2M, false, DailyRollupsTable, DailyRollupsColumn),
|
||||||
|
)
|
||||||
|
sqlgraph.HasNeighbors(s, step)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasDailyRollupsWith applies the HasEdge predicate on the "daily_rollups" edge with a given conditions (other predicates).
|
||||||
|
func HasDailyRollupsWith(preds ...predicate.ChannelMonitorDailyRollup) predicate.ChannelMonitor {
|
||||||
|
return predicate.ChannelMonitor(func(s *sql.Selector) {
|
||||||
|
step := newDailyRollupsStep()
|
||||||
|
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||||
|
for _, p := range preds {
|
||||||
|
p(s)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// And groups predicates with the AND operator between them.
|
// And groups predicates with the AND operator between them.
|
||||||
func And(predicates ...predicate.ChannelMonitor) predicate.ChannelMonitor {
|
func And(predicates ...predicate.ChannelMonitor) predicate.ChannelMonitor {
|
||||||
return predicate.ChannelMonitor(sql.AndPredicates(predicates...))
|
return predicate.ChannelMonitor(sql.AndPredicates(predicates...))
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import (
|
|||||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
"entgo.io/ent/schema/field"
|
"entgo.io/ent/schema/field"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/channelmonitor"
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitor"
|
||||||
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitordailyrollup"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/channelmonitorhistory"
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitorhistory"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -156,6 +157,21 @@ func (_c *ChannelMonitorCreate) AddHistory(v ...*ChannelMonitorHistory) *Channel
|
|||||||
return _c.AddHistoryIDs(ids...)
|
return _c.AddHistoryIDs(ids...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddDailyRollupIDs adds the "daily_rollups" edge to the ChannelMonitorDailyRollup entity by IDs.
|
||||||
|
func (_c *ChannelMonitorCreate) AddDailyRollupIDs(ids ...int64) *ChannelMonitorCreate {
|
||||||
|
_c.mutation.AddDailyRollupIDs(ids...)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddDailyRollups adds the "daily_rollups" edges to the ChannelMonitorDailyRollup entity.
|
||||||
|
func (_c *ChannelMonitorCreate) AddDailyRollups(v ...*ChannelMonitorDailyRollup) *ChannelMonitorCreate {
|
||||||
|
ids := make([]int64, len(v))
|
||||||
|
for i := range v {
|
||||||
|
ids[i] = v[i].ID
|
||||||
|
}
|
||||||
|
return _c.AddDailyRollupIDs(ids...)
|
||||||
|
}
|
||||||
|
|
||||||
// Mutation returns the ChannelMonitorMutation object of the builder.
|
// Mutation returns the ChannelMonitorMutation object of the builder.
|
||||||
func (_c *ChannelMonitorCreate) Mutation() *ChannelMonitorMutation {
|
func (_c *ChannelMonitorCreate) Mutation() *ChannelMonitorMutation {
|
||||||
return _c.mutation
|
return _c.mutation
|
||||||
@@ -378,6 +394,22 @@ func (_c *ChannelMonitorCreate) createSpec() (*ChannelMonitor, *sqlgraph.CreateS
|
|||||||
}
|
}
|
||||||
_spec.Edges = append(_spec.Edges, edge)
|
_spec.Edges = append(_spec.Edges, edge)
|
||||||
}
|
}
|
||||||
|
if nodes := _c.mutation.DailyRollupsIDs(); len(nodes) > 0 {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.O2M,
|
||||||
|
Inverse: false,
|
||||||
|
Table: channelmonitor.DailyRollupsTable,
|
||||||
|
Columns: []string{channelmonitor.DailyRollupsColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: sqlgraph.NewFieldSpec(channelmonitordailyrollup.FieldID, field.TypeInt64),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_spec.Edges = append(_spec.Edges, edge)
|
||||||
|
}
|
||||||
return _node, _spec
|
return _node, _spec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import (
|
|||||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
"entgo.io/ent/schema/field"
|
"entgo.io/ent/schema/field"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/channelmonitor"
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitor"
|
||||||
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitordailyrollup"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/channelmonitorhistory"
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitorhistory"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/predicate"
|
"github.com/Wei-Shaw/sub2api/ent/predicate"
|
||||||
)
|
)
|
||||||
@@ -21,12 +22,13 @@ import (
|
|||||||
// ChannelMonitorQuery is the builder for querying ChannelMonitor entities.
|
// ChannelMonitorQuery is the builder for querying ChannelMonitor entities.
|
||||||
type ChannelMonitorQuery struct {
|
type ChannelMonitorQuery struct {
|
||||||
config
|
config
|
||||||
ctx *QueryContext
|
ctx *QueryContext
|
||||||
order []channelmonitor.OrderOption
|
order []channelmonitor.OrderOption
|
||||||
inters []Interceptor
|
inters []Interceptor
|
||||||
predicates []predicate.ChannelMonitor
|
predicates []predicate.ChannelMonitor
|
||||||
withHistory *ChannelMonitorHistoryQuery
|
withHistory *ChannelMonitorHistoryQuery
|
||||||
modifiers []func(*sql.Selector)
|
withDailyRollups *ChannelMonitorDailyRollupQuery
|
||||||
|
modifiers []func(*sql.Selector)
|
||||||
// intermediate query (i.e. traversal path).
|
// intermediate query (i.e. traversal path).
|
||||||
sql *sql.Selector
|
sql *sql.Selector
|
||||||
path func(context.Context) (*sql.Selector, error)
|
path func(context.Context) (*sql.Selector, error)
|
||||||
@@ -85,6 +87,28 @@ func (_q *ChannelMonitorQuery) QueryHistory() *ChannelMonitorHistoryQuery {
|
|||||||
return query
|
return query
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// QueryDailyRollups chains the current query on the "daily_rollups" edge.
|
||||||
|
func (_q *ChannelMonitorQuery) QueryDailyRollups() *ChannelMonitorDailyRollupQuery {
|
||||||
|
query := (&ChannelMonitorDailyRollupClient{config: _q.config}).Query()
|
||||||
|
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||||
|
if err := _q.prepareQuery(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
selector := _q.sqlQuery(ctx)
|
||||||
|
if err := selector.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(channelmonitor.Table, channelmonitor.FieldID, selector),
|
||||||
|
sqlgraph.To(channelmonitordailyrollup.Table, channelmonitordailyrollup.FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.O2M, false, channelmonitor.DailyRollupsTable, channelmonitor.DailyRollupsColumn),
|
||||||
|
)
|
||||||
|
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||||
|
return fromU, nil
|
||||||
|
}
|
||||||
|
return query
|
||||||
|
}
|
||||||
|
|
||||||
// First returns the first ChannelMonitor entity from the query.
|
// First returns the first ChannelMonitor entity from the query.
|
||||||
// Returns a *NotFoundError when no ChannelMonitor was found.
|
// Returns a *NotFoundError when no ChannelMonitor was found.
|
||||||
func (_q *ChannelMonitorQuery) First(ctx context.Context) (*ChannelMonitor, error) {
|
func (_q *ChannelMonitorQuery) First(ctx context.Context) (*ChannelMonitor, error) {
|
||||||
@@ -272,12 +296,13 @@ func (_q *ChannelMonitorQuery) Clone() *ChannelMonitorQuery {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return &ChannelMonitorQuery{
|
return &ChannelMonitorQuery{
|
||||||
config: _q.config,
|
config: _q.config,
|
||||||
ctx: _q.ctx.Clone(),
|
ctx: _q.ctx.Clone(),
|
||||||
order: append([]channelmonitor.OrderOption{}, _q.order...),
|
order: append([]channelmonitor.OrderOption{}, _q.order...),
|
||||||
inters: append([]Interceptor{}, _q.inters...),
|
inters: append([]Interceptor{}, _q.inters...),
|
||||||
predicates: append([]predicate.ChannelMonitor{}, _q.predicates...),
|
predicates: append([]predicate.ChannelMonitor{}, _q.predicates...),
|
||||||
withHistory: _q.withHistory.Clone(),
|
withHistory: _q.withHistory.Clone(),
|
||||||
|
withDailyRollups: _q.withDailyRollups.Clone(),
|
||||||
// clone intermediate query.
|
// clone intermediate query.
|
||||||
sql: _q.sql.Clone(),
|
sql: _q.sql.Clone(),
|
||||||
path: _q.path,
|
path: _q.path,
|
||||||
@@ -295,6 +320,17 @@ func (_q *ChannelMonitorQuery) WithHistory(opts ...func(*ChannelMonitorHistoryQu
|
|||||||
return _q
|
return _q
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithDailyRollups tells the query-builder to eager-load the nodes that are connected to
|
||||||
|
// the "daily_rollups" edge. The optional arguments are used to configure the query builder of the edge.
|
||||||
|
func (_q *ChannelMonitorQuery) WithDailyRollups(opts ...func(*ChannelMonitorDailyRollupQuery)) *ChannelMonitorQuery {
|
||||||
|
query := (&ChannelMonitorDailyRollupClient{config: _q.config}).Query()
|
||||||
|
for _, opt := range opts {
|
||||||
|
opt(query)
|
||||||
|
}
|
||||||
|
_q.withDailyRollups = query
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
// GroupBy is used to group vertices by one or more fields/columns.
|
// GroupBy is used to group vertices by one or more fields/columns.
|
||||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||||
//
|
//
|
||||||
@@ -373,8 +409,9 @@ func (_q *ChannelMonitorQuery) sqlAll(ctx context.Context, hooks ...queryHook) (
|
|||||||
var (
|
var (
|
||||||
nodes = []*ChannelMonitor{}
|
nodes = []*ChannelMonitor{}
|
||||||
_spec = _q.querySpec()
|
_spec = _q.querySpec()
|
||||||
loadedTypes = [1]bool{
|
loadedTypes = [2]bool{
|
||||||
_q.withHistory != nil,
|
_q.withHistory != nil,
|
||||||
|
_q.withDailyRollups != nil,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||||
@@ -405,6 +442,15 @@ func (_q *ChannelMonitorQuery) sqlAll(ctx context.Context, hooks ...queryHook) (
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if query := _q.withDailyRollups; query != nil {
|
||||||
|
if err := _q.loadDailyRollups(ctx, query, nodes,
|
||||||
|
func(n *ChannelMonitor) { n.Edges.DailyRollups = []*ChannelMonitorDailyRollup{} },
|
||||||
|
func(n *ChannelMonitor, e *ChannelMonitorDailyRollup) {
|
||||||
|
n.Edges.DailyRollups = append(n.Edges.DailyRollups, e)
|
||||||
|
}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
return nodes, nil
|
return nodes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,6 +484,36 @@ func (_q *ChannelMonitorQuery) loadHistory(ctx context.Context, query *ChannelMo
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
func (_q *ChannelMonitorQuery) loadDailyRollups(ctx context.Context, query *ChannelMonitorDailyRollupQuery, nodes []*ChannelMonitor, init func(*ChannelMonitor), assign func(*ChannelMonitor, *ChannelMonitorDailyRollup)) error {
|
||||||
|
fks := make([]driver.Value, 0, len(nodes))
|
||||||
|
nodeids := make(map[int64]*ChannelMonitor)
|
||||||
|
for i := range nodes {
|
||||||
|
fks = append(fks, nodes[i].ID)
|
||||||
|
nodeids[nodes[i].ID] = nodes[i]
|
||||||
|
if init != nil {
|
||||||
|
init(nodes[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(query.ctx.Fields) > 0 {
|
||||||
|
query.ctx.AppendFieldOnce(channelmonitordailyrollup.FieldMonitorID)
|
||||||
|
}
|
||||||
|
query.Where(predicate.ChannelMonitorDailyRollup(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.InValues(s.C(channelmonitor.DailyRollupsColumn), fks...))
|
||||||
|
}))
|
||||||
|
neighbors, err := query.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, n := range neighbors {
|
||||||
|
fk := n.MonitorID
|
||||||
|
node, ok := nodeids[fk]
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(`unexpected referenced foreign-key "monitor_id" returned %v for node %v`, fk, n.ID)
|
||||||
|
}
|
||||||
|
assign(node, n)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (_q *ChannelMonitorQuery) sqlCount(ctx context.Context) (int, error) {
|
func (_q *ChannelMonitorQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
_spec := _q.querySpec()
|
_spec := _q.querySpec()
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import (
|
|||||||
"entgo.io/ent/dialect/sql/sqljson"
|
"entgo.io/ent/dialect/sql/sqljson"
|
||||||
"entgo.io/ent/schema/field"
|
"entgo.io/ent/schema/field"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/channelmonitor"
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitor"
|
||||||
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitordailyrollup"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/channelmonitorhistory"
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitorhistory"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/predicate"
|
"github.com/Wei-Shaw/sub2api/ent/predicate"
|
||||||
)
|
)
|
||||||
@@ -229,6 +230,21 @@ func (_u *ChannelMonitorUpdate) AddHistory(v ...*ChannelMonitorHistory) *Channel
|
|||||||
return _u.AddHistoryIDs(ids...)
|
return _u.AddHistoryIDs(ids...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddDailyRollupIDs adds the "daily_rollups" edge to the ChannelMonitorDailyRollup entity by IDs.
|
||||||
|
func (_u *ChannelMonitorUpdate) AddDailyRollupIDs(ids ...int64) *ChannelMonitorUpdate {
|
||||||
|
_u.mutation.AddDailyRollupIDs(ids...)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddDailyRollups adds the "daily_rollups" edges to the ChannelMonitorDailyRollup entity.
|
||||||
|
func (_u *ChannelMonitorUpdate) AddDailyRollups(v ...*ChannelMonitorDailyRollup) *ChannelMonitorUpdate {
|
||||||
|
ids := make([]int64, len(v))
|
||||||
|
for i := range v {
|
||||||
|
ids[i] = v[i].ID
|
||||||
|
}
|
||||||
|
return _u.AddDailyRollupIDs(ids...)
|
||||||
|
}
|
||||||
|
|
||||||
// Mutation returns the ChannelMonitorMutation object of the builder.
|
// Mutation returns the ChannelMonitorMutation object of the builder.
|
||||||
func (_u *ChannelMonitorUpdate) Mutation() *ChannelMonitorMutation {
|
func (_u *ChannelMonitorUpdate) Mutation() *ChannelMonitorMutation {
|
||||||
return _u.mutation
|
return _u.mutation
|
||||||
@@ -255,6 +271,27 @@ func (_u *ChannelMonitorUpdate) RemoveHistory(v ...*ChannelMonitorHistory) *Chan
|
|||||||
return _u.RemoveHistoryIDs(ids...)
|
return _u.RemoveHistoryIDs(ids...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClearDailyRollups clears all "daily_rollups" edges to the ChannelMonitorDailyRollup entity.
|
||||||
|
func (_u *ChannelMonitorUpdate) ClearDailyRollups() *ChannelMonitorUpdate {
|
||||||
|
_u.mutation.ClearDailyRollups()
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveDailyRollupIDs removes the "daily_rollups" edge to ChannelMonitorDailyRollup entities by IDs.
|
||||||
|
func (_u *ChannelMonitorUpdate) RemoveDailyRollupIDs(ids ...int64) *ChannelMonitorUpdate {
|
||||||
|
_u.mutation.RemoveDailyRollupIDs(ids...)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveDailyRollups removes "daily_rollups" edges to ChannelMonitorDailyRollup entities.
|
||||||
|
func (_u *ChannelMonitorUpdate) RemoveDailyRollups(v ...*ChannelMonitorDailyRollup) *ChannelMonitorUpdate {
|
||||||
|
ids := make([]int64, len(v))
|
||||||
|
for i := range v {
|
||||||
|
ids[i] = v[i].ID
|
||||||
|
}
|
||||||
|
return _u.RemoveDailyRollupIDs(ids...)
|
||||||
|
}
|
||||||
|
|
||||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||||
func (_u *ChannelMonitorUpdate) Save(ctx context.Context) (int, error) {
|
func (_u *ChannelMonitorUpdate) Save(ctx context.Context) (int, error) {
|
||||||
_u.defaults()
|
_u.defaults()
|
||||||
@@ -441,6 +478,51 @@ func (_u *ChannelMonitorUpdate) sqlSave(ctx context.Context) (_node int, err err
|
|||||||
}
|
}
|
||||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||||
}
|
}
|
||||||
|
if _u.mutation.DailyRollupsCleared() {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.O2M,
|
||||||
|
Inverse: false,
|
||||||
|
Table: channelmonitor.DailyRollupsTable,
|
||||||
|
Columns: []string{channelmonitor.DailyRollupsColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: sqlgraph.NewFieldSpec(channelmonitordailyrollup.FieldID, field.TypeInt64),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||||
|
}
|
||||||
|
if nodes := _u.mutation.RemovedDailyRollupsIDs(); len(nodes) > 0 && !_u.mutation.DailyRollupsCleared() {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.O2M,
|
||||||
|
Inverse: false,
|
||||||
|
Table: channelmonitor.DailyRollupsTable,
|
||||||
|
Columns: []string{channelmonitor.DailyRollupsColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: sqlgraph.NewFieldSpec(channelmonitordailyrollup.FieldID, field.TypeInt64),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||||
|
}
|
||||||
|
if nodes := _u.mutation.DailyRollupsIDs(); len(nodes) > 0 {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.O2M,
|
||||||
|
Inverse: false,
|
||||||
|
Table: channelmonitor.DailyRollupsTable,
|
||||||
|
Columns: []string{channelmonitor.DailyRollupsColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: sqlgraph.NewFieldSpec(channelmonitordailyrollup.FieldID, field.TypeInt64),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||||
|
}
|
||||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
err = &NotFoundError{channelmonitor.Label}
|
err = &NotFoundError{channelmonitor.Label}
|
||||||
@@ -660,6 +742,21 @@ func (_u *ChannelMonitorUpdateOne) AddHistory(v ...*ChannelMonitorHistory) *Chan
|
|||||||
return _u.AddHistoryIDs(ids...)
|
return _u.AddHistoryIDs(ids...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddDailyRollupIDs adds the "daily_rollups" edge to the ChannelMonitorDailyRollup entity by IDs.
|
||||||
|
func (_u *ChannelMonitorUpdateOne) AddDailyRollupIDs(ids ...int64) *ChannelMonitorUpdateOne {
|
||||||
|
_u.mutation.AddDailyRollupIDs(ids...)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddDailyRollups adds the "daily_rollups" edges to the ChannelMonitorDailyRollup entity.
|
||||||
|
func (_u *ChannelMonitorUpdateOne) AddDailyRollups(v ...*ChannelMonitorDailyRollup) *ChannelMonitorUpdateOne {
|
||||||
|
ids := make([]int64, len(v))
|
||||||
|
for i := range v {
|
||||||
|
ids[i] = v[i].ID
|
||||||
|
}
|
||||||
|
return _u.AddDailyRollupIDs(ids...)
|
||||||
|
}
|
||||||
|
|
||||||
// Mutation returns the ChannelMonitorMutation object of the builder.
|
// Mutation returns the ChannelMonitorMutation object of the builder.
|
||||||
func (_u *ChannelMonitorUpdateOne) Mutation() *ChannelMonitorMutation {
|
func (_u *ChannelMonitorUpdateOne) Mutation() *ChannelMonitorMutation {
|
||||||
return _u.mutation
|
return _u.mutation
|
||||||
@@ -686,6 +783,27 @@ func (_u *ChannelMonitorUpdateOne) RemoveHistory(v ...*ChannelMonitorHistory) *C
|
|||||||
return _u.RemoveHistoryIDs(ids...)
|
return _u.RemoveHistoryIDs(ids...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClearDailyRollups clears all "daily_rollups" edges to the ChannelMonitorDailyRollup entity.
|
||||||
|
func (_u *ChannelMonitorUpdateOne) ClearDailyRollups() *ChannelMonitorUpdateOne {
|
||||||
|
_u.mutation.ClearDailyRollups()
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveDailyRollupIDs removes the "daily_rollups" edge to ChannelMonitorDailyRollup entities by IDs.
|
||||||
|
func (_u *ChannelMonitorUpdateOne) RemoveDailyRollupIDs(ids ...int64) *ChannelMonitorUpdateOne {
|
||||||
|
_u.mutation.RemoveDailyRollupIDs(ids...)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveDailyRollups removes "daily_rollups" edges to ChannelMonitorDailyRollup entities.
|
||||||
|
func (_u *ChannelMonitorUpdateOne) RemoveDailyRollups(v ...*ChannelMonitorDailyRollup) *ChannelMonitorUpdateOne {
|
||||||
|
ids := make([]int64, len(v))
|
||||||
|
for i := range v {
|
||||||
|
ids[i] = v[i].ID
|
||||||
|
}
|
||||||
|
return _u.RemoveDailyRollupIDs(ids...)
|
||||||
|
}
|
||||||
|
|
||||||
// Where appends a list predicates to the ChannelMonitorUpdate builder.
|
// Where appends a list predicates to the ChannelMonitorUpdate builder.
|
||||||
func (_u *ChannelMonitorUpdateOne) Where(ps ...predicate.ChannelMonitor) *ChannelMonitorUpdateOne {
|
func (_u *ChannelMonitorUpdateOne) Where(ps ...predicate.ChannelMonitor) *ChannelMonitorUpdateOne {
|
||||||
_u.mutation.Where(ps...)
|
_u.mutation.Where(ps...)
|
||||||
@@ -902,6 +1020,51 @@ func (_u *ChannelMonitorUpdateOne) sqlSave(ctx context.Context) (_node *ChannelM
|
|||||||
}
|
}
|
||||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||||
}
|
}
|
||||||
|
if _u.mutation.DailyRollupsCleared() {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.O2M,
|
||||||
|
Inverse: false,
|
||||||
|
Table: channelmonitor.DailyRollupsTable,
|
||||||
|
Columns: []string{channelmonitor.DailyRollupsColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: sqlgraph.NewFieldSpec(channelmonitordailyrollup.FieldID, field.TypeInt64),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||||
|
}
|
||||||
|
if nodes := _u.mutation.RemovedDailyRollupsIDs(); len(nodes) > 0 && !_u.mutation.DailyRollupsCleared() {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.O2M,
|
||||||
|
Inverse: false,
|
||||||
|
Table: channelmonitor.DailyRollupsTable,
|
||||||
|
Columns: []string{channelmonitor.DailyRollupsColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: sqlgraph.NewFieldSpec(channelmonitordailyrollup.FieldID, field.TypeInt64),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||||
|
}
|
||||||
|
if nodes := _u.mutation.DailyRollupsIDs(); len(nodes) > 0 {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.O2M,
|
||||||
|
Inverse: false,
|
||||||
|
Table: channelmonitor.DailyRollupsTable,
|
||||||
|
Columns: []string{channelmonitor.DailyRollupsColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: sqlgraph.NewFieldSpec(channelmonitordailyrollup.FieldID, field.TypeInt64),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||||
|
}
|
||||||
_node = &ChannelMonitor{config: _u.config}
|
_node = &ChannelMonitor{config: _u.config}
|
||||||
_spec.Assign = _node.assignValues
|
_spec.Assign = _node.assignValues
|
||||||
_spec.ScanValues = _node.scanValues
|
_spec.ScanValues = _node.scanValues
|
||||||
|
|||||||
292
backend/ent/channelmonitordailyrollup.go
Normal file
292
backend/ent/channelmonitordailyrollup.go
Normal file
@@ -0,0 +1,292 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitor"
|
||||||
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitordailyrollup"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ChannelMonitorDailyRollup is the model entity for the ChannelMonitorDailyRollup schema.
|
||||||
|
type ChannelMonitorDailyRollup struct {
|
||||||
|
config `json:"-"`
|
||||||
|
// ID of the ent.
|
||||||
|
ID int64 `json:"id,omitempty"`
|
||||||
|
// DeletedAt holds the value of the "deleted_at" field.
|
||||||
|
DeletedAt *time.Time `json:"deleted_at,omitempty"`
|
||||||
|
// MonitorID holds the value of the "monitor_id" field.
|
||||||
|
MonitorID int64 `json:"monitor_id,omitempty"`
|
||||||
|
// Model holds the value of the "model" field.
|
||||||
|
Model string `json:"model,omitempty"`
|
||||||
|
// BucketDate holds the value of the "bucket_date" field.
|
||||||
|
BucketDate time.Time `json:"bucket_date,omitempty"`
|
||||||
|
// TotalChecks holds the value of the "total_checks" field.
|
||||||
|
TotalChecks int `json:"total_checks,omitempty"`
|
||||||
|
// OkCount holds the value of the "ok_count" field.
|
||||||
|
OkCount int `json:"ok_count,omitempty"`
|
||||||
|
// OperationalCount holds the value of the "operational_count" field.
|
||||||
|
OperationalCount int `json:"operational_count,omitempty"`
|
||||||
|
// DegradedCount holds the value of the "degraded_count" field.
|
||||||
|
DegradedCount int `json:"degraded_count,omitempty"`
|
||||||
|
// FailedCount holds the value of the "failed_count" field.
|
||||||
|
FailedCount int `json:"failed_count,omitempty"`
|
||||||
|
// ErrorCount holds the value of the "error_count" field.
|
||||||
|
ErrorCount int `json:"error_count,omitempty"`
|
||||||
|
// SumLatencyMs holds the value of the "sum_latency_ms" field.
|
||||||
|
SumLatencyMs int64 `json:"sum_latency_ms,omitempty"`
|
||||||
|
// CountLatency holds the value of the "count_latency" field.
|
||||||
|
CountLatency int `json:"count_latency,omitempty"`
|
||||||
|
// SumPingLatencyMs holds the value of the "sum_ping_latency_ms" field.
|
||||||
|
SumPingLatencyMs int64 `json:"sum_ping_latency_ms,omitempty"`
|
||||||
|
// CountPingLatency holds the value of the "count_ping_latency" field.
|
||||||
|
CountPingLatency int `json:"count_ping_latency,omitempty"`
|
||||||
|
// ComputedAt holds the value of the "computed_at" field.
|
||||||
|
ComputedAt time.Time `json:"computed_at,omitempty"`
|
||||||
|
// Edges holds the relations/edges for other nodes in the graph.
|
||||||
|
// The values are being populated by the ChannelMonitorDailyRollupQuery when eager-loading is set.
|
||||||
|
Edges ChannelMonitorDailyRollupEdges `json:"edges"`
|
||||||
|
selectValues sql.SelectValues
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChannelMonitorDailyRollupEdges holds the relations/edges for other nodes in the graph.
|
||||||
|
type ChannelMonitorDailyRollupEdges struct {
|
||||||
|
// Monitor holds the value of the monitor edge.
|
||||||
|
Monitor *ChannelMonitor `json:"monitor,omitempty"`
|
||||||
|
// loadedTypes holds the information for reporting if a
|
||||||
|
// type was loaded (or requested) in eager-loading or not.
|
||||||
|
loadedTypes [1]bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// MonitorOrErr returns the Monitor value or an error if the edge
|
||||||
|
// was not loaded in eager-loading, or loaded but was not found.
|
||||||
|
func (e ChannelMonitorDailyRollupEdges) MonitorOrErr() (*ChannelMonitor, error) {
|
||||||
|
if e.Monitor != nil {
|
||||||
|
return e.Monitor, nil
|
||||||
|
} else if e.loadedTypes[0] {
|
||||||
|
return nil, &NotFoundError{label: channelmonitor.Label}
|
||||||
|
}
|
||||||
|
return nil, &NotLoadedError{edge: "monitor"}
|
||||||
|
}
|
||||||
|
|
||||||
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
|
func (*ChannelMonitorDailyRollup) scanValues(columns []string) ([]any, error) {
|
||||||
|
values := make([]any, len(columns))
|
||||||
|
for i := range columns {
|
||||||
|
switch columns[i] {
|
||||||
|
case channelmonitordailyrollup.FieldID, channelmonitordailyrollup.FieldMonitorID, channelmonitordailyrollup.FieldTotalChecks, channelmonitordailyrollup.FieldOkCount, channelmonitordailyrollup.FieldOperationalCount, channelmonitordailyrollup.FieldDegradedCount, channelmonitordailyrollup.FieldFailedCount, channelmonitordailyrollup.FieldErrorCount, channelmonitordailyrollup.FieldSumLatencyMs, channelmonitordailyrollup.FieldCountLatency, channelmonitordailyrollup.FieldSumPingLatencyMs, channelmonitordailyrollup.FieldCountPingLatency:
|
||||||
|
values[i] = new(sql.NullInt64)
|
||||||
|
case channelmonitordailyrollup.FieldModel:
|
||||||
|
values[i] = new(sql.NullString)
|
||||||
|
case channelmonitordailyrollup.FieldDeletedAt, channelmonitordailyrollup.FieldBucketDate, channelmonitordailyrollup.FieldComputedAt:
|
||||||
|
values[i] = new(sql.NullTime)
|
||||||
|
default:
|
||||||
|
values[i] = new(sql.UnknownType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return values, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||||
|
// to the ChannelMonitorDailyRollup fields.
|
||||||
|
func (_m *ChannelMonitorDailyRollup) assignValues(columns []string, values []any) error {
|
||||||
|
if m, n := len(values), len(columns); m < n {
|
||||||
|
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||||
|
}
|
||||||
|
for i := range columns {
|
||||||
|
switch columns[i] {
|
||||||
|
case channelmonitordailyrollup.FieldID:
|
||||||
|
value, ok := values[i].(*sql.NullInt64)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field id", value)
|
||||||
|
}
|
||||||
|
_m.ID = int64(value.Int64)
|
||||||
|
case channelmonitordailyrollup.FieldDeletedAt:
|
||||||
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.DeletedAt = new(time.Time)
|
||||||
|
*_m.DeletedAt = value.Time
|
||||||
|
}
|
||||||
|
case channelmonitordailyrollup.FieldMonitorID:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field monitor_id", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.MonitorID = value.Int64
|
||||||
|
}
|
||||||
|
case channelmonitordailyrollup.FieldModel:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field model", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.Model = value.String
|
||||||
|
}
|
||||||
|
case channelmonitordailyrollup.FieldBucketDate:
|
||||||
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field bucket_date", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.BucketDate = value.Time
|
||||||
|
}
|
||||||
|
case channelmonitordailyrollup.FieldTotalChecks:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field total_checks", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.TotalChecks = int(value.Int64)
|
||||||
|
}
|
||||||
|
case channelmonitordailyrollup.FieldOkCount:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field ok_count", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.OkCount = int(value.Int64)
|
||||||
|
}
|
||||||
|
case channelmonitordailyrollup.FieldOperationalCount:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field operational_count", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.OperationalCount = int(value.Int64)
|
||||||
|
}
|
||||||
|
case channelmonitordailyrollup.FieldDegradedCount:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field degraded_count", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.DegradedCount = int(value.Int64)
|
||||||
|
}
|
||||||
|
case channelmonitordailyrollup.FieldFailedCount:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field failed_count", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.FailedCount = int(value.Int64)
|
||||||
|
}
|
||||||
|
case channelmonitordailyrollup.FieldErrorCount:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field error_count", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.ErrorCount = int(value.Int64)
|
||||||
|
}
|
||||||
|
case channelmonitordailyrollup.FieldSumLatencyMs:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field sum_latency_ms", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.SumLatencyMs = value.Int64
|
||||||
|
}
|
||||||
|
case channelmonitordailyrollup.FieldCountLatency:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field count_latency", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.CountLatency = int(value.Int64)
|
||||||
|
}
|
||||||
|
case channelmonitordailyrollup.FieldSumPingLatencyMs:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field sum_ping_latency_ms", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.SumPingLatencyMs = value.Int64
|
||||||
|
}
|
||||||
|
case channelmonitordailyrollup.FieldCountPingLatency:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field count_ping_latency", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.CountPingLatency = int(value.Int64)
|
||||||
|
}
|
||||||
|
case channelmonitordailyrollup.FieldComputedAt:
|
||||||
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field computed_at", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.ComputedAt = value.Time
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
_m.selectValues.Set(columns[i], values[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value returns the ent.Value that was dynamically selected and assigned to the ChannelMonitorDailyRollup.
|
||||||
|
// This includes values selected through modifiers, order, etc.
|
||||||
|
func (_m *ChannelMonitorDailyRollup) Value(name string) (ent.Value, error) {
|
||||||
|
return _m.selectValues.Get(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryMonitor queries the "monitor" edge of the ChannelMonitorDailyRollup entity.
|
||||||
|
func (_m *ChannelMonitorDailyRollup) QueryMonitor() *ChannelMonitorQuery {
|
||||||
|
return NewChannelMonitorDailyRollupClient(_m.config).QueryMonitor(_m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update returns a builder for updating this ChannelMonitorDailyRollup.
|
||||||
|
// Note that you need to call ChannelMonitorDailyRollup.Unwrap() before calling this method if this ChannelMonitorDailyRollup
|
||||||
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||||
|
func (_m *ChannelMonitorDailyRollup) Update() *ChannelMonitorDailyRollupUpdateOne {
|
||||||
|
return NewChannelMonitorDailyRollupClient(_m.config).UpdateOne(_m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unwrap unwraps the ChannelMonitorDailyRollup entity that was returned from a transaction after it was closed,
|
||||||
|
// so that all future queries will be executed through the driver which created the transaction.
|
||||||
|
func (_m *ChannelMonitorDailyRollup) Unwrap() *ChannelMonitorDailyRollup {
|
||||||
|
_tx, ok := _m.config.driver.(*txDriver)
|
||||||
|
if !ok {
|
||||||
|
panic("ent: ChannelMonitorDailyRollup is not a transactional entity")
|
||||||
|
}
|
||||||
|
_m.config.driver = _tx.drv
|
||||||
|
return _m
|
||||||
|
}
|
||||||
|
|
||||||
|
// String implements the fmt.Stringer.
|
||||||
|
func (_m *ChannelMonitorDailyRollup) String() string {
|
||||||
|
var builder strings.Builder
|
||||||
|
builder.WriteString("ChannelMonitorDailyRollup(")
|
||||||
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||||
|
if v := _m.DeletedAt; v != nil {
|
||||||
|
builder.WriteString("deleted_at=")
|
||||||
|
builder.WriteString(v.Format(time.ANSIC))
|
||||||
|
}
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("monitor_id=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", _m.MonitorID))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("model=")
|
||||||
|
builder.WriteString(_m.Model)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("bucket_date=")
|
||||||
|
builder.WriteString(_m.BucketDate.Format(time.ANSIC))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("total_checks=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", _m.TotalChecks))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("ok_count=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", _m.OkCount))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("operational_count=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", _m.OperationalCount))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("degraded_count=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", _m.DegradedCount))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("failed_count=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", _m.FailedCount))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("error_count=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", _m.ErrorCount))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("sum_latency_ms=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", _m.SumLatencyMs))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("count_latency=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", _m.CountLatency))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("sum_ping_latency_ms=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", _m.SumPingLatencyMs))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("count_ping_latency=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", _m.CountPingLatency))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("computed_at=")
|
||||||
|
builder.WriteString(_m.ComputedAt.Format(time.ANSIC))
|
||||||
|
builder.WriteByte(')')
|
||||||
|
return builder.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChannelMonitorDailyRollups is a parsable slice of ChannelMonitorDailyRollup.
|
||||||
|
type ChannelMonitorDailyRollups []*ChannelMonitorDailyRollup
|
||||||
@@ -0,0 +1,222 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package channelmonitordailyrollup
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Label holds the string label denoting the channelmonitordailyrollup type in the database.
|
||||||
|
Label = "channel_monitor_daily_rollup"
|
||||||
|
// FieldID holds the string denoting the id field in the database.
|
||||||
|
FieldID = "id"
|
||||||
|
// FieldDeletedAt holds the string denoting the deleted_at field in the database.
|
||||||
|
FieldDeletedAt = "deleted_at"
|
||||||
|
// FieldMonitorID holds the string denoting the monitor_id field in the database.
|
||||||
|
FieldMonitorID = "monitor_id"
|
||||||
|
// FieldModel holds the string denoting the model field in the database.
|
||||||
|
FieldModel = "model"
|
||||||
|
// FieldBucketDate holds the string denoting the bucket_date field in the database.
|
||||||
|
FieldBucketDate = "bucket_date"
|
||||||
|
// FieldTotalChecks holds the string denoting the total_checks field in the database.
|
||||||
|
FieldTotalChecks = "total_checks"
|
||||||
|
// FieldOkCount holds the string denoting the ok_count field in the database.
|
||||||
|
FieldOkCount = "ok_count"
|
||||||
|
// FieldOperationalCount holds the string denoting the operational_count field in the database.
|
||||||
|
FieldOperationalCount = "operational_count"
|
||||||
|
// FieldDegradedCount holds the string denoting the degraded_count field in the database.
|
||||||
|
FieldDegradedCount = "degraded_count"
|
||||||
|
// FieldFailedCount holds the string denoting the failed_count field in the database.
|
||||||
|
FieldFailedCount = "failed_count"
|
||||||
|
// FieldErrorCount holds the string denoting the error_count field in the database.
|
||||||
|
FieldErrorCount = "error_count"
|
||||||
|
// FieldSumLatencyMs holds the string denoting the sum_latency_ms field in the database.
|
||||||
|
FieldSumLatencyMs = "sum_latency_ms"
|
||||||
|
// FieldCountLatency holds the string denoting the count_latency field in the database.
|
||||||
|
FieldCountLatency = "count_latency"
|
||||||
|
// FieldSumPingLatencyMs holds the string denoting the sum_ping_latency_ms field in the database.
|
||||||
|
FieldSumPingLatencyMs = "sum_ping_latency_ms"
|
||||||
|
// FieldCountPingLatency holds the string denoting the count_ping_latency field in the database.
|
||||||
|
FieldCountPingLatency = "count_ping_latency"
|
||||||
|
// FieldComputedAt holds the string denoting the computed_at field in the database.
|
||||||
|
FieldComputedAt = "computed_at"
|
||||||
|
// EdgeMonitor holds the string denoting the monitor edge name in mutations.
|
||||||
|
EdgeMonitor = "monitor"
|
||||||
|
// Table holds the table name of the channelmonitordailyrollup in the database.
|
||||||
|
Table = "channel_monitor_daily_rollups"
|
||||||
|
// MonitorTable is the table that holds the monitor relation/edge.
|
||||||
|
MonitorTable = "channel_monitor_daily_rollups"
|
||||||
|
// MonitorInverseTable is the table name for the ChannelMonitor entity.
|
||||||
|
// It exists in this package in order to avoid circular dependency with the "channelmonitor" package.
|
||||||
|
MonitorInverseTable = "channel_monitors"
|
||||||
|
// MonitorColumn is the table column denoting the monitor relation/edge.
|
||||||
|
MonitorColumn = "monitor_id"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Columns holds all SQL columns for channelmonitordailyrollup fields.
|
||||||
|
var Columns = []string{
|
||||||
|
FieldID,
|
||||||
|
FieldDeletedAt,
|
||||||
|
FieldMonitorID,
|
||||||
|
FieldModel,
|
||||||
|
FieldBucketDate,
|
||||||
|
FieldTotalChecks,
|
||||||
|
FieldOkCount,
|
||||||
|
FieldOperationalCount,
|
||||||
|
FieldDegradedCount,
|
||||||
|
FieldFailedCount,
|
||||||
|
FieldErrorCount,
|
||||||
|
FieldSumLatencyMs,
|
||||||
|
FieldCountLatency,
|
||||||
|
FieldSumPingLatencyMs,
|
||||||
|
FieldCountPingLatency,
|
||||||
|
FieldComputedAt,
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||||
|
func ValidColumn(column string) bool {
|
||||||
|
for i := range Columns {
|
||||||
|
if column == Columns[i] {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note that the variables below are initialized by the runtime
|
||||||
|
// package on the initialization of the application. Therefore,
|
||||||
|
// it should be imported in the main as follows:
|
||||||
|
//
|
||||||
|
// import _ "github.com/Wei-Shaw/sub2api/ent/runtime"
|
||||||
|
var (
|
||||||
|
Hooks [1]ent.Hook
|
||||||
|
Interceptors [1]ent.Interceptor
|
||||||
|
// ModelValidator is a validator for the "model" field. It is called by the builders before save.
|
||||||
|
ModelValidator func(string) error
|
||||||
|
// DefaultTotalChecks holds the default value on creation for the "total_checks" field.
|
||||||
|
DefaultTotalChecks int
|
||||||
|
// DefaultOkCount holds the default value on creation for the "ok_count" field.
|
||||||
|
DefaultOkCount int
|
||||||
|
// DefaultOperationalCount holds the default value on creation for the "operational_count" field.
|
||||||
|
DefaultOperationalCount int
|
||||||
|
// DefaultDegradedCount holds the default value on creation for the "degraded_count" field.
|
||||||
|
DefaultDegradedCount int
|
||||||
|
// DefaultFailedCount holds the default value on creation for the "failed_count" field.
|
||||||
|
DefaultFailedCount int
|
||||||
|
// DefaultErrorCount holds the default value on creation for the "error_count" field.
|
||||||
|
DefaultErrorCount int
|
||||||
|
// DefaultSumLatencyMs holds the default value on creation for the "sum_latency_ms" field.
|
||||||
|
DefaultSumLatencyMs int64
|
||||||
|
// DefaultCountLatency holds the default value on creation for the "count_latency" field.
|
||||||
|
DefaultCountLatency int
|
||||||
|
// DefaultSumPingLatencyMs holds the default value on creation for the "sum_ping_latency_ms" field.
|
||||||
|
DefaultSumPingLatencyMs int64
|
||||||
|
// DefaultCountPingLatency holds the default value on creation for the "count_ping_latency" field.
|
||||||
|
DefaultCountPingLatency int
|
||||||
|
// DefaultComputedAt holds the default value on creation for the "computed_at" field.
|
||||||
|
DefaultComputedAt func() time.Time
|
||||||
|
// UpdateDefaultComputedAt holds the default value on update for the "computed_at" field.
|
||||||
|
UpdateDefaultComputedAt func() time.Time
|
||||||
|
)
|
||||||
|
|
||||||
|
// OrderOption defines the ordering options for the ChannelMonitorDailyRollup queries.
|
||||||
|
type OrderOption func(*sql.Selector)
|
||||||
|
|
||||||
|
// ByID orders the results by the id field.
|
||||||
|
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByDeletedAt orders the results by the deleted_at field.
|
||||||
|
func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByMonitorID orders the results by the monitor_id field.
|
||||||
|
func ByMonitorID(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldMonitorID, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByModel orders the results by the model field.
|
||||||
|
func ByModel(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldModel, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByBucketDate orders the results by the bucket_date field.
|
||||||
|
func ByBucketDate(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldBucketDate, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByTotalChecks orders the results by the total_checks field.
|
||||||
|
func ByTotalChecks(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldTotalChecks, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByOkCount orders the results by the ok_count field.
|
||||||
|
func ByOkCount(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldOkCount, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByOperationalCount orders the results by the operational_count field.
|
||||||
|
func ByOperationalCount(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldOperationalCount, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByDegradedCount orders the results by the degraded_count field.
|
||||||
|
func ByDegradedCount(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldDegradedCount, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByFailedCount orders the results by the failed_count field.
|
||||||
|
func ByFailedCount(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldFailedCount, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByErrorCount orders the results by the error_count field.
|
||||||
|
func ByErrorCount(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldErrorCount, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// BySumLatencyMs orders the results by the sum_latency_ms field.
|
||||||
|
func BySumLatencyMs(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldSumLatencyMs, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByCountLatency orders the results by the count_latency field.
|
||||||
|
func ByCountLatency(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldCountLatency, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// BySumPingLatencyMs orders the results by the sum_ping_latency_ms field.
|
||||||
|
func BySumPingLatencyMs(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldSumPingLatencyMs, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByCountPingLatency orders the results by the count_ping_latency field.
|
||||||
|
func ByCountPingLatency(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldCountPingLatency, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByComputedAt orders the results by the computed_at field.
|
||||||
|
func ByComputedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldComputedAt, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByMonitorField orders the results by monitor field.
|
||||||
|
func ByMonitorField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return func(s *sql.Selector) {
|
||||||
|
sqlgraph.OrderByNeighborTerms(s, newMonitorStep(), sql.OrderByField(field, opts...))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func newMonitorStep() *sqlgraph.Step {
|
||||||
|
return sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(Table, FieldID),
|
||||||
|
sqlgraph.To(MonitorInverseTable, FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.M2O, true, MonitorTable, MonitorColumn),
|
||||||
|
)
|
||||||
|
}
|
||||||
784
backend/ent/channelmonitordailyrollup/where.go
Normal file
784
backend/ent/channelmonitordailyrollup/where.go
Normal file
@@ -0,0 +1,784 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package channelmonitordailyrollup
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"github.com/Wei-Shaw/sub2api/ent/predicate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ID filters vertices based on their ID field.
|
||||||
|
func ID(id int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDEQ applies the EQ predicate on the ID field.
|
||||||
|
func IDEQ(id int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNEQ applies the NEQ predicate on the ID field.
|
||||||
|
func IDNEQ(id int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDIn applies the In predicate on the ID field.
|
||||||
|
func IDIn(ids ...int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNotIn applies the NotIn predicate on the ID field.
|
||||||
|
func IDNotIn(ids ...int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNotIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGT applies the GT predicate on the ID field.
|
||||||
|
func IDGT(id int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGTE applies the GTE predicate on the ID field.
|
||||||
|
func IDGTE(id int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGTE(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLT applies the LT predicate on the ID field.
|
||||||
|
func IDLT(id int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLTE applies the LTE predicate on the ID field.
|
||||||
|
func IDLTE(id int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLTE(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ.
|
||||||
|
func DeletedAt(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldDeletedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MonitorID applies equality check predicate on the "monitor_id" field. It's identical to MonitorIDEQ.
|
||||||
|
func MonitorID(v int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldMonitorID, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Model applies equality check predicate on the "model" field. It's identical to ModelEQ.
|
||||||
|
func Model(v string) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldModel, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// BucketDate applies equality check predicate on the "bucket_date" field. It's identical to BucketDateEQ.
|
||||||
|
func BucketDate(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldBucketDate, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// TotalChecks applies equality check predicate on the "total_checks" field. It's identical to TotalChecksEQ.
|
||||||
|
func TotalChecks(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldTotalChecks, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OkCount applies equality check predicate on the "ok_count" field. It's identical to OkCountEQ.
|
||||||
|
func OkCount(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldOkCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperationalCount applies equality check predicate on the "operational_count" field. It's identical to OperationalCountEQ.
|
||||||
|
func OperationalCount(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldOperationalCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DegradedCount applies equality check predicate on the "degraded_count" field. It's identical to DegradedCountEQ.
|
||||||
|
func DegradedCount(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldDegradedCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FailedCount applies equality check predicate on the "failed_count" field. It's identical to FailedCountEQ.
|
||||||
|
func FailedCount(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldFailedCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrorCount applies equality check predicate on the "error_count" field. It's identical to ErrorCountEQ.
|
||||||
|
func ErrorCount(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldErrorCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SumLatencyMs applies equality check predicate on the "sum_latency_ms" field. It's identical to SumLatencyMsEQ.
|
||||||
|
func SumLatencyMs(v int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldSumLatencyMs, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountLatency applies equality check predicate on the "count_latency" field. It's identical to CountLatencyEQ.
|
||||||
|
func CountLatency(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldCountLatency, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SumPingLatencyMs applies equality check predicate on the "sum_ping_latency_ms" field. It's identical to SumPingLatencyMsEQ.
|
||||||
|
func SumPingLatencyMs(v int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldSumPingLatencyMs, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountPingLatency applies equality check predicate on the "count_ping_latency" field. It's identical to CountPingLatencyEQ.
|
||||||
|
func CountPingLatency(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldCountPingLatency, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ComputedAt applies equality check predicate on the "computed_at" field. It's identical to ComputedAtEQ.
|
||||||
|
func ComputedAt(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldComputedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletedAtEQ applies the EQ predicate on the "deleted_at" field.
|
||||||
|
func DeletedAtEQ(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldDeletedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field.
|
||||||
|
func DeletedAtNEQ(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNEQ(FieldDeletedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletedAtIn applies the In predicate on the "deleted_at" field.
|
||||||
|
func DeletedAtIn(vs ...time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldIn(FieldDeletedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field.
|
||||||
|
func DeletedAtNotIn(vs ...time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNotIn(FieldDeletedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletedAtGT applies the GT predicate on the "deleted_at" field.
|
||||||
|
func DeletedAtGT(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGT(FieldDeletedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletedAtGTE applies the GTE predicate on the "deleted_at" field.
|
||||||
|
func DeletedAtGTE(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGTE(FieldDeletedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletedAtLT applies the LT predicate on the "deleted_at" field.
|
||||||
|
func DeletedAtLT(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLT(FieldDeletedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletedAtLTE applies the LTE predicate on the "deleted_at" field.
|
||||||
|
func DeletedAtLTE(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLTE(FieldDeletedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field.
|
||||||
|
func DeletedAtIsNil() predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldIsNull(FieldDeletedAt))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field.
|
||||||
|
func DeletedAtNotNil() predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNotNull(FieldDeletedAt))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MonitorIDEQ applies the EQ predicate on the "monitor_id" field.
|
||||||
|
func MonitorIDEQ(v int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldMonitorID, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MonitorIDNEQ applies the NEQ predicate on the "monitor_id" field.
|
||||||
|
func MonitorIDNEQ(v int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNEQ(FieldMonitorID, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MonitorIDIn applies the In predicate on the "monitor_id" field.
|
||||||
|
func MonitorIDIn(vs ...int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldIn(FieldMonitorID, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MonitorIDNotIn applies the NotIn predicate on the "monitor_id" field.
|
||||||
|
func MonitorIDNotIn(vs ...int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNotIn(FieldMonitorID, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ModelEQ applies the EQ predicate on the "model" field.
|
||||||
|
func ModelEQ(v string) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldModel, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ModelNEQ applies the NEQ predicate on the "model" field.
|
||||||
|
func ModelNEQ(v string) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNEQ(FieldModel, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ModelIn applies the In predicate on the "model" field.
|
||||||
|
func ModelIn(vs ...string) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldIn(FieldModel, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ModelNotIn applies the NotIn predicate on the "model" field.
|
||||||
|
func ModelNotIn(vs ...string) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNotIn(FieldModel, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ModelGT applies the GT predicate on the "model" field.
|
||||||
|
func ModelGT(v string) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGT(FieldModel, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ModelGTE applies the GTE predicate on the "model" field.
|
||||||
|
func ModelGTE(v string) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGTE(FieldModel, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ModelLT applies the LT predicate on the "model" field.
|
||||||
|
func ModelLT(v string) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLT(FieldModel, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ModelLTE applies the LTE predicate on the "model" field.
|
||||||
|
func ModelLTE(v string) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLTE(FieldModel, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ModelContains applies the Contains predicate on the "model" field.
|
||||||
|
func ModelContains(v string) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldContains(FieldModel, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ModelHasPrefix applies the HasPrefix predicate on the "model" field.
|
||||||
|
func ModelHasPrefix(v string) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldHasPrefix(FieldModel, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ModelHasSuffix applies the HasSuffix predicate on the "model" field.
|
||||||
|
func ModelHasSuffix(v string) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldHasSuffix(FieldModel, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ModelEqualFold applies the EqualFold predicate on the "model" field.
|
||||||
|
func ModelEqualFold(v string) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEqualFold(FieldModel, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ModelContainsFold applies the ContainsFold predicate on the "model" field.
|
||||||
|
func ModelContainsFold(v string) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldContainsFold(FieldModel, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// BucketDateEQ applies the EQ predicate on the "bucket_date" field.
|
||||||
|
func BucketDateEQ(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldBucketDate, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// BucketDateNEQ applies the NEQ predicate on the "bucket_date" field.
|
||||||
|
func BucketDateNEQ(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNEQ(FieldBucketDate, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// BucketDateIn applies the In predicate on the "bucket_date" field.
|
||||||
|
func BucketDateIn(vs ...time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldIn(FieldBucketDate, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// BucketDateNotIn applies the NotIn predicate on the "bucket_date" field.
|
||||||
|
func BucketDateNotIn(vs ...time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNotIn(FieldBucketDate, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// BucketDateGT applies the GT predicate on the "bucket_date" field.
|
||||||
|
func BucketDateGT(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGT(FieldBucketDate, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// BucketDateGTE applies the GTE predicate on the "bucket_date" field.
|
||||||
|
func BucketDateGTE(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGTE(FieldBucketDate, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// BucketDateLT applies the LT predicate on the "bucket_date" field.
|
||||||
|
func BucketDateLT(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLT(FieldBucketDate, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// BucketDateLTE applies the LTE predicate on the "bucket_date" field.
|
||||||
|
func BucketDateLTE(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLTE(FieldBucketDate, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// TotalChecksEQ applies the EQ predicate on the "total_checks" field.
|
||||||
|
func TotalChecksEQ(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldTotalChecks, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// TotalChecksNEQ applies the NEQ predicate on the "total_checks" field.
|
||||||
|
func TotalChecksNEQ(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNEQ(FieldTotalChecks, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// TotalChecksIn applies the In predicate on the "total_checks" field.
|
||||||
|
func TotalChecksIn(vs ...int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldIn(FieldTotalChecks, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// TotalChecksNotIn applies the NotIn predicate on the "total_checks" field.
|
||||||
|
func TotalChecksNotIn(vs ...int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNotIn(FieldTotalChecks, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// TotalChecksGT applies the GT predicate on the "total_checks" field.
|
||||||
|
func TotalChecksGT(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGT(FieldTotalChecks, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// TotalChecksGTE applies the GTE predicate on the "total_checks" field.
|
||||||
|
func TotalChecksGTE(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGTE(FieldTotalChecks, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// TotalChecksLT applies the LT predicate on the "total_checks" field.
|
||||||
|
func TotalChecksLT(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLT(FieldTotalChecks, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// TotalChecksLTE applies the LTE predicate on the "total_checks" field.
|
||||||
|
func TotalChecksLTE(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLTE(FieldTotalChecks, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OkCountEQ applies the EQ predicate on the "ok_count" field.
|
||||||
|
func OkCountEQ(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldOkCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OkCountNEQ applies the NEQ predicate on the "ok_count" field.
|
||||||
|
func OkCountNEQ(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNEQ(FieldOkCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OkCountIn applies the In predicate on the "ok_count" field.
|
||||||
|
func OkCountIn(vs ...int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldIn(FieldOkCount, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OkCountNotIn applies the NotIn predicate on the "ok_count" field.
|
||||||
|
func OkCountNotIn(vs ...int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNotIn(FieldOkCount, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OkCountGT applies the GT predicate on the "ok_count" field.
|
||||||
|
func OkCountGT(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGT(FieldOkCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OkCountGTE applies the GTE predicate on the "ok_count" field.
|
||||||
|
func OkCountGTE(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGTE(FieldOkCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OkCountLT applies the LT predicate on the "ok_count" field.
|
||||||
|
func OkCountLT(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLT(FieldOkCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OkCountLTE applies the LTE predicate on the "ok_count" field.
|
||||||
|
func OkCountLTE(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLTE(FieldOkCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperationalCountEQ applies the EQ predicate on the "operational_count" field.
|
||||||
|
func OperationalCountEQ(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldOperationalCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperationalCountNEQ applies the NEQ predicate on the "operational_count" field.
|
||||||
|
func OperationalCountNEQ(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNEQ(FieldOperationalCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperationalCountIn applies the In predicate on the "operational_count" field.
|
||||||
|
func OperationalCountIn(vs ...int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldIn(FieldOperationalCount, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperationalCountNotIn applies the NotIn predicate on the "operational_count" field.
|
||||||
|
func OperationalCountNotIn(vs ...int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNotIn(FieldOperationalCount, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperationalCountGT applies the GT predicate on the "operational_count" field.
|
||||||
|
func OperationalCountGT(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGT(FieldOperationalCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperationalCountGTE applies the GTE predicate on the "operational_count" field.
|
||||||
|
func OperationalCountGTE(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGTE(FieldOperationalCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperationalCountLT applies the LT predicate on the "operational_count" field.
|
||||||
|
func OperationalCountLT(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLT(FieldOperationalCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperationalCountLTE applies the LTE predicate on the "operational_count" field.
|
||||||
|
func OperationalCountLTE(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLTE(FieldOperationalCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DegradedCountEQ applies the EQ predicate on the "degraded_count" field.
|
||||||
|
func DegradedCountEQ(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldDegradedCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DegradedCountNEQ applies the NEQ predicate on the "degraded_count" field.
|
||||||
|
func DegradedCountNEQ(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNEQ(FieldDegradedCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DegradedCountIn applies the In predicate on the "degraded_count" field.
|
||||||
|
func DegradedCountIn(vs ...int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldIn(FieldDegradedCount, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DegradedCountNotIn applies the NotIn predicate on the "degraded_count" field.
|
||||||
|
func DegradedCountNotIn(vs ...int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNotIn(FieldDegradedCount, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DegradedCountGT applies the GT predicate on the "degraded_count" field.
|
||||||
|
func DegradedCountGT(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGT(FieldDegradedCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DegradedCountGTE applies the GTE predicate on the "degraded_count" field.
|
||||||
|
func DegradedCountGTE(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGTE(FieldDegradedCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DegradedCountLT applies the LT predicate on the "degraded_count" field.
|
||||||
|
func DegradedCountLT(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLT(FieldDegradedCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DegradedCountLTE applies the LTE predicate on the "degraded_count" field.
|
||||||
|
func DegradedCountLTE(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLTE(FieldDegradedCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FailedCountEQ applies the EQ predicate on the "failed_count" field.
|
||||||
|
func FailedCountEQ(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldFailedCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FailedCountNEQ applies the NEQ predicate on the "failed_count" field.
|
||||||
|
func FailedCountNEQ(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNEQ(FieldFailedCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FailedCountIn applies the In predicate on the "failed_count" field.
|
||||||
|
func FailedCountIn(vs ...int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldIn(FieldFailedCount, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FailedCountNotIn applies the NotIn predicate on the "failed_count" field.
|
||||||
|
func FailedCountNotIn(vs ...int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNotIn(FieldFailedCount, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FailedCountGT applies the GT predicate on the "failed_count" field.
|
||||||
|
func FailedCountGT(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGT(FieldFailedCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FailedCountGTE applies the GTE predicate on the "failed_count" field.
|
||||||
|
func FailedCountGTE(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGTE(FieldFailedCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FailedCountLT applies the LT predicate on the "failed_count" field.
|
||||||
|
func FailedCountLT(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLT(FieldFailedCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FailedCountLTE applies the LTE predicate on the "failed_count" field.
|
||||||
|
func FailedCountLTE(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLTE(FieldFailedCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrorCountEQ applies the EQ predicate on the "error_count" field.
|
||||||
|
func ErrorCountEQ(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldErrorCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrorCountNEQ applies the NEQ predicate on the "error_count" field.
|
||||||
|
func ErrorCountNEQ(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNEQ(FieldErrorCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrorCountIn applies the In predicate on the "error_count" field.
|
||||||
|
func ErrorCountIn(vs ...int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldIn(FieldErrorCount, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrorCountNotIn applies the NotIn predicate on the "error_count" field.
|
||||||
|
func ErrorCountNotIn(vs ...int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNotIn(FieldErrorCount, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrorCountGT applies the GT predicate on the "error_count" field.
|
||||||
|
func ErrorCountGT(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGT(FieldErrorCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrorCountGTE applies the GTE predicate on the "error_count" field.
|
||||||
|
func ErrorCountGTE(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGTE(FieldErrorCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrorCountLT applies the LT predicate on the "error_count" field.
|
||||||
|
func ErrorCountLT(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLT(FieldErrorCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrorCountLTE applies the LTE predicate on the "error_count" field.
|
||||||
|
func ErrorCountLTE(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLTE(FieldErrorCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SumLatencyMsEQ applies the EQ predicate on the "sum_latency_ms" field.
|
||||||
|
func SumLatencyMsEQ(v int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldSumLatencyMs, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SumLatencyMsNEQ applies the NEQ predicate on the "sum_latency_ms" field.
|
||||||
|
func SumLatencyMsNEQ(v int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNEQ(FieldSumLatencyMs, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SumLatencyMsIn applies the In predicate on the "sum_latency_ms" field.
|
||||||
|
func SumLatencyMsIn(vs ...int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldIn(FieldSumLatencyMs, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SumLatencyMsNotIn applies the NotIn predicate on the "sum_latency_ms" field.
|
||||||
|
func SumLatencyMsNotIn(vs ...int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNotIn(FieldSumLatencyMs, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SumLatencyMsGT applies the GT predicate on the "sum_latency_ms" field.
|
||||||
|
func SumLatencyMsGT(v int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGT(FieldSumLatencyMs, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SumLatencyMsGTE applies the GTE predicate on the "sum_latency_ms" field.
|
||||||
|
func SumLatencyMsGTE(v int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGTE(FieldSumLatencyMs, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SumLatencyMsLT applies the LT predicate on the "sum_latency_ms" field.
|
||||||
|
func SumLatencyMsLT(v int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLT(FieldSumLatencyMs, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SumLatencyMsLTE applies the LTE predicate on the "sum_latency_ms" field.
|
||||||
|
func SumLatencyMsLTE(v int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLTE(FieldSumLatencyMs, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountLatencyEQ applies the EQ predicate on the "count_latency" field.
|
||||||
|
func CountLatencyEQ(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldCountLatency, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountLatencyNEQ applies the NEQ predicate on the "count_latency" field.
|
||||||
|
func CountLatencyNEQ(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNEQ(FieldCountLatency, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountLatencyIn applies the In predicate on the "count_latency" field.
|
||||||
|
func CountLatencyIn(vs ...int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldIn(FieldCountLatency, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountLatencyNotIn applies the NotIn predicate on the "count_latency" field.
|
||||||
|
func CountLatencyNotIn(vs ...int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNotIn(FieldCountLatency, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountLatencyGT applies the GT predicate on the "count_latency" field.
|
||||||
|
func CountLatencyGT(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGT(FieldCountLatency, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountLatencyGTE applies the GTE predicate on the "count_latency" field.
|
||||||
|
func CountLatencyGTE(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGTE(FieldCountLatency, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountLatencyLT applies the LT predicate on the "count_latency" field.
|
||||||
|
func CountLatencyLT(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLT(FieldCountLatency, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountLatencyLTE applies the LTE predicate on the "count_latency" field.
|
||||||
|
func CountLatencyLTE(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLTE(FieldCountLatency, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SumPingLatencyMsEQ applies the EQ predicate on the "sum_ping_latency_ms" field.
|
||||||
|
func SumPingLatencyMsEQ(v int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldSumPingLatencyMs, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SumPingLatencyMsNEQ applies the NEQ predicate on the "sum_ping_latency_ms" field.
|
||||||
|
func SumPingLatencyMsNEQ(v int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNEQ(FieldSumPingLatencyMs, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SumPingLatencyMsIn applies the In predicate on the "sum_ping_latency_ms" field.
|
||||||
|
func SumPingLatencyMsIn(vs ...int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldIn(FieldSumPingLatencyMs, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SumPingLatencyMsNotIn applies the NotIn predicate on the "sum_ping_latency_ms" field.
|
||||||
|
func SumPingLatencyMsNotIn(vs ...int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNotIn(FieldSumPingLatencyMs, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SumPingLatencyMsGT applies the GT predicate on the "sum_ping_latency_ms" field.
|
||||||
|
func SumPingLatencyMsGT(v int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGT(FieldSumPingLatencyMs, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SumPingLatencyMsGTE applies the GTE predicate on the "sum_ping_latency_ms" field.
|
||||||
|
func SumPingLatencyMsGTE(v int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGTE(FieldSumPingLatencyMs, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SumPingLatencyMsLT applies the LT predicate on the "sum_ping_latency_ms" field.
|
||||||
|
func SumPingLatencyMsLT(v int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLT(FieldSumPingLatencyMs, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SumPingLatencyMsLTE applies the LTE predicate on the "sum_ping_latency_ms" field.
|
||||||
|
func SumPingLatencyMsLTE(v int64) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLTE(FieldSumPingLatencyMs, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountPingLatencyEQ applies the EQ predicate on the "count_ping_latency" field.
|
||||||
|
func CountPingLatencyEQ(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldCountPingLatency, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountPingLatencyNEQ applies the NEQ predicate on the "count_ping_latency" field.
|
||||||
|
func CountPingLatencyNEQ(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNEQ(FieldCountPingLatency, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountPingLatencyIn applies the In predicate on the "count_ping_latency" field.
|
||||||
|
func CountPingLatencyIn(vs ...int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldIn(FieldCountPingLatency, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountPingLatencyNotIn applies the NotIn predicate on the "count_ping_latency" field.
|
||||||
|
func CountPingLatencyNotIn(vs ...int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNotIn(FieldCountPingLatency, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountPingLatencyGT applies the GT predicate on the "count_ping_latency" field.
|
||||||
|
func CountPingLatencyGT(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGT(FieldCountPingLatency, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountPingLatencyGTE applies the GTE predicate on the "count_ping_latency" field.
|
||||||
|
func CountPingLatencyGTE(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGTE(FieldCountPingLatency, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountPingLatencyLT applies the LT predicate on the "count_ping_latency" field.
|
||||||
|
func CountPingLatencyLT(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLT(FieldCountPingLatency, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountPingLatencyLTE applies the LTE predicate on the "count_ping_latency" field.
|
||||||
|
func CountPingLatencyLTE(v int) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLTE(FieldCountPingLatency, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ComputedAtEQ applies the EQ predicate on the "computed_at" field.
|
||||||
|
func ComputedAtEQ(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldComputedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ComputedAtNEQ applies the NEQ predicate on the "computed_at" field.
|
||||||
|
func ComputedAtNEQ(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNEQ(FieldComputedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ComputedAtIn applies the In predicate on the "computed_at" field.
|
||||||
|
func ComputedAtIn(vs ...time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldIn(FieldComputedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ComputedAtNotIn applies the NotIn predicate on the "computed_at" field.
|
||||||
|
func ComputedAtNotIn(vs ...time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldNotIn(FieldComputedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ComputedAtGT applies the GT predicate on the "computed_at" field.
|
||||||
|
func ComputedAtGT(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGT(FieldComputedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ComputedAtGTE applies the GTE predicate on the "computed_at" field.
|
||||||
|
func ComputedAtGTE(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldGTE(FieldComputedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ComputedAtLT applies the LT predicate on the "computed_at" field.
|
||||||
|
func ComputedAtLT(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLT(FieldComputedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ComputedAtLTE applies the LTE predicate on the "computed_at" field.
|
||||||
|
func ComputedAtLTE(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.FieldLTE(FieldComputedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasMonitor applies the HasEdge predicate on the "monitor" edge.
|
||||||
|
func HasMonitor() predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(func(s *sql.Selector) {
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(Table, FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.M2O, true, MonitorTable, MonitorColumn),
|
||||||
|
)
|
||||||
|
sqlgraph.HasNeighbors(s, step)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasMonitorWith applies the HasEdge predicate on the "monitor" edge with a given conditions (other predicates).
|
||||||
|
func HasMonitorWith(preds ...predicate.ChannelMonitor) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(func(s *sql.Selector) {
|
||||||
|
step := newMonitorStep()
|
||||||
|
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||||
|
for _, p := range preds {
|
||||||
|
p(s)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// And groups predicates with the AND operator between them.
|
||||||
|
func And(predicates ...predicate.ChannelMonitorDailyRollup) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.AndPredicates(predicates...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Or groups predicates with the OR operator between them.
|
||||||
|
func Or(predicates ...predicate.ChannelMonitorDailyRollup) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.OrPredicates(predicates...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not applies the not operator on the given predicate.
|
||||||
|
func Not(p predicate.ChannelMonitorDailyRollup) predicate.ChannelMonitorDailyRollup {
|
||||||
|
return predicate.ChannelMonitorDailyRollup(sql.NotPredicates(p))
|
||||||
|
}
|
||||||
1593
backend/ent/channelmonitordailyrollup_create.go
Normal file
1593
backend/ent/channelmonitordailyrollup_create.go
Normal file
File diff suppressed because it is too large
Load Diff
88
backend/ent/channelmonitordailyrollup_delete.go
Normal file
88
backend/ent/channelmonitordailyrollup_delete.go
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitordailyrollup"
|
||||||
|
"github.com/Wei-Shaw/sub2api/ent/predicate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ChannelMonitorDailyRollupDelete is the builder for deleting a ChannelMonitorDailyRollup entity.
|
||||||
|
type ChannelMonitorDailyRollupDelete struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *ChannelMonitorDailyRollupMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the ChannelMonitorDailyRollupDelete builder.
|
||||||
|
func (_d *ChannelMonitorDailyRollupDelete) Where(ps ...predicate.ChannelMonitorDailyRollup) *ChannelMonitorDailyRollupDelete {
|
||||||
|
_d.mutation.Where(ps...)
|
||||||
|
return _d
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||||
|
func (_d *ChannelMonitorDailyRollupDelete) Exec(ctx context.Context) (int, error) {
|
||||||
|
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_d *ChannelMonitorDailyRollupDelete) ExecX(ctx context.Context) int {
|
||||||
|
n, err := _d.Exec(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_d *ChannelMonitorDailyRollupDelete) sqlExec(ctx context.Context) (int, error) {
|
||||||
|
_spec := sqlgraph.NewDeleteSpec(channelmonitordailyrollup.Table, sqlgraph.NewFieldSpec(channelmonitordailyrollup.FieldID, field.TypeInt64))
|
||||||
|
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||||
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
_d.mutation.done = true
|
||||||
|
return affected, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChannelMonitorDailyRollupDeleteOne is the builder for deleting a single ChannelMonitorDailyRollup entity.
|
||||||
|
type ChannelMonitorDailyRollupDeleteOne struct {
|
||||||
|
_d *ChannelMonitorDailyRollupDelete
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the ChannelMonitorDailyRollupDelete builder.
|
||||||
|
func (_d *ChannelMonitorDailyRollupDeleteOne) Where(ps ...predicate.ChannelMonitorDailyRollup) *ChannelMonitorDailyRollupDeleteOne {
|
||||||
|
_d._d.mutation.Where(ps...)
|
||||||
|
return _d
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query.
|
||||||
|
func (_d *ChannelMonitorDailyRollupDeleteOne) Exec(ctx context.Context) error {
|
||||||
|
n, err := _d._d.Exec(ctx)
|
||||||
|
switch {
|
||||||
|
case err != nil:
|
||||||
|
return err
|
||||||
|
case n == 0:
|
||||||
|
return &NotFoundError{channelmonitordailyrollup.Label}
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_d *ChannelMonitorDailyRollupDeleteOne) ExecX(ctx context.Context) {
|
||||||
|
if err := _d.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
643
backend/ent/channelmonitordailyrollup_query.go
Normal file
643
backend/ent/channelmonitordailyrollup_query.go
Normal file
@@ -0,0 +1,643 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"math"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitor"
|
||||||
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitordailyrollup"
|
||||||
|
"github.com/Wei-Shaw/sub2api/ent/predicate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ChannelMonitorDailyRollupQuery is the builder for querying ChannelMonitorDailyRollup entities.
|
||||||
|
type ChannelMonitorDailyRollupQuery struct {
|
||||||
|
config
|
||||||
|
ctx *QueryContext
|
||||||
|
order []channelmonitordailyrollup.OrderOption
|
||||||
|
inters []Interceptor
|
||||||
|
predicates []predicate.ChannelMonitorDailyRollup
|
||||||
|
withMonitor *ChannelMonitorQuery
|
||||||
|
modifiers []func(*sql.Selector)
|
||||||
|
// intermediate query (i.e. traversal path).
|
||||||
|
sql *sql.Selector
|
||||||
|
path func(context.Context) (*sql.Selector, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where adds a new predicate for the ChannelMonitorDailyRollupQuery builder.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) Where(ps ...predicate.ChannelMonitorDailyRollup) *ChannelMonitorDailyRollupQuery {
|
||||||
|
_q.predicates = append(_q.predicates, ps...)
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// Limit the number of records to be returned by this query.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) Limit(limit int) *ChannelMonitorDailyRollupQuery {
|
||||||
|
_q.ctx.Limit = &limit
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// Offset to start from.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) Offset(offset int) *ChannelMonitorDailyRollupQuery {
|
||||||
|
_q.ctx.Offset = &offset
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unique configures the query builder to filter duplicate records on query.
|
||||||
|
// By default, unique is set to true, and can be disabled using this method.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) Unique(unique bool) *ChannelMonitorDailyRollupQuery {
|
||||||
|
_q.ctx.Unique = &unique
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// Order specifies how the records should be ordered.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) Order(o ...channelmonitordailyrollup.OrderOption) *ChannelMonitorDailyRollupQuery {
|
||||||
|
_q.order = append(_q.order, o...)
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryMonitor chains the current query on the "monitor" edge.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) QueryMonitor() *ChannelMonitorQuery {
|
||||||
|
query := (&ChannelMonitorClient{config: _q.config}).Query()
|
||||||
|
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||||
|
if err := _q.prepareQuery(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
selector := _q.sqlQuery(ctx)
|
||||||
|
if err := selector.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(channelmonitordailyrollup.Table, channelmonitordailyrollup.FieldID, selector),
|
||||||
|
sqlgraph.To(channelmonitor.Table, channelmonitor.FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.M2O, true, channelmonitordailyrollup.MonitorTable, channelmonitordailyrollup.MonitorColumn),
|
||||||
|
)
|
||||||
|
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||||
|
return fromU, nil
|
||||||
|
}
|
||||||
|
return query
|
||||||
|
}
|
||||||
|
|
||||||
|
// First returns the first ChannelMonitorDailyRollup entity from the query.
|
||||||
|
// Returns a *NotFoundError when no ChannelMonitorDailyRollup was found.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) First(ctx context.Context) (*ChannelMonitorDailyRollup, error) {
|
||||||
|
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nil, &NotFoundError{channelmonitordailyrollup.Label}
|
||||||
|
}
|
||||||
|
return nodes[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstX is like First, but panics if an error occurs.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) FirstX(ctx context.Context) *ChannelMonitorDailyRollup {
|
||||||
|
node, err := _q.First(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstID returns the first ChannelMonitorDailyRollup ID from the query.
|
||||||
|
// Returns a *NotFoundError when no ChannelMonitorDailyRollup ID was found.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) FirstID(ctx context.Context) (id int64, err error) {
|
||||||
|
var ids []int64
|
||||||
|
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(ids) == 0 {
|
||||||
|
err = &NotFoundError{channelmonitordailyrollup.Label}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return ids[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) FirstIDX(ctx context.Context) int64 {
|
||||||
|
id, err := _q.FirstID(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only returns a single ChannelMonitorDailyRollup entity found by the query, ensuring it only returns one.
|
||||||
|
// Returns a *NotSingularError when more than one ChannelMonitorDailyRollup entity is found.
|
||||||
|
// Returns a *NotFoundError when no ChannelMonitorDailyRollup entities are found.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) Only(ctx context.Context) (*ChannelMonitorDailyRollup, error) {
|
||||||
|
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
switch len(nodes) {
|
||||||
|
case 1:
|
||||||
|
return nodes[0], nil
|
||||||
|
case 0:
|
||||||
|
return nil, &NotFoundError{channelmonitordailyrollup.Label}
|
||||||
|
default:
|
||||||
|
return nil, &NotSingularError{channelmonitordailyrollup.Label}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyX is like Only, but panics if an error occurs.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) OnlyX(ctx context.Context) *ChannelMonitorDailyRollup {
|
||||||
|
node, err := _q.Only(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyID is like Only, but returns the only ChannelMonitorDailyRollup ID in the query.
|
||||||
|
// Returns a *NotSingularError when more than one ChannelMonitorDailyRollup ID is found.
|
||||||
|
// Returns a *NotFoundError when no entities are found.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) OnlyID(ctx context.Context) (id int64, err error) {
|
||||||
|
var ids []int64
|
||||||
|
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch len(ids) {
|
||||||
|
case 1:
|
||||||
|
id = ids[0]
|
||||||
|
case 0:
|
||||||
|
err = &NotFoundError{channelmonitordailyrollup.Label}
|
||||||
|
default:
|
||||||
|
err = &NotSingularError{channelmonitordailyrollup.Label}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) OnlyIDX(ctx context.Context) int64 {
|
||||||
|
id, err := _q.OnlyID(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// All executes the query and returns a list of ChannelMonitorDailyRollups.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) All(ctx context.Context) ([]*ChannelMonitorDailyRollup, error) {
|
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||||
|
if err := _q.prepareQuery(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
qr := querierAll[[]*ChannelMonitorDailyRollup, *ChannelMonitorDailyRollupQuery]()
|
||||||
|
return withInterceptors[[]*ChannelMonitorDailyRollup](ctx, _q, qr, _q.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AllX is like All, but panics if an error occurs.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) AllX(ctx context.Context) []*ChannelMonitorDailyRollup {
|
||||||
|
nodes, err := _q.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return nodes
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs executes the query and returns a list of ChannelMonitorDailyRollup IDs.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) IDs(ctx context.Context) (ids []int64, err error) {
|
||||||
|
if _q.ctx.Unique == nil && _q.path != nil {
|
||||||
|
_q.Unique(true)
|
||||||
|
}
|
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||||
|
if err = _q.Select(channelmonitordailyrollup.FieldID).Scan(ctx, &ids); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ids, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDsX is like IDs, but panics if an error occurs.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) IDsX(ctx context.Context) []int64 {
|
||||||
|
ids, err := _q.IDs(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return ids
|
||||||
|
}
|
||||||
|
|
||||||
|
// Count returns the count of the given query.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) Count(ctx context.Context) (int, error) {
|
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||||
|
if err := _q.prepareQuery(ctx); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return withInterceptors[int](ctx, _q, querierCount[*ChannelMonitorDailyRollupQuery](), _q.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountX is like Count, but panics if an error occurs.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) CountX(ctx context.Context) int {
|
||||||
|
count, err := _q.Count(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exist returns true if the query has elements in the graph.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) Exist(ctx context.Context) (bool, error) {
|
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||||
|
switch _, err := _q.FirstID(ctx); {
|
||||||
|
case IsNotFound(err):
|
||||||
|
return false, nil
|
||||||
|
case err != nil:
|
||||||
|
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||||
|
default:
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExistX is like Exist, but panics if an error occurs.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) ExistX(ctx context.Context) bool {
|
||||||
|
exist, err := _q.Exist(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return exist
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clone returns a duplicate of the ChannelMonitorDailyRollupQuery builder, including all associated steps. It can be
|
||||||
|
// used to prepare common query builders and use them differently after the clone is made.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) Clone() *ChannelMonitorDailyRollupQuery {
|
||||||
|
if _q == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &ChannelMonitorDailyRollupQuery{
|
||||||
|
config: _q.config,
|
||||||
|
ctx: _q.ctx.Clone(),
|
||||||
|
order: append([]channelmonitordailyrollup.OrderOption{}, _q.order...),
|
||||||
|
inters: append([]Interceptor{}, _q.inters...),
|
||||||
|
predicates: append([]predicate.ChannelMonitorDailyRollup{}, _q.predicates...),
|
||||||
|
withMonitor: _q.withMonitor.Clone(),
|
||||||
|
// clone intermediate query.
|
||||||
|
sql: _q.sql.Clone(),
|
||||||
|
path: _q.path,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithMonitor tells the query-builder to eager-load the nodes that are connected to
|
||||||
|
// the "monitor" edge. The optional arguments are used to configure the query builder of the edge.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) WithMonitor(opts ...func(*ChannelMonitorQuery)) *ChannelMonitorDailyRollupQuery {
|
||||||
|
query := (&ChannelMonitorClient{config: _q.config}).Query()
|
||||||
|
for _, opt := range opts {
|
||||||
|
opt(query)
|
||||||
|
}
|
||||||
|
_q.withMonitor = query
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// GroupBy is used to group vertices by one or more fields/columns.
|
||||||
|
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
//
|
||||||
|
// var v []struct {
|
||||||
|
// DeletedAt time.Time `json:"deleted_at,omitempty"`
|
||||||
|
// Count int `json:"count,omitempty"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client.ChannelMonitorDailyRollup.Query().
|
||||||
|
// GroupBy(channelmonitordailyrollup.FieldDeletedAt).
|
||||||
|
// Aggregate(ent.Count()).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) GroupBy(field string, fields ...string) *ChannelMonitorDailyRollupGroupBy {
|
||||||
|
_q.ctx.Fields = append([]string{field}, fields...)
|
||||||
|
grbuild := &ChannelMonitorDailyRollupGroupBy{build: _q}
|
||||||
|
grbuild.flds = &_q.ctx.Fields
|
||||||
|
grbuild.label = channelmonitordailyrollup.Label
|
||||||
|
grbuild.scan = grbuild.Scan
|
||||||
|
return grbuild
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select allows the selection one or more fields/columns for the given query,
|
||||||
|
// instead of selecting all fields in the entity.
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
//
|
||||||
|
// var v []struct {
|
||||||
|
// DeletedAt time.Time `json:"deleted_at,omitempty"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client.ChannelMonitorDailyRollup.Query().
|
||||||
|
// Select(channelmonitordailyrollup.FieldDeletedAt).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) Select(fields ...string) *ChannelMonitorDailyRollupSelect {
|
||||||
|
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||||
|
sbuild := &ChannelMonitorDailyRollupSelect{ChannelMonitorDailyRollupQuery: _q}
|
||||||
|
sbuild.label = channelmonitordailyrollup.Label
|
||||||
|
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||||
|
return sbuild
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate returns a ChannelMonitorDailyRollupSelect configured with the given aggregations.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) Aggregate(fns ...AggregateFunc) *ChannelMonitorDailyRollupSelect {
|
||||||
|
return _q.Select().Aggregate(fns...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) prepareQuery(ctx context.Context) error {
|
||||||
|
for _, inter := range _q.inters {
|
||||||
|
if inter == nil {
|
||||||
|
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||||
|
}
|
||||||
|
if trv, ok := inter.(Traverser); ok {
|
||||||
|
if err := trv.Traverse(ctx, _q); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, f := range _q.ctx.Fields {
|
||||||
|
if !channelmonitordailyrollup.ValidColumn(f) {
|
||||||
|
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _q.path != nil {
|
||||||
|
prev, err := _q.path(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_q.sql = prev
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ChannelMonitorDailyRollup, error) {
|
||||||
|
var (
|
||||||
|
nodes = []*ChannelMonitorDailyRollup{}
|
||||||
|
_spec = _q.querySpec()
|
||||||
|
loadedTypes = [1]bool{
|
||||||
|
_q.withMonitor != nil,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||||
|
return (*ChannelMonitorDailyRollup).scanValues(nil, columns)
|
||||||
|
}
|
||||||
|
_spec.Assign = func(columns []string, values []any) error {
|
||||||
|
node := &ChannelMonitorDailyRollup{config: _q.config}
|
||||||
|
nodes = append(nodes, node)
|
||||||
|
node.Edges.loadedTypes = loadedTypes
|
||||||
|
return node.assignValues(columns, values)
|
||||||
|
}
|
||||||
|
if len(_q.modifiers) > 0 {
|
||||||
|
_spec.Modifiers = _q.modifiers
|
||||||
|
}
|
||||||
|
for i := range hooks {
|
||||||
|
hooks[i](ctx, _spec)
|
||||||
|
}
|
||||||
|
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
if query := _q.withMonitor; query != nil {
|
||||||
|
if err := _q.loadMonitor(ctx, query, nodes, nil,
|
||||||
|
func(n *ChannelMonitorDailyRollup, e *ChannelMonitor) { n.Edges.Monitor = e }); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) loadMonitor(ctx context.Context, query *ChannelMonitorQuery, nodes []*ChannelMonitorDailyRollup, init func(*ChannelMonitorDailyRollup), assign func(*ChannelMonitorDailyRollup, *ChannelMonitor)) error {
|
||||||
|
ids := make([]int64, 0, len(nodes))
|
||||||
|
nodeids := make(map[int64][]*ChannelMonitorDailyRollup)
|
||||||
|
for i := range nodes {
|
||||||
|
fk := nodes[i].MonitorID
|
||||||
|
if _, ok := nodeids[fk]; !ok {
|
||||||
|
ids = append(ids, fk)
|
||||||
|
}
|
||||||
|
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||||
|
}
|
||||||
|
if len(ids) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
query.Where(channelmonitor.IDIn(ids...))
|
||||||
|
neighbors, err := query.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, n := range neighbors {
|
||||||
|
nodes, ok := nodeids[n.ID]
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(`unexpected foreign-key "monitor_id" returned %v`, n.ID)
|
||||||
|
}
|
||||||
|
for i := range nodes {
|
||||||
|
assign(nodes[i], n)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
|
_spec := _q.querySpec()
|
||||||
|
if len(_q.modifiers) > 0 {
|
||||||
|
_spec.Modifiers = _q.modifiers
|
||||||
|
}
|
||||||
|
_spec.Node.Columns = _q.ctx.Fields
|
||||||
|
if len(_q.ctx.Fields) > 0 {
|
||||||
|
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||||
|
}
|
||||||
|
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) querySpec() *sqlgraph.QuerySpec {
|
||||||
|
_spec := sqlgraph.NewQuerySpec(channelmonitordailyrollup.Table, channelmonitordailyrollup.Columns, sqlgraph.NewFieldSpec(channelmonitordailyrollup.FieldID, field.TypeInt64))
|
||||||
|
_spec.From = _q.sql
|
||||||
|
if unique := _q.ctx.Unique; unique != nil {
|
||||||
|
_spec.Unique = *unique
|
||||||
|
} else if _q.path != nil {
|
||||||
|
_spec.Unique = true
|
||||||
|
}
|
||||||
|
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, channelmonitordailyrollup.FieldID)
|
||||||
|
for i := range fields {
|
||||||
|
if fields[i] != channelmonitordailyrollup.FieldID {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _q.withMonitor != nil {
|
||||||
|
_spec.Node.AddColumnOnce(channelmonitordailyrollup.FieldMonitorID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ps := _q.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if limit := _q.ctx.Limit; limit != nil {
|
||||||
|
_spec.Limit = *limit
|
||||||
|
}
|
||||||
|
if offset := _q.ctx.Offset; offset != nil {
|
||||||
|
_spec.Offset = *offset
|
||||||
|
}
|
||||||
|
if ps := _q.order; len(ps) > 0 {
|
||||||
|
_spec.Order = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||||
|
builder := sql.Dialect(_q.driver.Dialect())
|
||||||
|
t1 := builder.Table(channelmonitordailyrollup.Table)
|
||||||
|
columns := _q.ctx.Fields
|
||||||
|
if len(columns) == 0 {
|
||||||
|
columns = channelmonitordailyrollup.Columns
|
||||||
|
}
|
||||||
|
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||||
|
if _q.sql != nil {
|
||||||
|
selector = _q.sql
|
||||||
|
selector.Select(selector.Columns(columns...)...)
|
||||||
|
}
|
||||||
|
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||||
|
selector.Distinct()
|
||||||
|
}
|
||||||
|
for _, m := range _q.modifiers {
|
||||||
|
m(selector)
|
||||||
|
}
|
||||||
|
for _, p := range _q.predicates {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
for _, p := range _q.order {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
if offset := _q.ctx.Offset; offset != nil {
|
||||||
|
// limit is mandatory for offset clause. We start
|
||||||
|
// with default value, and override it below if needed.
|
||||||
|
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||||
|
}
|
||||||
|
if limit := _q.ctx.Limit; limit != nil {
|
||||||
|
selector.Limit(*limit)
|
||||||
|
}
|
||||||
|
return selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// ForUpdate locks the selected rows against concurrent updates, and prevent them from being
|
||||||
|
// updated, deleted or "selected ... for update" by other sessions, until the transaction is
|
||||||
|
// either committed or rolled-back.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) ForUpdate(opts ...sql.LockOption) *ChannelMonitorDailyRollupQuery {
|
||||||
|
if _q.driver.Dialect() == dialect.Postgres {
|
||||||
|
_q.Unique(false)
|
||||||
|
}
|
||||||
|
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
|
||||||
|
s.ForUpdate(opts...)
|
||||||
|
})
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock
|
||||||
|
// on any rows that are read. Other sessions can read the rows, but cannot modify them
|
||||||
|
// until your transaction commits.
|
||||||
|
func (_q *ChannelMonitorDailyRollupQuery) ForShare(opts ...sql.LockOption) *ChannelMonitorDailyRollupQuery {
|
||||||
|
if _q.driver.Dialect() == dialect.Postgres {
|
||||||
|
_q.Unique(false)
|
||||||
|
}
|
||||||
|
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
|
||||||
|
s.ForShare(opts...)
|
||||||
|
})
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChannelMonitorDailyRollupGroupBy is the group-by builder for ChannelMonitorDailyRollup entities.
|
||||||
|
type ChannelMonitorDailyRollupGroupBy struct {
|
||||||
|
selector
|
||||||
|
build *ChannelMonitorDailyRollupQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the group-by query.
|
||||||
|
func (_g *ChannelMonitorDailyRollupGroupBy) Aggregate(fns ...AggregateFunc) *ChannelMonitorDailyRollupGroupBy {
|
||||||
|
_g.fns = append(_g.fns, fns...)
|
||||||
|
return _g
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (_g *ChannelMonitorDailyRollupGroupBy) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||||
|
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*ChannelMonitorDailyRollupQuery, *ChannelMonitorDailyRollupGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_g *ChannelMonitorDailyRollupGroupBy) sqlScan(ctx context.Context, root *ChannelMonitorDailyRollupQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx).Select()
|
||||||
|
aggregation := make([]string, 0, len(_g.fns))
|
||||||
|
for _, fn := range _g.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
if len(selector.SelectedColumns()) == 0 {
|
||||||
|
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||||
|
for _, f := range *_g.flds {
|
||||||
|
columns = append(columns, selector.C(f))
|
||||||
|
}
|
||||||
|
columns = append(columns, aggregation...)
|
||||||
|
selector.Select(columns...)
|
||||||
|
}
|
||||||
|
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||||
|
if err := selector.Err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
rows := &sql.Rows{}
|
||||||
|
query, args := selector.Query()
|
||||||
|
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChannelMonitorDailyRollupSelect is the builder for selecting fields of ChannelMonitorDailyRollup entities.
|
||||||
|
type ChannelMonitorDailyRollupSelect struct {
|
||||||
|
*ChannelMonitorDailyRollupQuery
|
||||||
|
selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the selector query.
|
||||||
|
func (_s *ChannelMonitorDailyRollupSelect) Aggregate(fns ...AggregateFunc) *ChannelMonitorDailyRollupSelect {
|
||||||
|
_s.fns = append(_s.fns, fns...)
|
||||||
|
return _s
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (_s *ChannelMonitorDailyRollupSelect) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||||
|
if err := _s.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*ChannelMonitorDailyRollupQuery, *ChannelMonitorDailyRollupSelect](ctx, _s.ChannelMonitorDailyRollupQuery, _s, _s.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_s *ChannelMonitorDailyRollupSelect) sqlScan(ctx context.Context, root *ChannelMonitorDailyRollupQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx)
|
||||||
|
aggregation := make([]string, 0, len(_s.fns))
|
||||||
|
for _, fn := range _s.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
switch n := len(*_s.selector.flds); {
|
||||||
|
case n == 0 && len(aggregation) > 0:
|
||||||
|
selector.Select(aggregation...)
|
||||||
|
case n != 0 && len(aggregation) > 0:
|
||||||
|
selector.AppendSelect(aggregation...)
|
||||||
|
}
|
||||||
|
rows := &sql.Rows{}
|
||||||
|
query, args := selector.Query()
|
||||||
|
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
||||||
1025
backend/ent/channelmonitordailyrollup_update.go
Normal file
1025
backend/ent/channelmonitordailyrollup_update.go
Normal file
File diff suppressed because it is too large
Load Diff
@@ -18,6 +18,8 @@ type ChannelMonitorHistory struct {
|
|||||||
config `json:"-"`
|
config `json:"-"`
|
||||||
// ID of the ent.
|
// ID of the ent.
|
||||||
ID int64 `json:"id,omitempty"`
|
ID int64 `json:"id,omitempty"`
|
||||||
|
// DeletedAt holds the value of the "deleted_at" field.
|
||||||
|
DeletedAt *time.Time `json:"deleted_at,omitempty"`
|
||||||
// MonitorID holds the value of the "monitor_id" field.
|
// MonitorID holds the value of the "monitor_id" field.
|
||||||
MonitorID int64 `json:"monitor_id,omitempty"`
|
MonitorID int64 `json:"monitor_id,omitempty"`
|
||||||
// Model holds the value of the "model" field.
|
// Model holds the value of the "model" field.
|
||||||
@@ -67,7 +69,7 @@ func (*ChannelMonitorHistory) scanValues(columns []string) ([]any, error) {
|
|||||||
values[i] = new(sql.NullInt64)
|
values[i] = new(sql.NullInt64)
|
||||||
case channelmonitorhistory.FieldModel, channelmonitorhistory.FieldStatus, channelmonitorhistory.FieldMessage:
|
case channelmonitorhistory.FieldModel, channelmonitorhistory.FieldStatus, channelmonitorhistory.FieldMessage:
|
||||||
values[i] = new(sql.NullString)
|
values[i] = new(sql.NullString)
|
||||||
case channelmonitorhistory.FieldCheckedAt:
|
case channelmonitorhistory.FieldDeletedAt, channelmonitorhistory.FieldCheckedAt:
|
||||||
values[i] = new(sql.NullTime)
|
values[i] = new(sql.NullTime)
|
||||||
default:
|
default:
|
||||||
values[i] = new(sql.UnknownType)
|
values[i] = new(sql.UnknownType)
|
||||||
@@ -90,6 +92,13 @@ func (_m *ChannelMonitorHistory) assignValues(columns []string, values []any) er
|
|||||||
return fmt.Errorf("unexpected type %T for field id", value)
|
return fmt.Errorf("unexpected type %T for field id", value)
|
||||||
}
|
}
|
||||||
_m.ID = int64(value.Int64)
|
_m.ID = int64(value.Int64)
|
||||||
|
case channelmonitorhistory.FieldDeletedAt:
|
||||||
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.DeletedAt = new(time.Time)
|
||||||
|
*_m.DeletedAt = value.Time
|
||||||
|
}
|
||||||
case channelmonitorhistory.FieldMonitorID:
|
case channelmonitorhistory.FieldMonitorID:
|
||||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
return fmt.Errorf("unexpected type %T for field monitor_id", values[i])
|
return fmt.Errorf("unexpected type %T for field monitor_id", values[i])
|
||||||
@@ -175,6 +184,11 @@ func (_m *ChannelMonitorHistory) String() string {
|
|||||||
var builder strings.Builder
|
var builder strings.Builder
|
||||||
builder.WriteString("ChannelMonitorHistory(")
|
builder.WriteString("ChannelMonitorHistory(")
|
||||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||||
|
if v := _m.DeletedAt; v != nil {
|
||||||
|
builder.WriteString("deleted_at=")
|
||||||
|
builder.WriteString(v.Format(time.ANSIC))
|
||||||
|
}
|
||||||
|
builder.WriteString(", ")
|
||||||
builder.WriteString("monitor_id=")
|
builder.WriteString("monitor_id=")
|
||||||
builder.WriteString(fmt.Sprintf("%v", _m.MonitorID))
|
builder.WriteString(fmt.Sprintf("%v", _m.MonitorID))
|
||||||
builder.WriteString(", ")
|
builder.WriteString(", ")
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
"entgo.io/ent/dialect/sql"
|
"entgo.io/ent/dialect/sql"
|
||||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
)
|
)
|
||||||
@@ -15,6 +16,8 @@ const (
|
|||||||
Label = "channel_monitor_history"
|
Label = "channel_monitor_history"
|
||||||
// FieldID holds the string denoting the id field in the database.
|
// FieldID holds the string denoting the id field in the database.
|
||||||
FieldID = "id"
|
FieldID = "id"
|
||||||
|
// FieldDeletedAt holds the string denoting the deleted_at field in the database.
|
||||||
|
FieldDeletedAt = "deleted_at"
|
||||||
// FieldMonitorID holds the string denoting the monitor_id field in the database.
|
// FieldMonitorID holds the string denoting the monitor_id field in the database.
|
||||||
FieldMonitorID = "monitor_id"
|
FieldMonitorID = "monitor_id"
|
||||||
// FieldModel holds the string denoting the model field in the database.
|
// FieldModel holds the string denoting the model field in the database.
|
||||||
@@ -45,6 +48,7 @@ const (
|
|||||||
// Columns holds all SQL columns for channelmonitorhistory fields.
|
// Columns holds all SQL columns for channelmonitorhistory fields.
|
||||||
var Columns = []string{
|
var Columns = []string{
|
||||||
FieldID,
|
FieldID,
|
||||||
|
FieldDeletedAt,
|
||||||
FieldMonitorID,
|
FieldMonitorID,
|
||||||
FieldModel,
|
FieldModel,
|
||||||
FieldStatus,
|
FieldStatus,
|
||||||
@@ -64,7 +68,14 @@ func ValidColumn(column string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note that the variables below are initialized by the runtime
|
||||||
|
// package on the initialization of the application. Therefore,
|
||||||
|
// it should be imported in the main as follows:
|
||||||
|
//
|
||||||
|
// import _ "github.com/Wei-Shaw/sub2api/ent/runtime"
|
||||||
var (
|
var (
|
||||||
|
Hooks [1]ent.Hook
|
||||||
|
Interceptors [1]ent.Interceptor
|
||||||
// ModelValidator is a validator for the "model" field. It is called by the builders before save.
|
// ModelValidator is a validator for the "model" field. It is called by the builders before save.
|
||||||
ModelValidator func(string) error
|
ModelValidator func(string) error
|
||||||
// DefaultMessage holds the default value on creation for the "message" field.
|
// DefaultMessage holds the default value on creation for the "message" field.
|
||||||
@@ -108,6 +119,11 @@ func ByID(opts ...sql.OrderTermOption) OrderOption {
|
|||||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ByDeletedAt orders the results by the deleted_at field.
|
||||||
|
func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
// ByMonitorID orders the results by the monitor_id field.
|
// ByMonitorID orders the results by the monitor_id field.
|
||||||
func ByMonitorID(opts ...sql.OrderTermOption) OrderOption {
|
func ByMonitorID(opts ...sql.OrderTermOption) OrderOption {
|
||||||
return sql.OrderByField(FieldMonitorID, opts...).ToFunc()
|
return sql.OrderByField(FieldMonitorID, opts...).ToFunc()
|
||||||
|
|||||||
@@ -55,6 +55,11 @@ func IDLTE(id int64) predicate.ChannelMonitorHistory {
|
|||||||
return predicate.ChannelMonitorHistory(sql.FieldLTE(FieldID, id))
|
return predicate.ChannelMonitorHistory(sql.FieldLTE(FieldID, id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ.
|
||||||
|
func DeletedAt(v time.Time) predicate.ChannelMonitorHistory {
|
||||||
|
return predicate.ChannelMonitorHistory(sql.FieldEQ(FieldDeletedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
// MonitorID applies equality check predicate on the "monitor_id" field. It's identical to MonitorIDEQ.
|
// MonitorID applies equality check predicate on the "monitor_id" field. It's identical to MonitorIDEQ.
|
||||||
func MonitorID(v int64) predicate.ChannelMonitorHistory {
|
func MonitorID(v int64) predicate.ChannelMonitorHistory {
|
||||||
return predicate.ChannelMonitorHistory(sql.FieldEQ(FieldMonitorID, v))
|
return predicate.ChannelMonitorHistory(sql.FieldEQ(FieldMonitorID, v))
|
||||||
@@ -85,6 +90,56 @@ func CheckedAt(v time.Time) predicate.ChannelMonitorHistory {
|
|||||||
return predicate.ChannelMonitorHistory(sql.FieldEQ(FieldCheckedAt, v))
|
return predicate.ChannelMonitorHistory(sql.FieldEQ(FieldCheckedAt, v))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeletedAtEQ applies the EQ predicate on the "deleted_at" field.
|
||||||
|
func DeletedAtEQ(v time.Time) predicate.ChannelMonitorHistory {
|
||||||
|
return predicate.ChannelMonitorHistory(sql.FieldEQ(FieldDeletedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field.
|
||||||
|
func DeletedAtNEQ(v time.Time) predicate.ChannelMonitorHistory {
|
||||||
|
return predicate.ChannelMonitorHistory(sql.FieldNEQ(FieldDeletedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletedAtIn applies the In predicate on the "deleted_at" field.
|
||||||
|
func DeletedAtIn(vs ...time.Time) predicate.ChannelMonitorHistory {
|
||||||
|
return predicate.ChannelMonitorHistory(sql.FieldIn(FieldDeletedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field.
|
||||||
|
func DeletedAtNotIn(vs ...time.Time) predicate.ChannelMonitorHistory {
|
||||||
|
return predicate.ChannelMonitorHistory(sql.FieldNotIn(FieldDeletedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletedAtGT applies the GT predicate on the "deleted_at" field.
|
||||||
|
func DeletedAtGT(v time.Time) predicate.ChannelMonitorHistory {
|
||||||
|
return predicate.ChannelMonitorHistory(sql.FieldGT(FieldDeletedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletedAtGTE applies the GTE predicate on the "deleted_at" field.
|
||||||
|
func DeletedAtGTE(v time.Time) predicate.ChannelMonitorHistory {
|
||||||
|
return predicate.ChannelMonitorHistory(sql.FieldGTE(FieldDeletedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletedAtLT applies the LT predicate on the "deleted_at" field.
|
||||||
|
func DeletedAtLT(v time.Time) predicate.ChannelMonitorHistory {
|
||||||
|
return predicate.ChannelMonitorHistory(sql.FieldLT(FieldDeletedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletedAtLTE applies the LTE predicate on the "deleted_at" field.
|
||||||
|
func DeletedAtLTE(v time.Time) predicate.ChannelMonitorHistory {
|
||||||
|
return predicate.ChannelMonitorHistory(sql.FieldLTE(FieldDeletedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field.
|
||||||
|
func DeletedAtIsNil() predicate.ChannelMonitorHistory {
|
||||||
|
return predicate.ChannelMonitorHistory(sql.FieldIsNull(FieldDeletedAt))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field.
|
||||||
|
func DeletedAtNotNil() predicate.ChannelMonitorHistory {
|
||||||
|
return predicate.ChannelMonitorHistory(sql.FieldNotNull(FieldDeletedAt))
|
||||||
|
}
|
||||||
|
|
||||||
// MonitorIDEQ applies the EQ predicate on the "monitor_id" field.
|
// MonitorIDEQ applies the EQ predicate on the "monitor_id" field.
|
||||||
func MonitorIDEQ(v int64) predicate.ChannelMonitorHistory {
|
func MonitorIDEQ(v int64) predicate.ChannelMonitorHistory {
|
||||||
return predicate.ChannelMonitorHistory(sql.FieldEQ(FieldMonitorID, v))
|
return predicate.ChannelMonitorHistory(sql.FieldEQ(FieldMonitorID, v))
|
||||||
|
|||||||
@@ -23,6 +23,20 @@ type ChannelMonitorHistoryCreate struct {
|
|||||||
conflict []sql.ConflictOption
|
conflict []sql.ConflictOption
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetDeletedAt sets the "deleted_at" field.
|
||||||
|
func (_c *ChannelMonitorHistoryCreate) SetDeletedAt(v time.Time) *ChannelMonitorHistoryCreate {
|
||||||
|
_c.mutation.SetDeletedAt(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
||||||
|
func (_c *ChannelMonitorHistoryCreate) SetNillableDeletedAt(v *time.Time) *ChannelMonitorHistoryCreate {
|
||||||
|
if v != nil {
|
||||||
|
_c.SetDeletedAt(*v)
|
||||||
|
}
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
// SetMonitorID sets the "monitor_id" field.
|
// SetMonitorID sets the "monitor_id" field.
|
||||||
func (_c *ChannelMonitorHistoryCreate) SetMonitorID(v int64) *ChannelMonitorHistoryCreate {
|
func (_c *ChannelMonitorHistoryCreate) SetMonitorID(v int64) *ChannelMonitorHistoryCreate {
|
||||||
_c.mutation.SetMonitorID(v)
|
_c.mutation.SetMonitorID(v)
|
||||||
@@ -109,7 +123,9 @@ func (_c *ChannelMonitorHistoryCreate) Mutation() *ChannelMonitorHistoryMutation
|
|||||||
|
|
||||||
// Save creates the ChannelMonitorHistory in the database.
|
// Save creates the ChannelMonitorHistory in the database.
|
||||||
func (_c *ChannelMonitorHistoryCreate) Save(ctx context.Context) (*ChannelMonitorHistory, error) {
|
func (_c *ChannelMonitorHistoryCreate) Save(ctx context.Context) (*ChannelMonitorHistory, error) {
|
||||||
_c.defaults()
|
if err := _c.defaults(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,15 +152,19 @@ func (_c *ChannelMonitorHistoryCreate) ExecX(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// defaults sets the default values of the builder before save.
|
// defaults sets the default values of the builder before save.
|
||||||
func (_c *ChannelMonitorHistoryCreate) defaults() {
|
func (_c *ChannelMonitorHistoryCreate) defaults() error {
|
||||||
if _, ok := _c.mutation.Message(); !ok {
|
if _, ok := _c.mutation.Message(); !ok {
|
||||||
v := channelmonitorhistory.DefaultMessage
|
v := channelmonitorhistory.DefaultMessage
|
||||||
_c.mutation.SetMessage(v)
|
_c.mutation.SetMessage(v)
|
||||||
}
|
}
|
||||||
if _, ok := _c.mutation.CheckedAt(); !ok {
|
if _, ok := _c.mutation.CheckedAt(); !ok {
|
||||||
|
if channelmonitorhistory.DefaultCheckedAt == nil {
|
||||||
|
return fmt.Errorf("ent: uninitialized channelmonitorhistory.DefaultCheckedAt (forgotten import ent/runtime?)")
|
||||||
|
}
|
||||||
v := channelmonitorhistory.DefaultCheckedAt()
|
v := channelmonitorhistory.DefaultCheckedAt()
|
||||||
_c.mutation.SetCheckedAt(v)
|
_c.mutation.SetCheckedAt(v)
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// check runs all checks and user-defined validators on the builder.
|
// check runs all checks and user-defined validators on the builder.
|
||||||
@@ -206,6 +226,10 @@ func (_c *ChannelMonitorHistoryCreate) createSpec() (*ChannelMonitorHistory, *sq
|
|||||||
_spec = sqlgraph.NewCreateSpec(channelmonitorhistory.Table, sqlgraph.NewFieldSpec(channelmonitorhistory.FieldID, field.TypeInt64))
|
_spec = sqlgraph.NewCreateSpec(channelmonitorhistory.Table, sqlgraph.NewFieldSpec(channelmonitorhistory.FieldID, field.TypeInt64))
|
||||||
)
|
)
|
||||||
_spec.OnConflict = _c.conflict
|
_spec.OnConflict = _c.conflict
|
||||||
|
if value, ok := _c.mutation.DeletedAt(); ok {
|
||||||
|
_spec.SetField(channelmonitorhistory.FieldDeletedAt, field.TypeTime, value)
|
||||||
|
_node.DeletedAt = &value
|
||||||
|
}
|
||||||
if value, ok := _c.mutation.Model(); ok {
|
if value, ok := _c.mutation.Model(); ok {
|
||||||
_spec.SetField(channelmonitorhistory.FieldModel, field.TypeString, value)
|
_spec.SetField(channelmonitorhistory.FieldModel, field.TypeString, value)
|
||||||
_node.Model = value
|
_node.Model = value
|
||||||
@@ -254,7 +278,7 @@ func (_c *ChannelMonitorHistoryCreate) createSpec() (*ChannelMonitorHistory, *sq
|
|||||||
// of the `INSERT` statement. For example:
|
// of the `INSERT` statement. For example:
|
||||||
//
|
//
|
||||||
// client.ChannelMonitorHistory.Create().
|
// client.ChannelMonitorHistory.Create().
|
||||||
// SetMonitorID(v).
|
// SetDeletedAt(v).
|
||||||
// OnConflict(
|
// OnConflict(
|
||||||
// // Update the row with the new values
|
// // Update the row with the new values
|
||||||
// // the was proposed for insertion.
|
// // the was proposed for insertion.
|
||||||
@@ -263,7 +287,7 @@ func (_c *ChannelMonitorHistoryCreate) createSpec() (*ChannelMonitorHistory, *sq
|
|||||||
// // Override some of the fields with custom
|
// // Override some of the fields with custom
|
||||||
// // update values.
|
// // update values.
|
||||||
// Update(func(u *ent.ChannelMonitorHistoryUpsert) {
|
// Update(func(u *ent.ChannelMonitorHistoryUpsert) {
|
||||||
// SetMonitorID(v+v).
|
// SetDeletedAt(v+v).
|
||||||
// }).
|
// }).
|
||||||
// Exec(ctx)
|
// Exec(ctx)
|
||||||
func (_c *ChannelMonitorHistoryCreate) OnConflict(opts ...sql.ConflictOption) *ChannelMonitorHistoryUpsertOne {
|
func (_c *ChannelMonitorHistoryCreate) OnConflict(opts ...sql.ConflictOption) *ChannelMonitorHistoryUpsertOne {
|
||||||
@@ -299,6 +323,24 @@ type (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// SetDeletedAt sets the "deleted_at" field.
|
||||||
|
func (u *ChannelMonitorHistoryUpsert) SetDeletedAt(v time.Time) *ChannelMonitorHistoryUpsert {
|
||||||
|
u.Set(channelmonitorhistory.FieldDeletedAt, v)
|
||||||
|
return u
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
||||||
|
func (u *ChannelMonitorHistoryUpsert) UpdateDeletedAt() *ChannelMonitorHistoryUpsert {
|
||||||
|
u.SetExcluded(channelmonitorhistory.FieldDeletedAt)
|
||||||
|
return u
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
||||||
|
func (u *ChannelMonitorHistoryUpsert) ClearDeletedAt() *ChannelMonitorHistoryUpsert {
|
||||||
|
u.SetNull(channelmonitorhistory.FieldDeletedAt)
|
||||||
|
return u
|
||||||
|
}
|
||||||
|
|
||||||
// SetMonitorID sets the "monitor_id" field.
|
// SetMonitorID sets the "monitor_id" field.
|
||||||
func (u *ChannelMonitorHistoryUpsert) SetMonitorID(v int64) *ChannelMonitorHistoryUpsert {
|
func (u *ChannelMonitorHistoryUpsert) SetMonitorID(v int64) *ChannelMonitorHistoryUpsert {
|
||||||
u.Set(channelmonitorhistory.FieldMonitorID, v)
|
u.Set(channelmonitorhistory.FieldMonitorID, v)
|
||||||
@@ -453,6 +495,27 @@ func (u *ChannelMonitorHistoryUpsertOne) Update(set func(*ChannelMonitorHistoryU
|
|||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetDeletedAt sets the "deleted_at" field.
|
||||||
|
func (u *ChannelMonitorHistoryUpsertOne) SetDeletedAt(v time.Time) *ChannelMonitorHistoryUpsertOne {
|
||||||
|
return u.Update(func(s *ChannelMonitorHistoryUpsert) {
|
||||||
|
s.SetDeletedAt(v)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
||||||
|
func (u *ChannelMonitorHistoryUpsertOne) UpdateDeletedAt() *ChannelMonitorHistoryUpsertOne {
|
||||||
|
return u.Update(func(s *ChannelMonitorHistoryUpsert) {
|
||||||
|
s.UpdateDeletedAt()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
||||||
|
func (u *ChannelMonitorHistoryUpsertOne) ClearDeletedAt() *ChannelMonitorHistoryUpsertOne {
|
||||||
|
return u.Update(func(s *ChannelMonitorHistoryUpsert) {
|
||||||
|
s.ClearDeletedAt()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// SetMonitorID sets the "monitor_id" field.
|
// SetMonitorID sets the "monitor_id" field.
|
||||||
func (u *ChannelMonitorHistoryUpsertOne) SetMonitorID(v int64) *ChannelMonitorHistoryUpsertOne {
|
func (u *ChannelMonitorHistoryUpsertOne) SetMonitorID(v int64) *ChannelMonitorHistoryUpsertOne {
|
||||||
return u.Update(func(s *ChannelMonitorHistoryUpsert) {
|
return u.Update(func(s *ChannelMonitorHistoryUpsert) {
|
||||||
@@ -721,7 +784,7 @@ func (_c *ChannelMonitorHistoryCreateBulk) ExecX(ctx context.Context) {
|
|||||||
// // Override some of the fields with custom
|
// // Override some of the fields with custom
|
||||||
// // update values.
|
// // update values.
|
||||||
// Update(func(u *ent.ChannelMonitorHistoryUpsert) {
|
// Update(func(u *ent.ChannelMonitorHistoryUpsert) {
|
||||||
// SetMonitorID(v+v).
|
// SetDeletedAt(v+v).
|
||||||
// }).
|
// }).
|
||||||
// Exec(ctx)
|
// Exec(ctx)
|
||||||
func (_c *ChannelMonitorHistoryCreateBulk) OnConflict(opts ...sql.ConflictOption) *ChannelMonitorHistoryUpsertBulk {
|
func (_c *ChannelMonitorHistoryCreateBulk) OnConflict(opts ...sql.ConflictOption) *ChannelMonitorHistoryUpsertBulk {
|
||||||
@@ -790,6 +853,27 @@ func (u *ChannelMonitorHistoryUpsertBulk) Update(set func(*ChannelMonitorHistory
|
|||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetDeletedAt sets the "deleted_at" field.
|
||||||
|
func (u *ChannelMonitorHistoryUpsertBulk) SetDeletedAt(v time.Time) *ChannelMonitorHistoryUpsertBulk {
|
||||||
|
return u.Update(func(s *ChannelMonitorHistoryUpsert) {
|
||||||
|
s.SetDeletedAt(v)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
||||||
|
func (u *ChannelMonitorHistoryUpsertBulk) UpdateDeletedAt() *ChannelMonitorHistoryUpsertBulk {
|
||||||
|
return u.Update(func(s *ChannelMonitorHistoryUpsert) {
|
||||||
|
s.UpdateDeletedAt()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
||||||
|
func (u *ChannelMonitorHistoryUpsertBulk) ClearDeletedAt() *ChannelMonitorHistoryUpsertBulk {
|
||||||
|
return u.Update(func(s *ChannelMonitorHistoryUpsert) {
|
||||||
|
s.ClearDeletedAt()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// SetMonitorID sets the "monitor_id" field.
|
// SetMonitorID sets the "monitor_id" field.
|
||||||
func (u *ChannelMonitorHistoryUpsertBulk) SetMonitorID(v int64) *ChannelMonitorHistoryUpsertBulk {
|
func (u *ChannelMonitorHistoryUpsertBulk) SetMonitorID(v int64) *ChannelMonitorHistoryUpsertBulk {
|
||||||
return u.Update(func(s *ChannelMonitorHistoryUpsert) {
|
return u.Update(func(s *ChannelMonitorHistoryUpsert) {
|
||||||
|
|||||||
@@ -300,12 +300,12 @@ func (_q *ChannelMonitorHistoryQuery) WithMonitor(opts ...func(*ChannelMonitorQu
|
|||||||
// Example:
|
// Example:
|
||||||
//
|
//
|
||||||
// var v []struct {
|
// var v []struct {
|
||||||
// MonitorID int64 `json:"monitor_id,omitempty"`
|
// DeletedAt time.Time `json:"deleted_at,omitempty"`
|
||||||
// Count int `json:"count,omitempty"`
|
// Count int `json:"count,omitempty"`
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// client.ChannelMonitorHistory.Query().
|
// client.ChannelMonitorHistory.Query().
|
||||||
// GroupBy(channelmonitorhistory.FieldMonitorID).
|
// GroupBy(channelmonitorhistory.FieldDeletedAt).
|
||||||
// Aggregate(ent.Count()).
|
// Aggregate(ent.Count()).
|
||||||
// Scan(ctx, &v)
|
// Scan(ctx, &v)
|
||||||
func (_q *ChannelMonitorHistoryQuery) GroupBy(field string, fields ...string) *ChannelMonitorHistoryGroupBy {
|
func (_q *ChannelMonitorHistoryQuery) GroupBy(field string, fields ...string) *ChannelMonitorHistoryGroupBy {
|
||||||
@@ -323,11 +323,11 @@ func (_q *ChannelMonitorHistoryQuery) GroupBy(field string, fields ...string) *C
|
|||||||
// Example:
|
// Example:
|
||||||
//
|
//
|
||||||
// var v []struct {
|
// var v []struct {
|
||||||
// MonitorID int64 `json:"monitor_id,omitempty"`
|
// DeletedAt time.Time `json:"deleted_at,omitempty"`
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// client.ChannelMonitorHistory.Query().
|
// client.ChannelMonitorHistory.Query().
|
||||||
// Select(channelmonitorhistory.FieldMonitorID).
|
// Select(channelmonitorhistory.FieldDeletedAt).
|
||||||
// Scan(ctx, &v)
|
// Scan(ctx, &v)
|
||||||
func (_q *ChannelMonitorHistoryQuery) Select(fields ...string) *ChannelMonitorHistorySelect {
|
func (_q *ChannelMonitorHistoryQuery) Select(fields ...string) *ChannelMonitorHistorySelect {
|
||||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||||
|
|||||||
@@ -29,6 +29,26 @@ func (_u *ChannelMonitorHistoryUpdate) Where(ps ...predicate.ChannelMonitorHisto
|
|||||||
return _u
|
return _u
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetDeletedAt sets the "deleted_at" field.
|
||||||
|
func (_u *ChannelMonitorHistoryUpdate) SetDeletedAt(v time.Time) *ChannelMonitorHistoryUpdate {
|
||||||
|
_u.mutation.SetDeletedAt(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
||||||
|
func (_u *ChannelMonitorHistoryUpdate) SetNillableDeletedAt(v *time.Time) *ChannelMonitorHistoryUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetDeletedAt(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
||||||
|
func (_u *ChannelMonitorHistoryUpdate) ClearDeletedAt() *ChannelMonitorHistoryUpdate {
|
||||||
|
_u.mutation.ClearDeletedAt()
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
// SetMonitorID sets the "monitor_id" field.
|
// SetMonitorID sets the "monitor_id" field.
|
||||||
func (_u *ChannelMonitorHistoryUpdate) SetMonitorID(v int64) *ChannelMonitorHistoryUpdate {
|
func (_u *ChannelMonitorHistoryUpdate) SetMonitorID(v int64) *ChannelMonitorHistoryUpdate {
|
||||||
_u.mutation.SetMonitorID(v)
|
_u.mutation.SetMonitorID(v)
|
||||||
@@ -237,6 +257,12 @@ func (_u *ChannelMonitorHistoryUpdate) sqlSave(ctx context.Context) (_node int,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if value, ok := _u.mutation.DeletedAt(); ok {
|
||||||
|
_spec.SetField(channelmonitorhistory.FieldDeletedAt, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
if _u.mutation.DeletedAtCleared() {
|
||||||
|
_spec.ClearField(channelmonitorhistory.FieldDeletedAt, field.TypeTime)
|
||||||
|
}
|
||||||
if value, ok := _u.mutation.Model(); ok {
|
if value, ok := _u.mutation.Model(); ok {
|
||||||
_spec.SetField(channelmonitorhistory.FieldModel, field.TypeString, value)
|
_spec.SetField(channelmonitorhistory.FieldModel, field.TypeString, value)
|
||||||
}
|
}
|
||||||
@@ -319,6 +345,26 @@ type ChannelMonitorHistoryUpdateOne struct {
|
|||||||
mutation *ChannelMonitorHistoryMutation
|
mutation *ChannelMonitorHistoryMutation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetDeletedAt sets the "deleted_at" field.
|
||||||
|
func (_u *ChannelMonitorHistoryUpdateOne) SetDeletedAt(v time.Time) *ChannelMonitorHistoryUpdateOne {
|
||||||
|
_u.mutation.SetDeletedAt(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
||||||
|
func (_u *ChannelMonitorHistoryUpdateOne) SetNillableDeletedAt(v *time.Time) *ChannelMonitorHistoryUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetDeletedAt(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
||||||
|
func (_u *ChannelMonitorHistoryUpdateOne) ClearDeletedAt() *ChannelMonitorHistoryUpdateOne {
|
||||||
|
_u.mutation.ClearDeletedAt()
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
// SetMonitorID sets the "monitor_id" field.
|
// SetMonitorID sets the "monitor_id" field.
|
||||||
func (_u *ChannelMonitorHistoryUpdateOne) SetMonitorID(v int64) *ChannelMonitorHistoryUpdateOne {
|
func (_u *ChannelMonitorHistoryUpdateOne) SetMonitorID(v int64) *ChannelMonitorHistoryUpdateOne {
|
||||||
_u.mutation.SetMonitorID(v)
|
_u.mutation.SetMonitorID(v)
|
||||||
@@ -557,6 +603,12 @@ func (_u *ChannelMonitorHistoryUpdateOne) sqlSave(ctx context.Context) (_node *C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if value, ok := _u.mutation.DeletedAt(); ok {
|
||||||
|
_spec.SetField(channelmonitorhistory.FieldDeletedAt, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
if _u.mutation.DeletedAtCleared() {
|
||||||
|
_spec.ClearField(channelmonitorhistory.FieldDeletedAt, field.TypeTime)
|
||||||
|
}
|
||||||
if value, ok := _u.mutation.Model(); ok {
|
if value, ok := _u.mutation.Model(); ok {
|
||||||
_spec.SetField(channelmonitorhistory.FieldModel, field.TypeString, value)
|
_spec.SetField(channelmonitorhistory.FieldModel, field.TypeString, value)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import (
|
|||||||
"github.com/Wei-Shaw/sub2api/ent/authidentity"
|
"github.com/Wei-Shaw/sub2api/ent/authidentity"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/authidentitychannel"
|
"github.com/Wei-Shaw/sub2api/ent/authidentitychannel"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/channelmonitor"
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitor"
|
||||||
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitordailyrollup"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/channelmonitorhistory"
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitorhistory"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
|
"github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/group"
|
"github.com/Wei-Shaw/sub2api/ent/group"
|
||||||
@@ -72,6 +73,8 @@ type Client struct {
|
|||||||
AuthIdentityChannel *AuthIdentityChannelClient
|
AuthIdentityChannel *AuthIdentityChannelClient
|
||||||
// ChannelMonitor is the client for interacting with the ChannelMonitor builders.
|
// ChannelMonitor is the client for interacting with the ChannelMonitor builders.
|
||||||
ChannelMonitor *ChannelMonitorClient
|
ChannelMonitor *ChannelMonitorClient
|
||||||
|
// ChannelMonitorDailyRollup is the client for interacting with the ChannelMonitorDailyRollup builders.
|
||||||
|
ChannelMonitorDailyRollup *ChannelMonitorDailyRollupClient
|
||||||
// ChannelMonitorHistory is the client for interacting with the ChannelMonitorHistory builders.
|
// ChannelMonitorHistory is the client for interacting with the ChannelMonitorHistory builders.
|
||||||
ChannelMonitorHistory *ChannelMonitorHistoryClient
|
ChannelMonitorHistory *ChannelMonitorHistoryClient
|
||||||
// ErrorPassthroughRule is the client for interacting with the ErrorPassthroughRule builders.
|
// ErrorPassthroughRule is the client for interacting with the ErrorPassthroughRule builders.
|
||||||
@@ -139,6 +142,7 @@ func (c *Client) init() {
|
|||||||
c.AuthIdentity = NewAuthIdentityClient(c.config)
|
c.AuthIdentity = NewAuthIdentityClient(c.config)
|
||||||
c.AuthIdentityChannel = NewAuthIdentityChannelClient(c.config)
|
c.AuthIdentityChannel = NewAuthIdentityChannelClient(c.config)
|
||||||
c.ChannelMonitor = NewChannelMonitorClient(c.config)
|
c.ChannelMonitor = NewChannelMonitorClient(c.config)
|
||||||
|
c.ChannelMonitorDailyRollup = NewChannelMonitorDailyRollupClient(c.config)
|
||||||
c.ChannelMonitorHistory = NewChannelMonitorHistoryClient(c.config)
|
c.ChannelMonitorHistory = NewChannelMonitorHistoryClient(c.config)
|
||||||
c.ErrorPassthroughRule = NewErrorPassthroughRuleClient(c.config)
|
c.ErrorPassthroughRule = NewErrorPassthroughRuleClient(c.config)
|
||||||
c.Group = NewGroupClient(c.config)
|
c.Group = NewGroupClient(c.config)
|
||||||
@@ -253,40 +257,41 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
|||||||
cfg := c.config
|
cfg := c.config
|
||||||
cfg.driver = tx
|
cfg.driver = tx
|
||||||
return &Tx{
|
return &Tx{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
config: cfg,
|
config: cfg,
|
||||||
APIKey: NewAPIKeyClient(cfg),
|
APIKey: NewAPIKeyClient(cfg),
|
||||||
Account: NewAccountClient(cfg),
|
Account: NewAccountClient(cfg),
|
||||||
AccountGroup: NewAccountGroupClient(cfg),
|
AccountGroup: NewAccountGroupClient(cfg),
|
||||||
Announcement: NewAnnouncementClient(cfg),
|
Announcement: NewAnnouncementClient(cfg),
|
||||||
AnnouncementRead: NewAnnouncementReadClient(cfg),
|
AnnouncementRead: NewAnnouncementReadClient(cfg),
|
||||||
AuthIdentity: NewAuthIdentityClient(cfg),
|
AuthIdentity: NewAuthIdentityClient(cfg),
|
||||||
AuthIdentityChannel: NewAuthIdentityChannelClient(cfg),
|
AuthIdentityChannel: NewAuthIdentityChannelClient(cfg),
|
||||||
ChannelMonitor: NewChannelMonitorClient(cfg),
|
ChannelMonitor: NewChannelMonitorClient(cfg),
|
||||||
ChannelMonitorHistory: NewChannelMonitorHistoryClient(cfg),
|
ChannelMonitorDailyRollup: NewChannelMonitorDailyRollupClient(cfg),
|
||||||
ErrorPassthroughRule: NewErrorPassthroughRuleClient(cfg),
|
ChannelMonitorHistory: NewChannelMonitorHistoryClient(cfg),
|
||||||
Group: NewGroupClient(cfg),
|
ErrorPassthroughRule: NewErrorPassthroughRuleClient(cfg),
|
||||||
IdempotencyRecord: NewIdempotencyRecordClient(cfg),
|
Group: NewGroupClient(cfg),
|
||||||
IdentityAdoptionDecision: NewIdentityAdoptionDecisionClient(cfg),
|
IdempotencyRecord: NewIdempotencyRecordClient(cfg),
|
||||||
PaymentAuditLog: NewPaymentAuditLogClient(cfg),
|
IdentityAdoptionDecision: NewIdentityAdoptionDecisionClient(cfg),
|
||||||
PaymentOrder: NewPaymentOrderClient(cfg),
|
PaymentAuditLog: NewPaymentAuditLogClient(cfg),
|
||||||
PaymentProviderInstance: NewPaymentProviderInstanceClient(cfg),
|
PaymentOrder: NewPaymentOrderClient(cfg),
|
||||||
PendingAuthSession: NewPendingAuthSessionClient(cfg),
|
PaymentProviderInstance: NewPaymentProviderInstanceClient(cfg),
|
||||||
PromoCode: NewPromoCodeClient(cfg),
|
PendingAuthSession: NewPendingAuthSessionClient(cfg),
|
||||||
PromoCodeUsage: NewPromoCodeUsageClient(cfg),
|
PromoCode: NewPromoCodeClient(cfg),
|
||||||
Proxy: NewProxyClient(cfg),
|
PromoCodeUsage: NewPromoCodeUsageClient(cfg),
|
||||||
RedeemCode: NewRedeemCodeClient(cfg),
|
Proxy: NewProxyClient(cfg),
|
||||||
SecuritySecret: NewSecuritySecretClient(cfg),
|
RedeemCode: NewRedeemCodeClient(cfg),
|
||||||
Setting: NewSettingClient(cfg),
|
SecuritySecret: NewSecuritySecretClient(cfg),
|
||||||
SubscriptionPlan: NewSubscriptionPlanClient(cfg),
|
Setting: NewSettingClient(cfg),
|
||||||
TLSFingerprintProfile: NewTLSFingerprintProfileClient(cfg),
|
SubscriptionPlan: NewSubscriptionPlanClient(cfg),
|
||||||
UsageCleanupTask: NewUsageCleanupTaskClient(cfg),
|
TLSFingerprintProfile: NewTLSFingerprintProfileClient(cfg),
|
||||||
UsageLog: NewUsageLogClient(cfg),
|
UsageCleanupTask: NewUsageCleanupTaskClient(cfg),
|
||||||
User: NewUserClient(cfg),
|
UsageLog: NewUsageLogClient(cfg),
|
||||||
UserAllowedGroup: NewUserAllowedGroupClient(cfg),
|
User: NewUserClient(cfg),
|
||||||
UserAttributeDefinition: NewUserAttributeDefinitionClient(cfg),
|
UserAllowedGroup: NewUserAllowedGroupClient(cfg),
|
||||||
UserAttributeValue: NewUserAttributeValueClient(cfg),
|
UserAttributeDefinition: NewUserAttributeDefinitionClient(cfg),
|
||||||
UserSubscription: NewUserSubscriptionClient(cfg),
|
UserAttributeValue: NewUserAttributeValueClient(cfg),
|
||||||
|
UserSubscription: NewUserSubscriptionClient(cfg),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,40 +309,41 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
|
|||||||
cfg := c.config
|
cfg := c.config
|
||||||
cfg.driver = &txDriver{tx: tx, drv: c.driver}
|
cfg.driver = &txDriver{tx: tx, drv: c.driver}
|
||||||
return &Tx{
|
return &Tx{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
config: cfg,
|
config: cfg,
|
||||||
APIKey: NewAPIKeyClient(cfg),
|
APIKey: NewAPIKeyClient(cfg),
|
||||||
Account: NewAccountClient(cfg),
|
Account: NewAccountClient(cfg),
|
||||||
AccountGroup: NewAccountGroupClient(cfg),
|
AccountGroup: NewAccountGroupClient(cfg),
|
||||||
Announcement: NewAnnouncementClient(cfg),
|
Announcement: NewAnnouncementClient(cfg),
|
||||||
AnnouncementRead: NewAnnouncementReadClient(cfg),
|
AnnouncementRead: NewAnnouncementReadClient(cfg),
|
||||||
AuthIdentity: NewAuthIdentityClient(cfg),
|
AuthIdentity: NewAuthIdentityClient(cfg),
|
||||||
AuthIdentityChannel: NewAuthIdentityChannelClient(cfg),
|
AuthIdentityChannel: NewAuthIdentityChannelClient(cfg),
|
||||||
ChannelMonitor: NewChannelMonitorClient(cfg),
|
ChannelMonitor: NewChannelMonitorClient(cfg),
|
||||||
ChannelMonitorHistory: NewChannelMonitorHistoryClient(cfg),
|
ChannelMonitorDailyRollup: NewChannelMonitorDailyRollupClient(cfg),
|
||||||
ErrorPassthroughRule: NewErrorPassthroughRuleClient(cfg),
|
ChannelMonitorHistory: NewChannelMonitorHistoryClient(cfg),
|
||||||
Group: NewGroupClient(cfg),
|
ErrorPassthroughRule: NewErrorPassthroughRuleClient(cfg),
|
||||||
IdempotencyRecord: NewIdempotencyRecordClient(cfg),
|
Group: NewGroupClient(cfg),
|
||||||
IdentityAdoptionDecision: NewIdentityAdoptionDecisionClient(cfg),
|
IdempotencyRecord: NewIdempotencyRecordClient(cfg),
|
||||||
PaymentAuditLog: NewPaymentAuditLogClient(cfg),
|
IdentityAdoptionDecision: NewIdentityAdoptionDecisionClient(cfg),
|
||||||
PaymentOrder: NewPaymentOrderClient(cfg),
|
PaymentAuditLog: NewPaymentAuditLogClient(cfg),
|
||||||
PaymentProviderInstance: NewPaymentProviderInstanceClient(cfg),
|
PaymentOrder: NewPaymentOrderClient(cfg),
|
||||||
PendingAuthSession: NewPendingAuthSessionClient(cfg),
|
PaymentProviderInstance: NewPaymentProviderInstanceClient(cfg),
|
||||||
PromoCode: NewPromoCodeClient(cfg),
|
PendingAuthSession: NewPendingAuthSessionClient(cfg),
|
||||||
PromoCodeUsage: NewPromoCodeUsageClient(cfg),
|
PromoCode: NewPromoCodeClient(cfg),
|
||||||
Proxy: NewProxyClient(cfg),
|
PromoCodeUsage: NewPromoCodeUsageClient(cfg),
|
||||||
RedeemCode: NewRedeemCodeClient(cfg),
|
Proxy: NewProxyClient(cfg),
|
||||||
SecuritySecret: NewSecuritySecretClient(cfg),
|
RedeemCode: NewRedeemCodeClient(cfg),
|
||||||
Setting: NewSettingClient(cfg),
|
SecuritySecret: NewSecuritySecretClient(cfg),
|
||||||
SubscriptionPlan: NewSubscriptionPlanClient(cfg),
|
Setting: NewSettingClient(cfg),
|
||||||
TLSFingerprintProfile: NewTLSFingerprintProfileClient(cfg),
|
SubscriptionPlan: NewSubscriptionPlanClient(cfg),
|
||||||
UsageCleanupTask: NewUsageCleanupTaskClient(cfg),
|
TLSFingerprintProfile: NewTLSFingerprintProfileClient(cfg),
|
||||||
UsageLog: NewUsageLogClient(cfg),
|
UsageCleanupTask: NewUsageCleanupTaskClient(cfg),
|
||||||
User: NewUserClient(cfg),
|
UsageLog: NewUsageLogClient(cfg),
|
||||||
UserAllowedGroup: NewUserAllowedGroupClient(cfg),
|
User: NewUserClient(cfg),
|
||||||
UserAttributeDefinition: NewUserAttributeDefinitionClient(cfg),
|
UserAllowedGroup: NewUserAllowedGroupClient(cfg),
|
||||||
UserAttributeValue: NewUserAttributeValueClient(cfg),
|
UserAttributeDefinition: NewUserAttributeDefinitionClient(cfg),
|
||||||
UserSubscription: NewUserSubscriptionClient(cfg),
|
UserAttributeValue: NewUserAttributeValueClient(cfg),
|
||||||
|
UserSubscription: NewUserSubscriptionClient(cfg),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,12 +375,12 @@ func (c *Client) Use(hooks ...Hook) {
|
|||||||
for _, n := range []interface{ Use(...Hook) }{
|
for _, n := range []interface{ Use(...Hook) }{
|
||||||
c.APIKey, c.Account, c.AccountGroup, c.Announcement, c.AnnouncementRead,
|
c.APIKey, c.Account, c.AccountGroup, c.Announcement, c.AnnouncementRead,
|
||||||
c.AuthIdentity, c.AuthIdentityChannel, c.ChannelMonitor,
|
c.AuthIdentity, c.AuthIdentityChannel, c.ChannelMonitor,
|
||||||
c.ChannelMonitorHistory, c.ErrorPassthroughRule, c.Group, c.IdempotencyRecord,
|
c.ChannelMonitorDailyRollup, c.ChannelMonitorHistory, c.ErrorPassthroughRule,
|
||||||
c.IdentityAdoptionDecision, c.PaymentAuditLog, c.PaymentOrder,
|
c.Group, c.IdempotencyRecord, c.IdentityAdoptionDecision, c.PaymentAuditLog,
|
||||||
c.PaymentProviderInstance, c.PendingAuthSession, c.PromoCode, c.PromoCodeUsage,
|
c.PaymentOrder, c.PaymentProviderInstance, c.PendingAuthSession, c.PromoCode,
|
||||||
c.Proxy, c.RedeemCode, c.SecuritySecret, c.Setting, c.SubscriptionPlan,
|
c.PromoCodeUsage, c.Proxy, c.RedeemCode, c.SecuritySecret, c.Setting,
|
||||||
c.TLSFingerprintProfile, c.UsageCleanupTask, c.UsageLog, c.User,
|
c.SubscriptionPlan, c.TLSFingerprintProfile, c.UsageCleanupTask, c.UsageLog,
|
||||||
c.UserAllowedGroup, c.UserAttributeDefinition, c.UserAttributeValue,
|
c.User, c.UserAllowedGroup, c.UserAttributeDefinition, c.UserAttributeValue,
|
||||||
c.UserSubscription,
|
c.UserSubscription,
|
||||||
} {
|
} {
|
||||||
n.Use(hooks...)
|
n.Use(hooks...)
|
||||||
@@ -387,12 +393,12 @@ func (c *Client) Intercept(interceptors ...Interceptor) {
|
|||||||
for _, n := range []interface{ Intercept(...Interceptor) }{
|
for _, n := range []interface{ Intercept(...Interceptor) }{
|
||||||
c.APIKey, c.Account, c.AccountGroup, c.Announcement, c.AnnouncementRead,
|
c.APIKey, c.Account, c.AccountGroup, c.Announcement, c.AnnouncementRead,
|
||||||
c.AuthIdentity, c.AuthIdentityChannel, c.ChannelMonitor,
|
c.AuthIdentity, c.AuthIdentityChannel, c.ChannelMonitor,
|
||||||
c.ChannelMonitorHistory, c.ErrorPassthroughRule, c.Group, c.IdempotencyRecord,
|
c.ChannelMonitorDailyRollup, c.ChannelMonitorHistory, c.ErrorPassthroughRule,
|
||||||
c.IdentityAdoptionDecision, c.PaymentAuditLog, c.PaymentOrder,
|
c.Group, c.IdempotencyRecord, c.IdentityAdoptionDecision, c.PaymentAuditLog,
|
||||||
c.PaymentProviderInstance, c.PendingAuthSession, c.PromoCode, c.PromoCodeUsage,
|
c.PaymentOrder, c.PaymentProviderInstance, c.PendingAuthSession, c.PromoCode,
|
||||||
c.Proxy, c.RedeemCode, c.SecuritySecret, c.Setting, c.SubscriptionPlan,
|
c.PromoCodeUsage, c.Proxy, c.RedeemCode, c.SecuritySecret, c.Setting,
|
||||||
c.TLSFingerprintProfile, c.UsageCleanupTask, c.UsageLog, c.User,
|
c.SubscriptionPlan, c.TLSFingerprintProfile, c.UsageCleanupTask, c.UsageLog,
|
||||||
c.UserAllowedGroup, c.UserAttributeDefinition, c.UserAttributeValue,
|
c.User, c.UserAllowedGroup, c.UserAttributeDefinition, c.UserAttributeValue,
|
||||||
c.UserSubscription,
|
c.UserSubscription,
|
||||||
} {
|
} {
|
||||||
n.Intercept(interceptors...)
|
n.Intercept(interceptors...)
|
||||||
@@ -418,6 +424,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
|
|||||||
return c.AuthIdentityChannel.mutate(ctx, m)
|
return c.AuthIdentityChannel.mutate(ctx, m)
|
||||||
case *ChannelMonitorMutation:
|
case *ChannelMonitorMutation:
|
||||||
return c.ChannelMonitor.mutate(ctx, m)
|
return c.ChannelMonitor.mutate(ctx, m)
|
||||||
|
case *ChannelMonitorDailyRollupMutation:
|
||||||
|
return c.ChannelMonitorDailyRollup.mutate(ctx, m)
|
||||||
case *ChannelMonitorHistoryMutation:
|
case *ChannelMonitorHistoryMutation:
|
||||||
return c.ChannelMonitorHistory.mutate(ctx, m)
|
return c.ChannelMonitorHistory.mutate(ctx, m)
|
||||||
case *ErrorPassthroughRuleMutation:
|
case *ErrorPassthroughRuleMutation:
|
||||||
@@ -1737,6 +1745,22 @@ func (c *ChannelMonitorClient) QueryHistory(_m *ChannelMonitor) *ChannelMonitorH
|
|||||||
return query
|
return query
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// QueryDailyRollups queries the daily_rollups edge of a ChannelMonitor.
|
||||||
|
func (c *ChannelMonitorClient) QueryDailyRollups(_m *ChannelMonitor) *ChannelMonitorDailyRollupQuery {
|
||||||
|
query := (&ChannelMonitorDailyRollupClient{config: c.config}).Query()
|
||||||
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||||
|
id := _m.ID
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(channelmonitor.Table, channelmonitor.FieldID, id),
|
||||||
|
sqlgraph.To(channelmonitordailyrollup.Table, channelmonitordailyrollup.FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.O2M, false, channelmonitor.DailyRollupsTable, channelmonitor.DailyRollupsColumn),
|
||||||
|
)
|
||||||
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||||
|
return fromV, nil
|
||||||
|
}
|
||||||
|
return query
|
||||||
|
}
|
||||||
|
|
||||||
// Hooks returns the client hooks.
|
// Hooks returns the client hooks.
|
||||||
func (c *ChannelMonitorClient) Hooks() []Hook {
|
func (c *ChannelMonitorClient) Hooks() []Hook {
|
||||||
return c.hooks.ChannelMonitor
|
return c.hooks.ChannelMonitor
|
||||||
@@ -1762,6 +1786,157 @@ func (c *ChannelMonitorClient) mutate(ctx context.Context, m *ChannelMonitorMuta
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ChannelMonitorDailyRollupClient is a client for the ChannelMonitorDailyRollup schema.
|
||||||
|
type ChannelMonitorDailyRollupClient struct {
|
||||||
|
config
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewChannelMonitorDailyRollupClient returns a client for the ChannelMonitorDailyRollup from the given config.
|
||||||
|
func NewChannelMonitorDailyRollupClient(c config) *ChannelMonitorDailyRollupClient {
|
||||||
|
return &ChannelMonitorDailyRollupClient{config: c}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use adds a list of mutation hooks to the hooks stack.
|
||||||
|
// A call to `Use(f, g, h)` equals to `channelmonitordailyrollup.Hooks(f(g(h())))`.
|
||||||
|
func (c *ChannelMonitorDailyRollupClient) Use(hooks ...Hook) {
|
||||||
|
c.hooks.ChannelMonitorDailyRollup = append(c.hooks.ChannelMonitorDailyRollup, hooks...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||||
|
// A call to `Intercept(f, g, h)` equals to `channelmonitordailyrollup.Intercept(f(g(h())))`.
|
||||||
|
func (c *ChannelMonitorDailyRollupClient) Intercept(interceptors ...Interceptor) {
|
||||||
|
c.inters.ChannelMonitorDailyRollup = append(c.inters.ChannelMonitorDailyRollup, interceptors...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create returns a builder for creating a ChannelMonitorDailyRollup entity.
|
||||||
|
func (c *ChannelMonitorDailyRollupClient) Create() *ChannelMonitorDailyRollupCreate {
|
||||||
|
mutation := newChannelMonitorDailyRollupMutation(c.config, OpCreate)
|
||||||
|
return &ChannelMonitorDailyRollupCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateBulk returns a builder for creating a bulk of ChannelMonitorDailyRollup entities.
|
||||||
|
func (c *ChannelMonitorDailyRollupClient) CreateBulk(builders ...*ChannelMonitorDailyRollupCreate) *ChannelMonitorDailyRollupCreateBulk {
|
||||||
|
return &ChannelMonitorDailyRollupCreateBulk{config: c.config, builders: builders}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||||
|
// a builder and applies setFunc on it.
|
||||||
|
func (c *ChannelMonitorDailyRollupClient) MapCreateBulk(slice any, setFunc func(*ChannelMonitorDailyRollupCreate, int)) *ChannelMonitorDailyRollupCreateBulk {
|
||||||
|
rv := reflect.ValueOf(slice)
|
||||||
|
if rv.Kind() != reflect.Slice {
|
||||||
|
return &ChannelMonitorDailyRollupCreateBulk{err: fmt.Errorf("calling to ChannelMonitorDailyRollupClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||||
|
}
|
||||||
|
builders := make([]*ChannelMonitorDailyRollupCreate, rv.Len())
|
||||||
|
for i := 0; i < rv.Len(); i++ {
|
||||||
|
builders[i] = c.Create()
|
||||||
|
setFunc(builders[i], i)
|
||||||
|
}
|
||||||
|
return &ChannelMonitorDailyRollupCreateBulk{config: c.config, builders: builders}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update returns an update builder for ChannelMonitorDailyRollup.
|
||||||
|
func (c *ChannelMonitorDailyRollupClient) Update() *ChannelMonitorDailyRollupUpdate {
|
||||||
|
mutation := newChannelMonitorDailyRollupMutation(c.config, OpUpdate)
|
||||||
|
return &ChannelMonitorDailyRollupUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateOne returns an update builder for the given entity.
|
||||||
|
func (c *ChannelMonitorDailyRollupClient) UpdateOne(_m *ChannelMonitorDailyRollup) *ChannelMonitorDailyRollupUpdateOne {
|
||||||
|
mutation := newChannelMonitorDailyRollupMutation(c.config, OpUpdateOne, withChannelMonitorDailyRollup(_m))
|
||||||
|
return &ChannelMonitorDailyRollupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateOneID returns an update builder for the given id.
|
||||||
|
func (c *ChannelMonitorDailyRollupClient) UpdateOneID(id int64) *ChannelMonitorDailyRollupUpdateOne {
|
||||||
|
mutation := newChannelMonitorDailyRollupMutation(c.config, OpUpdateOne, withChannelMonitorDailyRollupID(id))
|
||||||
|
return &ChannelMonitorDailyRollupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete returns a delete builder for ChannelMonitorDailyRollup.
|
||||||
|
func (c *ChannelMonitorDailyRollupClient) Delete() *ChannelMonitorDailyRollupDelete {
|
||||||
|
mutation := newChannelMonitorDailyRollupMutation(c.config, OpDelete)
|
||||||
|
return &ChannelMonitorDailyRollupDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOne returns a builder for deleting the given entity.
|
||||||
|
func (c *ChannelMonitorDailyRollupClient) DeleteOne(_m *ChannelMonitorDailyRollup) *ChannelMonitorDailyRollupDeleteOne {
|
||||||
|
return c.DeleteOneID(_m.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||||
|
func (c *ChannelMonitorDailyRollupClient) DeleteOneID(id int64) *ChannelMonitorDailyRollupDeleteOne {
|
||||||
|
builder := c.Delete().Where(channelmonitordailyrollup.ID(id))
|
||||||
|
builder.mutation.id = &id
|
||||||
|
builder.mutation.op = OpDeleteOne
|
||||||
|
return &ChannelMonitorDailyRollupDeleteOne{builder}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Query returns a query builder for ChannelMonitorDailyRollup.
|
||||||
|
func (c *ChannelMonitorDailyRollupClient) Query() *ChannelMonitorDailyRollupQuery {
|
||||||
|
return &ChannelMonitorDailyRollupQuery{
|
||||||
|
config: c.config,
|
||||||
|
ctx: &QueryContext{Type: TypeChannelMonitorDailyRollup},
|
||||||
|
inters: c.Interceptors(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get returns a ChannelMonitorDailyRollup entity by its id.
|
||||||
|
func (c *ChannelMonitorDailyRollupClient) Get(ctx context.Context, id int64) (*ChannelMonitorDailyRollup, error) {
|
||||||
|
return c.Query().Where(channelmonitordailyrollup.ID(id)).Only(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetX is like Get, but panics if an error occurs.
|
||||||
|
func (c *ChannelMonitorDailyRollupClient) GetX(ctx context.Context, id int64) *ChannelMonitorDailyRollup {
|
||||||
|
obj, err := c.Get(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return obj
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryMonitor queries the monitor edge of a ChannelMonitorDailyRollup.
|
||||||
|
func (c *ChannelMonitorDailyRollupClient) QueryMonitor(_m *ChannelMonitorDailyRollup) *ChannelMonitorQuery {
|
||||||
|
query := (&ChannelMonitorClient{config: c.config}).Query()
|
||||||
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||||
|
id := _m.ID
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(channelmonitordailyrollup.Table, channelmonitordailyrollup.FieldID, id),
|
||||||
|
sqlgraph.To(channelmonitor.Table, channelmonitor.FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.M2O, true, channelmonitordailyrollup.MonitorTable, channelmonitordailyrollup.MonitorColumn),
|
||||||
|
)
|
||||||
|
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||||
|
return fromV, nil
|
||||||
|
}
|
||||||
|
return query
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hooks returns the client hooks.
|
||||||
|
func (c *ChannelMonitorDailyRollupClient) Hooks() []Hook {
|
||||||
|
hooks := c.hooks.ChannelMonitorDailyRollup
|
||||||
|
return append(hooks[:len(hooks):len(hooks)], channelmonitordailyrollup.Hooks[:]...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Interceptors returns the client interceptors.
|
||||||
|
func (c *ChannelMonitorDailyRollupClient) Interceptors() []Interceptor {
|
||||||
|
inters := c.inters.ChannelMonitorDailyRollup
|
||||||
|
return append(inters[:len(inters):len(inters)], channelmonitordailyrollup.Interceptors[:]...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ChannelMonitorDailyRollupClient) mutate(ctx context.Context, m *ChannelMonitorDailyRollupMutation) (Value, error) {
|
||||||
|
switch m.Op() {
|
||||||
|
case OpCreate:
|
||||||
|
return (&ChannelMonitorDailyRollupCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||||
|
case OpUpdate:
|
||||||
|
return (&ChannelMonitorDailyRollupUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||||
|
case OpUpdateOne:
|
||||||
|
return (&ChannelMonitorDailyRollupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||||
|
case OpDelete, OpDeleteOne:
|
||||||
|
return (&ChannelMonitorDailyRollupDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("ent: unknown ChannelMonitorDailyRollup mutation op: %q", m.Op())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ChannelMonitorHistoryClient is a client for the ChannelMonitorHistory schema.
|
// ChannelMonitorHistoryClient is a client for the ChannelMonitorHistory schema.
|
||||||
type ChannelMonitorHistoryClient struct {
|
type ChannelMonitorHistoryClient struct {
|
||||||
config
|
config
|
||||||
@@ -1888,12 +2063,14 @@ func (c *ChannelMonitorHistoryClient) QueryMonitor(_m *ChannelMonitorHistory) *C
|
|||||||
|
|
||||||
// Hooks returns the client hooks.
|
// Hooks returns the client hooks.
|
||||||
func (c *ChannelMonitorHistoryClient) Hooks() []Hook {
|
func (c *ChannelMonitorHistoryClient) Hooks() []Hook {
|
||||||
return c.hooks.ChannelMonitorHistory
|
hooks := c.hooks.ChannelMonitorHistory
|
||||||
|
return append(hooks[:len(hooks):len(hooks)], channelmonitorhistory.Hooks[:]...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interceptors returns the client interceptors.
|
// Interceptors returns the client interceptors.
|
||||||
func (c *ChannelMonitorHistoryClient) Interceptors() []Interceptor {
|
func (c *ChannelMonitorHistoryClient) Interceptors() []Interceptor {
|
||||||
return c.inters.ChannelMonitorHistory
|
inters := c.inters.ChannelMonitorHistory
|
||||||
|
return append(inters[:len(inters):len(inters)], channelmonitorhistory.Interceptors[:]...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ChannelMonitorHistoryClient) mutate(ctx context.Context, m *ChannelMonitorHistoryMutation) (Value, error) {
|
func (c *ChannelMonitorHistoryClient) mutate(ctx context.Context, m *ChannelMonitorHistoryMutation) (Value, error) {
|
||||||
@@ -5671,23 +5848,23 @@ func (c *UserSubscriptionClient) mutate(ctx context.Context, m *UserSubscription
|
|||||||
type (
|
type (
|
||||||
hooks struct {
|
hooks struct {
|
||||||
APIKey, Account, AccountGroup, Announcement, AnnouncementRead, AuthIdentity,
|
APIKey, Account, AccountGroup, Announcement, AnnouncementRead, AuthIdentity,
|
||||||
AuthIdentityChannel, ChannelMonitor, ChannelMonitorHistory,
|
AuthIdentityChannel, ChannelMonitor, ChannelMonitorDailyRollup,
|
||||||
ErrorPassthroughRule, Group, IdempotencyRecord, IdentityAdoptionDecision,
|
ChannelMonitorHistory, ErrorPassthroughRule, Group, IdempotencyRecord,
|
||||||
PaymentAuditLog, PaymentOrder, PaymentProviderInstance, PendingAuthSession,
|
IdentityAdoptionDecision, PaymentAuditLog, PaymentOrder,
|
||||||
PromoCode, PromoCodeUsage, Proxy, RedeemCode, SecuritySecret, Setting,
|
PaymentProviderInstance, PendingAuthSession, PromoCode, PromoCodeUsage, Proxy,
|
||||||
SubscriptionPlan, TLSFingerprintProfile, UsageCleanupTask, UsageLog, User,
|
RedeemCode, SecuritySecret, Setting, SubscriptionPlan, TLSFingerprintProfile,
|
||||||
UserAllowedGroup, UserAttributeDefinition, UserAttributeValue,
|
UsageCleanupTask, UsageLog, User, UserAllowedGroup, UserAttributeDefinition,
|
||||||
UserSubscription []ent.Hook
|
UserAttributeValue, UserSubscription []ent.Hook
|
||||||
}
|
}
|
||||||
inters struct {
|
inters struct {
|
||||||
APIKey, Account, AccountGroup, Announcement, AnnouncementRead, AuthIdentity,
|
APIKey, Account, AccountGroup, Announcement, AnnouncementRead, AuthIdentity,
|
||||||
AuthIdentityChannel, ChannelMonitor, ChannelMonitorHistory,
|
AuthIdentityChannel, ChannelMonitor, ChannelMonitorDailyRollup,
|
||||||
ErrorPassthroughRule, Group, IdempotencyRecord, IdentityAdoptionDecision,
|
ChannelMonitorHistory, ErrorPassthroughRule, Group, IdempotencyRecord,
|
||||||
PaymentAuditLog, PaymentOrder, PaymentProviderInstance, PendingAuthSession,
|
IdentityAdoptionDecision, PaymentAuditLog, PaymentOrder,
|
||||||
PromoCode, PromoCodeUsage, Proxy, RedeemCode, SecuritySecret, Setting,
|
PaymentProviderInstance, PendingAuthSession, PromoCode, PromoCodeUsage, Proxy,
|
||||||
SubscriptionPlan, TLSFingerprintProfile, UsageCleanupTask, UsageLog, User,
|
RedeemCode, SecuritySecret, Setting, SubscriptionPlan, TLSFingerprintProfile,
|
||||||
UserAllowedGroup, UserAttributeDefinition, UserAttributeValue,
|
UsageCleanupTask, UsageLog, User, UserAllowedGroup, UserAttributeDefinition,
|
||||||
UserSubscription []ent.Interceptor
|
UserAttributeValue, UserSubscription []ent.Interceptor
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import (
|
|||||||
"github.com/Wei-Shaw/sub2api/ent/authidentity"
|
"github.com/Wei-Shaw/sub2api/ent/authidentity"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/authidentitychannel"
|
"github.com/Wei-Shaw/sub2api/ent/authidentitychannel"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/channelmonitor"
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitor"
|
||||||
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitordailyrollup"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/channelmonitorhistory"
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitorhistory"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
|
"github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/group"
|
"github.com/Wei-Shaw/sub2api/ent/group"
|
||||||
@@ -104,38 +105,39 @@ var (
|
|||||||
func checkColumn(t, c string) error {
|
func checkColumn(t, c string) error {
|
||||||
initCheck.Do(func() {
|
initCheck.Do(func() {
|
||||||
columnCheck = sql.NewColumnCheck(map[string]func(string) bool{
|
columnCheck = sql.NewColumnCheck(map[string]func(string) bool{
|
||||||
apikey.Table: apikey.ValidColumn,
|
apikey.Table: apikey.ValidColumn,
|
||||||
account.Table: account.ValidColumn,
|
account.Table: account.ValidColumn,
|
||||||
accountgroup.Table: accountgroup.ValidColumn,
|
accountgroup.Table: accountgroup.ValidColumn,
|
||||||
announcement.Table: announcement.ValidColumn,
|
announcement.Table: announcement.ValidColumn,
|
||||||
announcementread.Table: announcementread.ValidColumn,
|
announcementread.Table: announcementread.ValidColumn,
|
||||||
authidentity.Table: authidentity.ValidColumn,
|
authidentity.Table: authidentity.ValidColumn,
|
||||||
authidentitychannel.Table: authidentitychannel.ValidColumn,
|
authidentitychannel.Table: authidentitychannel.ValidColumn,
|
||||||
channelmonitor.Table: channelmonitor.ValidColumn,
|
channelmonitor.Table: channelmonitor.ValidColumn,
|
||||||
channelmonitorhistory.Table: channelmonitorhistory.ValidColumn,
|
channelmonitordailyrollup.Table: channelmonitordailyrollup.ValidColumn,
|
||||||
errorpassthroughrule.Table: errorpassthroughrule.ValidColumn,
|
channelmonitorhistory.Table: channelmonitorhistory.ValidColumn,
|
||||||
group.Table: group.ValidColumn,
|
errorpassthroughrule.Table: errorpassthroughrule.ValidColumn,
|
||||||
idempotencyrecord.Table: idempotencyrecord.ValidColumn,
|
group.Table: group.ValidColumn,
|
||||||
identityadoptiondecision.Table: identityadoptiondecision.ValidColumn,
|
idempotencyrecord.Table: idempotencyrecord.ValidColumn,
|
||||||
paymentauditlog.Table: paymentauditlog.ValidColumn,
|
identityadoptiondecision.Table: identityadoptiondecision.ValidColumn,
|
||||||
paymentorder.Table: paymentorder.ValidColumn,
|
paymentauditlog.Table: paymentauditlog.ValidColumn,
|
||||||
paymentproviderinstance.Table: paymentproviderinstance.ValidColumn,
|
paymentorder.Table: paymentorder.ValidColumn,
|
||||||
pendingauthsession.Table: pendingauthsession.ValidColumn,
|
paymentproviderinstance.Table: paymentproviderinstance.ValidColumn,
|
||||||
promocode.Table: promocode.ValidColumn,
|
pendingauthsession.Table: pendingauthsession.ValidColumn,
|
||||||
promocodeusage.Table: promocodeusage.ValidColumn,
|
promocode.Table: promocode.ValidColumn,
|
||||||
proxy.Table: proxy.ValidColumn,
|
promocodeusage.Table: promocodeusage.ValidColumn,
|
||||||
redeemcode.Table: redeemcode.ValidColumn,
|
proxy.Table: proxy.ValidColumn,
|
||||||
securitysecret.Table: securitysecret.ValidColumn,
|
redeemcode.Table: redeemcode.ValidColumn,
|
||||||
setting.Table: setting.ValidColumn,
|
securitysecret.Table: securitysecret.ValidColumn,
|
||||||
subscriptionplan.Table: subscriptionplan.ValidColumn,
|
setting.Table: setting.ValidColumn,
|
||||||
tlsfingerprintprofile.Table: tlsfingerprintprofile.ValidColumn,
|
subscriptionplan.Table: subscriptionplan.ValidColumn,
|
||||||
usagecleanuptask.Table: usagecleanuptask.ValidColumn,
|
tlsfingerprintprofile.Table: tlsfingerprintprofile.ValidColumn,
|
||||||
usagelog.Table: usagelog.ValidColumn,
|
usagecleanuptask.Table: usagecleanuptask.ValidColumn,
|
||||||
user.Table: user.ValidColumn,
|
usagelog.Table: usagelog.ValidColumn,
|
||||||
userallowedgroup.Table: userallowedgroup.ValidColumn,
|
user.Table: user.ValidColumn,
|
||||||
userattributedefinition.Table: userattributedefinition.ValidColumn,
|
userallowedgroup.Table: userallowedgroup.ValidColumn,
|
||||||
userattributevalue.Table: userattributevalue.ValidColumn,
|
userattributedefinition.Table: userattributedefinition.ValidColumn,
|
||||||
usersubscription.Table: usersubscription.ValidColumn,
|
userattributevalue.Table: userattributevalue.ValidColumn,
|
||||||
|
usersubscription.Table: usersubscription.ValidColumn,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
return columnCheck(t, c)
|
return columnCheck(t, c)
|
||||||
|
|||||||
@@ -105,6 +105,18 @@ func (f ChannelMonitorFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Val
|
|||||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ChannelMonitorMutation", m)
|
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ChannelMonitorMutation", m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The ChannelMonitorDailyRollupFunc type is an adapter to allow the use of ordinary
|
||||||
|
// function as ChannelMonitorDailyRollup mutator.
|
||||||
|
type ChannelMonitorDailyRollupFunc func(context.Context, *ent.ChannelMonitorDailyRollupMutation) (ent.Value, error)
|
||||||
|
|
||||||
|
// Mutate calls f(ctx, m).
|
||||||
|
func (f ChannelMonitorDailyRollupFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||||
|
if mv, ok := m.(*ent.ChannelMonitorDailyRollupMutation); ok {
|
||||||
|
return f(ctx, mv)
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ChannelMonitorDailyRollupMutation", m)
|
||||||
|
}
|
||||||
|
|
||||||
// The ChannelMonitorHistoryFunc type is an adapter to allow the use of ordinary
|
// The ChannelMonitorHistoryFunc type is an adapter to allow the use of ordinary
|
||||||
// function as ChannelMonitorHistory mutator.
|
// function as ChannelMonitorHistory mutator.
|
||||||
type ChannelMonitorHistoryFunc func(context.Context, *ent.ChannelMonitorHistoryMutation) (ent.Value, error)
|
type ChannelMonitorHistoryFunc func(context.Context, *ent.ChannelMonitorHistoryMutation) (ent.Value, error)
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import (
|
|||||||
"github.com/Wei-Shaw/sub2api/ent/authidentity"
|
"github.com/Wei-Shaw/sub2api/ent/authidentity"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/authidentitychannel"
|
"github.com/Wei-Shaw/sub2api/ent/authidentitychannel"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/channelmonitor"
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitor"
|
||||||
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitordailyrollup"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/channelmonitorhistory"
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitorhistory"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
|
"github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/group"
|
"github.com/Wei-Shaw/sub2api/ent/group"
|
||||||
@@ -315,6 +316,33 @@ func (f TraverseChannelMonitor) Traverse(ctx context.Context, q ent.Query) error
|
|||||||
return fmt.Errorf("unexpected query type %T. expect *ent.ChannelMonitorQuery", q)
|
return fmt.Errorf("unexpected query type %T. expect *ent.ChannelMonitorQuery", q)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The ChannelMonitorDailyRollupFunc type is an adapter to allow the use of ordinary function as a Querier.
|
||||||
|
type ChannelMonitorDailyRollupFunc func(context.Context, *ent.ChannelMonitorDailyRollupQuery) (ent.Value, error)
|
||||||
|
|
||||||
|
// Query calls f(ctx, q).
|
||||||
|
func (f ChannelMonitorDailyRollupFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
|
||||||
|
if q, ok := q.(*ent.ChannelMonitorDailyRollupQuery); ok {
|
||||||
|
return f(ctx, q)
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("unexpected query type %T. expect *ent.ChannelMonitorDailyRollupQuery", q)
|
||||||
|
}
|
||||||
|
|
||||||
|
// The TraverseChannelMonitorDailyRollup type is an adapter to allow the use of ordinary function as Traverser.
|
||||||
|
type TraverseChannelMonitorDailyRollup func(context.Context, *ent.ChannelMonitorDailyRollupQuery) error
|
||||||
|
|
||||||
|
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
|
||||||
|
func (f TraverseChannelMonitorDailyRollup) Intercept(next ent.Querier) ent.Querier {
|
||||||
|
return next
|
||||||
|
}
|
||||||
|
|
||||||
|
// Traverse calls f(ctx, q).
|
||||||
|
func (f TraverseChannelMonitorDailyRollup) Traverse(ctx context.Context, q ent.Query) error {
|
||||||
|
if q, ok := q.(*ent.ChannelMonitorDailyRollupQuery); ok {
|
||||||
|
return f(ctx, q)
|
||||||
|
}
|
||||||
|
return fmt.Errorf("unexpected query type %T. expect *ent.ChannelMonitorDailyRollupQuery", q)
|
||||||
|
}
|
||||||
|
|
||||||
// The ChannelMonitorHistoryFunc type is an adapter to allow the use of ordinary function as a Querier.
|
// The ChannelMonitorHistoryFunc type is an adapter to allow the use of ordinary function as a Querier.
|
||||||
type ChannelMonitorHistoryFunc func(context.Context, *ent.ChannelMonitorHistoryQuery) (ent.Value, error)
|
type ChannelMonitorHistoryFunc func(context.Context, *ent.ChannelMonitorHistoryQuery) (ent.Value, error)
|
||||||
|
|
||||||
@@ -982,6 +1010,8 @@ func NewQuery(q ent.Query) (Query, error) {
|
|||||||
return &query[*ent.AuthIdentityChannelQuery, predicate.AuthIdentityChannel, authidentitychannel.OrderOption]{typ: ent.TypeAuthIdentityChannel, tq: q}, nil
|
return &query[*ent.AuthIdentityChannelQuery, predicate.AuthIdentityChannel, authidentitychannel.OrderOption]{typ: ent.TypeAuthIdentityChannel, tq: q}, nil
|
||||||
case *ent.ChannelMonitorQuery:
|
case *ent.ChannelMonitorQuery:
|
||||||
return &query[*ent.ChannelMonitorQuery, predicate.ChannelMonitor, channelmonitor.OrderOption]{typ: ent.TypeChannelMonitor, tq: q}, nil
|
return &query[*ent.ChannelMonitorQuery, predicate.ChannelMonitor, channelmonitor.OrderOption]{typ: ent.TypeChannelMonitor, tq: q}, nil
|
||||||
|
case *ent.ChannelMonitorDailyRollupQuery:
|
||||||
|
return &query[*ent.ChannelMonitorDailyRollupQuery, predicate.ChannelMonitorDailyRollup, channelmonitordailyrollup.OrderOption]{typ: ent.TypeChannelMonitorDailyRollup, tq: q}, nil
|
||||||
case *ent.ChannelMonitorHistoryQuery:
|
case *ent.ChannelMonitorHistoryQuery:
|
||||||
return &query[*ent.ChannelMonitorHistoryQuery, predicate.ChannelMonitorHistory, channelmonitorhistory.OrderOption]{typ: ent.TypeChannelMonitorHistory, tq: q}, nil
|
return &query[*ent.ChannelMonitorHistoryQuery, predicate.ChannelMonitorHistory, channelmonitorhistory.OrderOption]{typ: ent.TypeChannelMonitorHistory, tq: q}, nil
|
||||||
case *ent.ErrorPassthroughRuleQuery:
|
case *ent.ErrorPassthroughRuleQuery:
|
||||||
|
|||||||
@@ -461,9 +461,55 @@ var (
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
// ChannelMonitorDailyRollupsColumns holds the columns for the "channel_monitor_daily_rollups" table.
|
||||||
|
ChannelMonitorDailyRollupsColumns = []*schema.Column{
|
||||||
|
{Name: "id", Type: field.TypeInt64, Increment: true},
|
||||||
|
{Name: "deleted_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"postgres": "timestamptz"}},
|
||||||
|
{Name: "model", Type: field.TypeString, Size: 200},
|
||||||
|
{Name: "bucket_date", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "date"}},
|
||||||
|
{Name: "total_checks", Type: field.TypeInt, Default: 0},
|
||||||
|
{Name: "ok_count", Type: field.TypeInt, Default: 0},
|
||||||
|
{Name: "operational_count", Type: field.TypeInt, Default: 0},
|
||||||
|
{Name: "degraded_count", Type: field.TypeInt, Default: 0},
|
||||||
|
{Name: "failed_count", Type: field.TypeInt, Default: 0},
|
||||||
|
{Name: "error_count", Type: field.TypeInt, Default: 0},
|
||||||
|
{Name: "sum_latency_ms", Type: field.TypeInt64, Default: 0},
|
||||||
|
{Name: "count_latency", Type: field.TypeInt, Default: 0},
|
||||||
|
{Name: "sum_ping_latency_ms", Type: field.TypeInt64, Default: 0},
|
||||||
|
{Name: "count_ping_latency", Type: field.TypeInt, Default: 0},
|
||||||
|
{Name: "computed_at", Type: field.TypeTime},
|
||||||
|
{Name: "monitor_id", Type: field.TypeInt64},
|
||||||
|
}
|
||||||
|
// ChannelMonitorDailyRollupsTable holds the schema information for the "channel_monitor_daily_rollups" table.
|
||||||
|
ChannelMonitorDailyRollupsTable = &schema.Table{
|
||||||
|
Name: "channel_monitor_daily_rollups",
|
||||||
|
Columns: ChannelMonitorDailyRollupsColumns,
|
||||||
|
PrimaryKey: []*schema.Column{ChannelMonitorDailyRollupsColumns[0]},
|
||||||
|
ForeignKeys: []*schema.ForeignKey{
|
||||||
|
{
|
||||||
|
Symbol: "channel_monitor_daily_rollups_channel_monitors_daily_rollups",
|
||||||
|
Columns: []*schema.Column{ChannelMonitorDailyRollupsColumns[15]},
|
||||||
|
RefColumns: []*schema.Column{ChannelMonitorsColumns[0]},
|
||||||
|
OnDelete: schema.Cascade,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Indexes: []*schema.Index{
|
||||||
|
{
|
||||||
|
Name: "channelmonitordailyrollup_monitor_id_model_bucket_date",
|
||||||
|
Unique: true,
|
||||||
|
Columns: []*schema.Column{ChannelMonitorDailyRollupsColumns[15], ChannelMonitorDailyRollupsColumns[2], ChannelMonitorDailyRollupsColumns[3]},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "channelmonitordailyrollup_bucket_date",
|
||||||
|
Unique: false,
|
||||||
|
Columns: []*schema.Column{ChannelMonitorDailyRollupsColumns[3]},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
// ChannelMonitorHistoriesColumns holds the columns for the "channel_monitor_histories" table.
|
// ChannelMonitorHistoriesColumns holds the columns for the "channel_monitor_histories" table.
|
||||||
ChannelMonitorHistoriesColumns = []*schema.Column{
|
ChannelMonitorHistoriesColumns = []*schema.Column{
|
||||||
{Name: "id", Type: field.TypeInt64, Increment: true},
|
{Name: "id", Type: field.TypeInt64, Increment: true},
|
||||||
|
{Name: "deleted_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"postgres": "timestamptz"}},
|
||||||
{Name: "model", Type: field.TypeString, Size: 200},
|
{Name: "model", Type: field.TypeString, Size: 200},
|
||||||
{Name: "status", Type: field.TypeEnum, Enums: []string{"operational", "degraded", "failed", "error"}},
|
{Name: "status", Type: field.TypeEnum, Enums: []string{"operational", "degraded", "failed", "error"}},
|
||||||
{Name: "latency_ms", Type: field.TypeInt, Nullable: true},
|
{Name: "latency_ms", Type: field.TypeInt, Nullable: true},
|
||||||
@@ -480,7 +526,7 @@ var (
|
|||||||
ForeignKeys: []*schema.ForeignKey{
|
ForeignKeys: []*schema.ForeignKey{
|
||||||
{
|
{
|
||||||
Symbol: "channel_monitor_histories_channel_monitors_history",
|
Symbol: "channel_monitor_histories_channel_monitors_history",
|
||||||
Columns: []*schema.Column{ChannelMonitorHistoriesColumns[7]},
|
Columns: []*schema.Column{ChannelMonitorHistoriesColumns[8]},
|
||||||
RefColumns: []*schema.Column{ChannelMonitorsColumns[0]},
|
RefColumns: []*schema.Column{ChannelMonitorsColumns[0]},
|
||||||
OnDelete: schema.Cascade,
|
OnDelete: schema.Cascade,
|
||||||
},
|
},
|
||||||
@@ -489,12 +535,12 @@ var (
|
|||||||
{
|
{
|
||||||
Name: "channelmonitorhistory_monitor_id_model_checked_at",
|
Name: "channelmonitorhistory_monitor_id_model_checked_at",
|
||||||
Unique: false,
|
Unique: false,
|
||||||
Columns: []*schema.Column{ChannelMonitorHistoriesColumns[7], ChannelMonitorHistoriesColumns[1], ChannelMonitorHistoriesColumns[6]},
|
Columns: []*schema.Column{ChannelMonitorHistoriesColumns[8], ChannelMonitorHistoriesColumns[2], ChannelMonitorHistoriesColumns[7]},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "channelmonitorhistory_checked_at",
|
Name: "channelmonitorhistory_checked_at",
|
||||||
Unique: false,
|
Unique: false,
|
||||||
Columns: []*schema.Column{ChannelMonitorHistoriesColumns[6]},
|
Columns: []*schema.Column{ChannelMonitorHistoriesColumns[7]},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -1598,6 +1644,7 @@ var (
|
|||||||
AuthIdentitiesTable,
|
AuthIdentitiesTable,
|
||||||
AuthIdentityChannelsTable,
|
AuthIdentityChannelsTable,
|
||||||
ChannelMonitorsTable,
|
ChannelMonitorsTable,
|
||||||
|
ChannelMonitorDailyRollupsTable,
|
||||||
ChannelMonitorHistoriesTable,
|
ChannelMonitorHistoriesTable,
|
||||||
ErrorPassthroughRulesTable,
|
ErrorPassthroughRulesTable,
|
||||||
GroupsTable,
|
GroupsTable,
|
||||||
@@ -1659,6 +1706,10 @@ func init() {
|
|||||||
ChannelMonitorsTable.Annotation = &entsql.Annotation{
|
ChannelMonitorsTable.Annotation = &entsql.Annotation{
|
||||||
Table: "channel_monitors",
|
Table: "channel_monitors",
|
||||||
}
|
}
|
||||||
|
ChannelMonitorDailyRollupsTable.ForeignKeys[0].RefTable = ChannelMonitorsTable
|
||||||
|
ChannelMonitorDailyRollupsTable.Annotation = &entsql.Annotation{
|
||||||
|
Table: "channel_monitor_daily_rollups",
|
||||||
|
}
|
||||||
ChannelMonitorHistoriesTable.ForeignKeys[0].RefTable = ChannelMonitorsTable
|
ChannelMonitorHistoriesTable.ForeignKeys[0].RefTable = ChannelMonitorsTable
|
||||||
ChannelMonitorHistoriesTable.Annotation = &entsql.Annotation{
|
ChannelMonitorHistoriesTable.Annotation = &entsql.Annotation{
|
||||||
Table: "channel_monitor_histories",
|
Table: "channel_monitor_histories",
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -30,6 +30,9 @@ type AuthIdentityChannel func(*sql.Selector)
|
|||||||
// ChannelMonitor is the predicate function for channelmonitor builders.
|
// ChannelMonitor is the predicate function for channelmonitor builders.
|
||||||
type ChannelMonitor func(*sql.Selector)
|
type ChannelMonitor func(*sql.Selector)
|
||||||
|
|
||||||
|
// ChannelMonitorDailyRollup is the predicate function for channelmonitordailyrollup builders.
|
||||||
|
type ChannelMonitorDailyRollup func(*sql.Selector)
|
||||||
|
|
||||||
// ChannelMonitorHistory is the predicate function for channelmonitorhistory builders.
|
// ChannelMonitorHistory is the predicate function for channelmonitorhistory builders.
|
||||||
type ChannelMonitorHistory func(*sql.Selector)
|
type ChannelMonitorHistory func(*sql.Selector)
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/Wei-Shaw/sub2api/ent/authidentity"
|
"github.com/Wei-Shaw/sub2api/ent/authidentity"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/authidentitychannel"
|
"github.com/Wei-Shaw/sub2api/ent/authidentitychannel"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/channelmonitor"
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitor"
|
||||||
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitordailyrollup"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/channelmonitorhistory"
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitorhistory"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
|
"github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/group"
|
"github.com/Wei-Shaw/sub2api/ent/group"
|
||||||
@@ -520,6 +521,82 @@ func init() {
|
|||||||
channelmonitorDescIntervalSeconds := channelmonitorFields[8].Descriptor()
|
channelmonitorDescIntervalSeconds := channelmonitorFields[8].Descriptor()
|
||||||
// channelmonitor.IntervalSecondsValidator is a validator for the "interval_seconds" field. It is called by the builders before save.
|
// channelmonitor.IntervalSecondsValidator is a validator for the "interval_seconds" field. It is called by the builders before save.
|
||||||
channelmonitor.IntervalSecondsValidator = channelmonitorDescIntervalSeconds.Validators[0].(func(int) error)
|
channelmonitor.IntervalSecondsValidator = channelmonitorDescIntervalSeconds.Validators[0].(func(int) error)
|
||||||
|
channelmonitordailyrollupMixin := schema.ChannelMonitorDailyRollup{}.Mixin()
|
||||||
|
channelmonitordailyrollupMixinHooks0 := channelmonitordailyrollupMixin[0].Hooks()
|
||||||
|
channelmonitordailyrollup.Hooks[0] = channelmonitordailyrollupMixinHooks0[0]
|
||||||
|
channelmonitordailyrollupMixinInters0 := channelmonitordailyrollupMixin[0].Interceptors()
|
||||||
|
channelmonitordailyrollup.Interceptors[0] = channelmonitordailyrollupMixinInters0[0]
|
||||||
|
channelmonitordailyrollupFields := schema.ChannelMonitorDailyRollup{}.Fields()
|
||||||
|
_ = channelmonitordailyrollupFields
|
||||||
|
// channelmonitordailyrollupDescModel is the schema descriptor for model field.
|
||||||
|
channelmonitordailyrollupDescModel := channelmonitordailyrollupFields[1].Descriptor()
|
||||||
|
// channelmonitordailyrollup.ModelValidator is a validator for the "model" field. It is called by the builders before save.
|
||||||
|
channelmonitordailyrollup.ModelValidator = func() func(string) error {
|
||||||
|
validators := channelmonitordailyrollupDescModel.Validators
|
||||||
|
fns := [...]func(string) error{
|
||||||
|
validators[0].(func(string) error),
|
||||||
|
validators[1].(func(string) error),
|
||||||
|
}
|
||||||
|
return func(model string) error {
|
||||||
|
for _, fn := range fns {
|
||||||
|
if err := fn(model); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
// channelmonitordailyrollupDescTotalChecks is the schema descriptor for total_checks field.
|
||||||
|
channelmonitordailyrollupDescTotalChecks := channelmonitordailyrollupFields[3].Descriptor()
|
||||||
|
// channelmonitordailyrollup.DefaultTotalChecks holds the default value on creation for the total_checks field.
|
||||||
|
channelmonitordailyrollup.DefaultTotalChecks = channelmonitordailyrollupDescTotalChecks.Default.(int)
|
||||||
|
// channelmonitordailyrollupDescOkCount is the schema descriptor for ok_count field.
|
||||||
|
channelmonitordailyrollupDescOkCount := channelmonitordailyrollupFields[4].Descriptor()
|
||||||
|
// channelmonitordailyrollup.DefaultOkCount holds the default value on creation for the ok_count field.
|
||||||
|
channelmonitordailyrollup.DefaultOkCount = channelmonitordailyrollupDescOkCount.Default.(int)
|
||||||
|
// channelmonitordailyrollupDescOperationalCount is the schema descriptor for operational_count field.
|
||||||
|
channelmonitordailyrollupDescOperationalCount := channelmonitordailyrollupFields[5].Descriptor()
|
||||||
|
// channelmonitordailyrollup.DefaultOperationalCount holds the default value on creation for the operational_count field.
|
||||||
|
channelmonitordailyrollup.DefaultOperationalCount = channelmonitordailyrollupDescOperationalCount.Default.(int)
|
||||||
|
// channelmonitordailyrollupDescDegradedCount is the schema descriptor for degraded_count field.
|
||||||
|
channelmonitordailyrollupDescDegradedCount := channelmonitordailyrollupFields[6].Descriptor()
|
||||||
|
// channelmonitordailyrollup.DefaultDegradedCount holds the default value on creation for the degraded_count field.
|
||||||
|
channelmonitordailyrollup.DefaultDegradedCount = channelmonitordailyrollupDescDegradedCount.Default.(int)
|
||||||
|
// channelmonitordailyrollupDescFailedCount is the schema descriptor for failed_count field.
|
||||||
|
channelmonitordailyrollupDescFailedCount := channelmonitordailyrollupFields[7].Descriptor()
|
||||||
|
// channelmonitordailyrollup.DefaultFailedCount holds the default value on creation for the failed_count field.
|
||||||
|
channelmonitordailyrollup.DefaultFailedCount = channelmonitordailyrollupDescFailedCount.Default.(int)
|
||||||
|
// channelmonitordailyrollupDescErrorCount is the schema descriptor for error_count field.
|
||||||
|
channelmonitordailyrollupDescErrorCount := channelmonitordailyrollupFields[8].Descriptor()
|
||||||
|
// channelmonitordailyrollup.DefaultErrorCount holds the default value on creation for the error_count field.
|
||||||
|
channelmonitordailyrollup.DefaultErrorCount = channelmonitordailyrollupDescErrorCount.Default.(int)
|
||||||
|
// channelmonitordailyrollupDescSumLatencyMs is the schema descriptor for sum_latency_ms field.
|
||||||
|
channelmonitordailyrollupDescSumLatencyMs := channelmonitordailyrollupFields[9].Descriptor()
|
||||||
|
// channelmonitordailyrollup.DefaultSumLatencyMs holds the default value on creation for the sum_latency_ms field.
|
||||||
|
channelmonitordailyrollup.DefaultSumLatencyMs = channelmonitordailyrollupDescSumLatencyMs.Default.(int64)
|
||||||
|
// channelmonitordailyrollupDescCountLatency is the schema descriptor for count_latency field.
|
||||||
|
channelmonitordailyrollupDescCountLatency := channelmonitordailyrollupFields[10].Descriptor()
|
||||||
|
// channelmonitordailyrollup.DefaultCountLatency holds the default value on creation for the count_latency field.
|
||||||
|
channelmonitordailyrollup.DefaultCountLatency = channelmonitordailyrollupDescCountLatency.Default.(int)
|
||||||
|
// channelmonitordailyrollupDescSumPingLatencyMs is the schema descriptor for sum_ping_latency_ms field.
|
||||||
|
channelmonitordailyrollupDescSumPingLatencyMs := channelmonitordailyrollupFields[11].Descriptor()
|
||||||
|
// channelmonitordailyrollup.DefaultSumPingLatencyMs holds the default value on creation for the sum_ping_latency_ms field.
|
||||||
|
channelmonitordailyrollup.DefaultSumPingLatencyMs = channelmonitordailyrollupDescSumPingLatencyMs.Default.(int64)
|
||||||
|
// channelmonitordailyrollupDescCountPingLatency is the schema descriptor for count_ping_latency field.
|
||||||
|
channelmonitordailyrollupDescCountPingLatency := channelmonitordailyrollupFields[12].Descriptor()
|
||||||
|
// channelmonitordailyrollup.DefaultCountPingLatency holds the default value on creation for the count_ping_latency field.
|
||||||
|
channelmonitordailyrollup.DefaultCountPingLatency = channelmonitordailyrollupDescCountPingLatency.Default.(int)
|
||||||
|
// channelmonitordailyrollupDescComputedAt is the schema descriptor for computed_at field.
|
||||||
|
channelmonitordailyrollupDescComputedAt := channelmonitordailyrollupFields[13].Descriptor()
|
||||||
|
// channelmonitordailyrollup.DefaultComputedAt holds the default value on creation for the computed_at field.
|
||||||
|
channelmonitordailyrollup.DefaultComputedAt = channelmonitordailyrollupDescComputedAt.Default.(func() time.Time)
|
||||||
|
// channelmonitordailyrollup.UpdateDefaultComputedAt holds the default value on update for the computed_at field.
|
||||||
|
channelmonitordailyrollup.UpdateDefaultComputedAt = channelmonitordailyrollupDescComputedAt.UpdateDefault.(func() time.Time)
|
||||||
|
channelmonitorhistoryMixin := schema.ChannelMonitorHistory{}.Mixin()
|
||||||
|
channelmonitorhistoryMixinHooks0 := channelmonitorhistoryMixin[0].Hooks()
|
||||||
|
channelmonitorhistory.Hooks[0] = channelmonitorhistoryMixinHooks0[0]
|
||||||
|
channelmonitorhistoryMixinInters0 := channelmonitorhistoryMixin[0].Interceptors()
|
||||||
|
channelmonitorhistory.Interceptors[0] = channelmonitorhistoryMixinInters0[0]
|
||||||
channelmonitorhistoryFields := schema.ChannelMonitorHistory{}.Fields()
|
channelmonitorhistoryFields := schema.ChannelMonitorHistory{}.Fields()
|
||||||
_ = channelmonitorhistoryFields
|
_ = channelmonitorhistoryFields
|
||||||
// channelmonitorhistoryDescModel is the schema descriptor for model field.
|
// channelmonitorhistoryDescModel is the schema descriptor for model field.
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ func (ChannelMonitor) Edges() []ent.Edge {
|
|||||||
return []ent.Edge{
|
return []ent.Edge{
|
||||||
edge.To("history", ChannelMonitorHistory.Type).
|
edge.To("history", ChannelMonitorHistory.Type).
|
||||||
Annotations(entsql.OnDelete(entsql.Cascade)),
|
Annotations(entsql.OnDelete(entsql.Cascade)),
|
||||||
|
edge.To("daily_rollups", ChannelMonitorDailyRollup.Type).
|
||||||
|
Annotations(entsql.OnDelete(entsql.Cascade)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
73
backend/ent/schema/channel_monitor_daily_rollup.go
Normal file
73
backend/ent/schema/channel_monitor_daily_rollup.go
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
package schema
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect"
|
||||||
|
"entgo.io/ent/dialect/entsql"
|
||||||
|
"entgo.io/ent/schema"
|
||||||
|
"entgo.io/ent/schema/edge"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"entgo.io/ent/schema/index"
|
||||||
|
|
||||||
|
"github.com/Wei-Shaw/sub2api/ent/schema/mixins"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ChannelMonitorDailyRollup 按 (monitor_id, model, bucket_date) 维度聚合的渠道监控日统计。
|
||||||
|
// 每天的明细被收敛为一行(保留 status 分布 + 延迟和),用于 7d/15d/30d 窗口的可用率
|
||||||
|
// 加权计算(avg_latency = sum_latency_ms / count_latency;availability = ok_count / total_checks)。
|
||||||
|
type ChannelMonitorDailyRollup struct {
|
||||||
|
ent.Schema
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ChannelMonitorDailyRollup) Annotations() []schema.Annotation {
|
||||||
|
return []schema.Annotation{
|
||||||
|
entsql.Annotation{Table: "channel_monitor_daily_rollups"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ChannelMonitorDailyRollup) Mixin() []ent.Mixin {
|
||||||
|
return []ent.Mixin{
|
||||||
|
mixins.SoftDeleteMixin{},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ChannelMonitorDailyRollup) Fields() []ent.Field {
|
||||||
|
return []ent.Field{
|
||||||
|
field.Int64("monitor_id"),
|
||||||
|
field.String("model").
|
||||||
|
NotEmpty().
|
||||||
|
MaxLen(200),
|
||||||
|
field.Time("bucket_date").
|
||||||
|
SchemaType(map[string]string{dialect.Postgres: "date"}),
|
||||||
|
field.Int("total_checks").Default(0),
|
||||||
|
field.Int("ok_count").Default(0),
|
||||||
|
field.Int("operational_count").Default(0),
|
||||||
|
field.Int("degraded_count").Default(0),
|
||||||
|
field.Int("failed_count").Default(0),
|
||||||
|
field.Int("error_count").Default(0),
|
||||||
|
field.Int64("sum_latency_ms").Default(0),
|
||||||
|
field.Int("count_latency").Default(0),
|
||||||
|
field.Int64("sum_ping_latency_ms").Default(0),
|
||||||
|
field.Int("count_ping_latency").Default(0),
|
||||||
|
field.Time("computed_at").Default(time.Now).UpdateDefault(time.Now),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ChannelMonitorDailyRollup) Edges() []ent.Edge {
|
||||||
|
return []ent.Edge{
|
||||||
|
edge.From("monitor", ChannelMonitor.Type).
|
||||||
|
Ref("daily_rollups").
|
||||||
|
Field("monitor_id").
|
||||||
|
Unique().
|
||||||
|
Required(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ChannelMonitorDailyRollup) Indexes() []ent.Index {
|
||||||
|
return []ent.Index{
|
||||||
|
index.Fields("monitor_id", "model", "bucket_date").Unique(),
|
||||||
|
index.Fields("bucket_date"),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,10 +9,13 @@ import (
|
|||||||
"entgo.io/ent/schema/edge"
|
"entgo.io/ent/schema/edge"
|
||||||
"entgo.io/ent/schema/field"
|
"entgo.io/ent/schema/field"
|
||||||
"entgo.io/ent/schema/index"
|
"entgo.io/ent/schema/index"
|
||||||
|
|
||||||
|
"github.com/Wei-Shaw/sub2api/ent/schema/mixins"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ChannelMonitorHistory holds the schema definition for the ChannelMonitorHistory entity.
|
// ChannelMonitorHistory holds the schema definition for the ChannelMonitorHistory entity.
|
||||||
// 渠道监控历史:每次检测每个模型一行记录,由调度器写入,定期清理 30 天前的旧数据。
|
// 渠道监控历史:每次检测每个模型一行记录。明细只保留 1 天,超过 1 天的数据被聚合到
|
||||||
|
// channel_monitor_daily_rollups 后软删(deleted_at),由后续懒清理任务物理移除。
|
||||||
type ChannelMonitorHistory struct {
|
type ChannelMonitorHistory struct {
|
||||||
ent.Schema
|
ent.Schema
|
||||||
}
|
}
|
||||||
@@ -23,6 +26,12 @@ func (ChannelMonitorHistory) Annotations() []schema.Annotation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ChannelMonitorHistory) Mixin() []ent.Mixin {
|
||||||
|
return []ent.Mixin{
|
||||||
|
mixins.SoftDeleteMixin{},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (ChannelMonitorHistory) Fields() []ent.Field {
|
func (ChannelMonitorHistory) Fields() []ent.Field {
|
||||||
return []ent.Field{
|
return []ent.Field{
|
||||||
field.Int64("monitor_id"),
|
field.Int64("monitor_id"),
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ type Tx struct {
|
|||||||
AuthIdentityChannel *AuthIdentityChannelClient
|
AuthIdentityChannel *AuthIdentityChannelClient
|
||||||
// ChannelMonitor is the client for interacting with the ChannelMonitor builders.
|
// ChannelMonitor is the client for interacting with the ChannelMonitor builders.
|
||||||
ChannelMonitor *ChannelMonitorClient
|
ChannelMonitor *ChannelMonitorClient
|
||||||
|
// ChannelMonitorDailyRollup is the client for interacting with the ChannelMonitorDailyRollup builders.
|
||||||
|
ChannelMonitorDailyRollup *ChannelMonitorDailyRollupClient
|
||||||
// ChannelMonitorHistory is the client for interacting with the ChannelMonitorHistory builders.
|
// ChannelMonitorHistory is the client for interacting with the ChannelMonitorHistory builders.
|
||||||
ChannelMonitorHistory *ChannelMonitorHistoryClient
|
ChannelMonitorHistory *ChannelMonitorHistoryClient
|
||||||
// ErrorPassthroughRule is the client for interacting with the ErrorPassthroughRule builders.
|
// ErrorPassthroughRule is the client for interacting with the ErrorPassthroughRule builders.
|
||||||
@@ -217,6 +219,7 @@ func (tx *Tx) init() {
|
|||||||
tx.AuthIdentity = NewAuthIdentityClient(tx.config)
|
tx.AuthIdentity = NewAuthIdentityClient(tx.config)
|
||||||
tx.AuthIdentityChannel = NewAuthIdentityChannelClient(tx.config)
|
tx.AuthIdentityChannel = NewAuthIdentityChannelClient(tx.config)
|
||||||
tx.ChannelMonitor = NewChannelMonitorClient(tx.config)
|
tx.ChannelMonitor = NewChannelMonitorClient(tx.config)
|
||||||
|
tx.ChannelMonitorDailyRollup = NewChannelMonitorDailyRollupClient(tx.config)
|
||||||
tx.ChannelMonitorHistory = NewChannelMonitorHistoryClient(tx.config)
|
tx.ChannelMonitorHistory = NewChannelMonitorHistoryClient(tx.config)
|
||||||
tx.ErrorPassthroughRule = NewErrorPassthroughRuleClient(tx.config)
|
tx.ErrorPassthroughRule = NewErrorPassthroughRuleClient(tx.config)
|
||||||
tx.Group = NewGroupClient(tx.config)
|
tx.Group = NewGroupClient(tx.config)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
|
|
||||||
dbent "github.com/Wei-Shaw/sub2api/ent"
|
dbent "github.com/Wei-Shaw/sub2api/ent"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/channelmonitor"
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitor"
|
||||||
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitordailyrollup"
|
||||||
"github.com/Wei-Shaw/sub2api/ent/channelmonitorhistory"
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitorhistory"
|
||||||
"github.com/Wei-Shaw/sub2api/internal/service"
|
"github.com/Wei-Shaw/sub2api/internal/service"
|
||||||
"github.com/lib/pq"
|
"github.com/lib/pq"
|
||||||
@@ -246,6 +247,7 @@ func (r *channelMonitorRepository) ListLatestPerModel(ctx context.Context, monit
|
|||||||
model, status, latency_ms, ping_latency_ms, checked_at
|
model, status, latency_ms, ping_latency_ms, checked_at
|
||||||
FROM channel_monitor_histories
|
FROM channel_monitor_histories
|
||||||
WHERE monitor_id = $1
|
WHERE monitor_id = $1
|
||||||
|
AND deleted_at IS NULL
|
||||||
ORDER BY model, checked_at DESC
|
ORDER BY model, checked_at DESC
|
||||||
`
|
`
|
||||||
rows, err := r.db.QueryContext(ctx, q, monitorID)
|
rows, err := r.db.QueryContext(ctx, q, monitorID)
|
||||||
@@ -280,23 +282,48 @@ func assignNullInt(dst **int, n sql.NullInt64) {
|
|||||||
|
|
||||||
// ComputeAvailability 计算指定窗口内每个模型的可用率与平均延迟。
|
// ComputeAvailability 计算指定窗口内每个模型的可用率与平均延迟。
|
||||||
// "可用" = status IN (operational, degraded)。
|
// "可用" = status IN (operational, degraded)。
|
||||||
|
//
|
||||||
|
// 数据来源:明细表只保留 1 天;窗口前其余天数走聚合表。
|
||||||
|
// - raw = 今天(CURRENT_DATE 起)的未软删明细,按 model 累加
|
||||||
|
// - rollup = [CURRENT_DATE - windowDays, CURRENT_DATE) 区间的聚合行
|
||||||
|
//
|
||||||
|
// 总窗口为 "今天 + 过去 windowDays 天",比 windowDays 字面值大 1 天,但因为聚合
|
||||||
|
// 是按整 UTC 日切的,这是聚合化无法避免的精度损失,且偏宽不偏窄(数据更全)。
|
||||||
func (r *channelMonitorRepository) ComputeAvailability(ctx context.Context, monitorID int64, windowDays int) ([]*service.ChannelMonitorAvailability, error) {
|
func (r *channelMonitorRepository) ComputeAvailability(ctx context.Context, monitorID int64, windowDays int) ([]*service.ChannelMonitorAvailability, error) {
|
||||||
if windowDays <= 0 {
|
if windowDays <= 0 {
|
||||||
windowDays = 7
|
windowDays = 7
|
||||||
}
|
}
|
||||||
const q = `
|
const q = `
|
||||||
SELECT
|
WITH raw AS (
|
||||||
model,
|
SELECT model,
|
||||||
COUNT(*) AS total_checks,
|
COUNT(*) AS total_checks,
|
||||||
COUNT(*) FILTER (WHERE status IN ('operational','degraded')) AS ok_checks,
|
COUNT(*) FILTER (WHERE status IN ('operational','degraded')) AS ok_count,
|
||||||
AVG(latency_ms) FILTER (WHERE latency_ms IS NOT NULL) AS avg_latency_ms
|
COALESCE(SUM(latency_ms) FILTER (WHERE latency_ms IS NOT NULL), 0) AS sum_latency_ms,
|
||||||
FROM channel_monitor_histories
|
COUNT(latency_ms) AS count_latency
|
||||||
WHERE monitor_id = $1
|
FROM channel_monitor_histories
|
||||||
AND checked_at >= $2
|
WHERE monitor_id = $1
|
||||||
|
AND deleted_at IS NULL
|
||||||
|
AND checked_at >= CURRENT_DATE
|
||||||
|
GROUP BY model
|
||||||
|
),
|
||||||
|
rollup AS (
|
||||||
|
SELECT model, total_checks, ok_count, sum_latency_ms, count_latency
|
||||||
|
FROM channel_monitor_daily_rollups
|
||||||
|
WHERE monitor_id = $1
|
||||||
|
AND deleted_at IS NULL
|
||||||
|
AND bucket_date >= (CURRENT_DATE - $2::int)
|
||||||
|
AND bucket_date < CURRENT_DATE
|
||||||
|
)
|
||||||
|
SELECT model,
|
||||||
|
SUM(total_checks) AS total,
|
||||||
|
SUM(ok_count) AS ok,
|
||||||
|
CASE WHEN SUM(count_latency) > 0
|
||||||
|
THEN SUM(sum_latency_ms)::float8 / SUM(count_latency)
|
||||||
|
ELSE NULL END AS avg_latency_ms
|
||||||
|
FROM (SELECT * FROM raw UNION ALL SELECT * FROM rollup) combined
|
||||||
GROUP BY model
|
GROUP BY model
|
||||||
`
|
`
|
||||||
from := time.Now().AddDate(0, 0, -windowDays)
|
rows, err := r.db.QueryContext(ctx, q, monitorID, windowDays)
|
||||||
rows, err := r.db.QueryContext(ctx, q, monitorID, from)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("query availability: %w", err)
|
return nil, fmt.Errorf("query availability: %w", err)
|
||||||
}
|
}
|
||||||
@@ -349,6 +376,7 @@ func (r *channelMonitorRepository) ListLatestForMonitorIDs(ctx context.Context,
|
|||||||
monitor_id, model, status, latency_ms, ping_latency_ms, checked_at
|
monitor_id, model, status, latency_ms, ping_latency_ms, checked_at
|
||||||
FROM channel_monitor_histories
|
FROM channel_monitor_histories
|
||||||
WHERE monitor_id = ANY($1)
|
WHERE monitor_id = ANY($1)
|
||||||
|
AND deleted_at IS NULL
|
||||||
ORDER BY monitor_id, model, checked_at DESC
|
ORDER BY monitor_id, model, checked_at DESC
|
||||||
`
|
`
|
||||||
rows, err := r.db.QueryContext(ctx, q, pq.Array(ids))
|
rows, err := r.db.QueryContext(ctx, q, pq.Array(ids))
|
||||||
@@ -409,6 +437,7 @@ func (r *channelMonitorRepository) ListRecentHistoryForMonitors(
|
|||||||
FROM channel_monitor_histories h
|
FROM channel_monitor_histories h
|
||||||
JOIN targets t
|
JOIN targets t
|
||||||
ON t.monitor_id = h.monitor_id AND t.model = h.model
|
ON t.monitor_id = h.monitor_id AND t.model = h.model
|
||||||
|
WHERE h.deleted_at IS NULL
|
||||||
)
|
)
|
||||||
SELECT monitor_id, status, latency_ms, ping_latency_ms, checked_at
|
SELECT monitor_id, status, latency_ms, ping_latency_ms, checked_at
|
||||||
FROM ranked
|
FROM ranked
|
||||||
@@ -476,6 +505,7 @@ func clampTimelineLimit(n int) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ComputeAvailabilityForMonitors 一次性计算多个监控在某个窗口内的每模型可用率与平均延迟。
|
// ComputeAvailabilityForMonitors 一次性计算多个监控在某个窗口内的每模型可用率与平均延迟。
|
||||||
|
// 与单 monitor 版本同构:明细只覆盖今天,更早走聚合表 UNION 合并。
|
||||||
func (r *channelMonitorRepository) ComputeAvailabilityForMonitors(ctx context.Context, ids []int64, windowDays int) (map[int64][]*service.ChannelMonitorAvailability, error) {
|
func (r *channelMonitorRepository) ComputeAvailabilityForMonitors(ctx context.Context, ids []int64, windowDays int) (map[int64][]*service.ChannelMonitorAvailability, error) {
|
||||||
out := make(map[int64][]*service.ChannelMonitorAvailability, len(ids))
|
out := make(map[int64][]*service.ChannelMonitorAvailability, len(ids))
|
||||||
if len(ids) == 0 {
|
if len(ids) == 0 {
|
||||||
@@ -485,19 +515,38 @@ func (r *channelMonitorRepository) ComputeAvailabilityForMonitors(ctx context.Co
|
|||||||
windowDays = 7
|
windowDays = 7
|
||||||
}
|
}
|
||||||
const q = `
|
const q = `
|
||||||
SELECT
|
WITH raw AS (
|
||||||
monitor_id,
|
SELECT monitor_id,
|
||||||
model,
|
model,
|
||||||
COUNT(*) AS total_checks,
|
COUNT(*) AS total_checks,
|
||||||
COUNT(*) FILTER (WHERE status IN ('operational','degraded')) AS ok_checks,
|
COUNT(*) FILTER (WHERE status IN ('operational','degraded')) AS ok_count,
|
||||||
AVG(latency_ms) FILTER (WHERE latency_ms IS NOT NULL) AS avg_latency_ms
|
COALESCE(SUM(latency_ms) FILTER (WHERE latency_ms IS NOT NULL), 0) AS sum_latency_ms,
|
||||||
FROM channel_monitor_histories
|
COUNT(latency_ms) AS count_latency
|
||||||
WHERE monitor_id = ANY($1)
|
FROM channel_monitor_histories
|
||||||
AND checked_at >= $2
|
WHERE monitor_id = ANY($1)
|
||||||
|
AND deleted_at IS NULL
|
||||||
|
AND checked_at >= CURRENT_DATE
|
||||||
|
GROUP BY monitor_id, model
|
||||||
|
),
|
||||||
|
rollup AS (
|
||||||
|
SELECT monitor_id, model, total_checks, ok_count, sum_latency_ms, count_latency
|
||||||
|
FROM channel_monitor_daily_rollups
|
||||||
|
WHERE monitor_id = ANY($1)
|
||||||
|
AND deleted_at IS NULL
|
||||||
|
AND bucket_date >= (CURRENT_DATE - $2::int)
|
||||||
|
AND bucket_date < CURRENT_DATE
|
||||||
|
)
|
||||||
|
SELECT monitor_id,
|
||||||
|
model,
|
||||||
|
SUM(total_checks) AS total,
|
||||||
|
SUM(ok_count) AS ok,
|
||||||
|
CASE WHEN SUM(count_latency) > 0
|
||||||
|
THEN SUM(sum_latency_ms)::float8 / SUM(count_latency)
|
||||||
|
ELSE NULL END AS avg_latency_ms
|
||||||
|
FROM (SELECT * FROM raw UNION ALL SELECT * FROM rollup) combined
|
||||||
GROUP BY monitor_id, model
|
GROUP BY monitor_id, model
|
||||||
`
|
`
|
||||||
from := time.Now().AddDate(0, 0, -windowDays)
|
rows, err := r.db.QueryContext(ctx, q, pq.Array(ids), windowDays)
|
||||||
rows, err := r.db.QueryContext(ctx, q, pq.Array(ids), from)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("query availability batch: %w", err)
|
return nil, fmt.Errorf("query availability batch: %w", err)
|
||||||
}
|
}
|
||||||
@@ -521,6 +570,116 @@ func (r *channelMonitorRepository) ComputeAvailabilityForMonitors(ctx context.Co
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------- 聚合维护 ----------
|
||||||
|
|
||||||
|
// UpsertDailyRollupsFor 把 targetDate 当天([targetDate, targetDate+1d))未软删的明细
|
||||||
|
// 按 (monitor_id, model, bucket_date) 聚合写入 channel_monitor_daily_rollups。
|
||||||
|
// - 用 ON CONFLICT (monitor_id, model, bucket_date) DO UPDATE 实现幂等回填,
|
||||||
|
// 重复执行只会用最新统计覆盖;
|
||||||
|
// - 同时把 deleted_at 重置为 NULL,避免历史误删后聚合行被持续过滤掉;
|
||||||
|
// - $1::date 让 PG 自动把入参 truncate 到 UTC 日期,调用方不需要预处理 targetDate。
|
||||||
|
func (r *channelMonitorRepository) UpsertDailyRollupsFor(ctx context.Context, targetDate time.Time) (int64, error) {
|
||||||
|
const q = `
|
||||||
|
INSERT INTO channel_monitor_daily_rollups (
|
||||||
|
monitor_id, model, bucket_date,
|
||||||
|
total_checks, ok_count,
|
||||||
|
operational_count, degraded_count, failed_count, error_count,
|
||||||
|
sum_latency_ms, count_latency,
|
||||||
|
sum_ping_latency_ms, count_ping_latency,
|
||||||
|
computed_at
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
monitor_id,
|
||||||
|
model,
|
||||||
|
$1::date AS bucket_date,
|
||||||
|
COUNT(*) AS total_checks,
|
||||||
|
COUNT(*) FILTER (WHERE status IN ('operational','degraded')) AS ok_count,
|
||||||
|
COUNT(*) FILTER (WHERE status = 'operational') AS operational_count,
|
||||||
|
COUNT(*) FILTER (WHERE status = 'degraded') AS degraded_count,
|
||||||
|
COUNT(*) FILTER (WHERE status = 'failed') AS failed_count,
|
||||||
|
COUNT(*) FILTER (WHERE status = 'error') AS error_count,
|
||||||
|
COALESCE(SUM(latency_ms) FILTER (WHERE latency_ms IS NOT NULL), 0) AS sum_latency_ms,
|
||||||
|
COUNT(latency_ms) AS count_latency,
|
||||||
|
COALESCE(SUM(ping_latency_ms) FILTER (WHERE ping_latency_ms IS NOT NULL), 0) AS sum_ping_latency_ms,
|
||||||
|
COUNT(ping_latency_ms) AS count_ping_latency,
|
||||||
|
NOW()
|
||||||
|
FROM channel_monitor_histories
|
||||||
|
WHERE deleted_at IS NULL
|
||||||
|
AND checked_at >= $1::date
|
||||||
|
AND checked_at < ($1::date + INTERVAL '1 day')
|
||||||
|
GROUP BY monitor_id, model
|
||||||
|
ON CONFLICT (monitor_id, model, bucket_date) DO UPDATE SET
|
||||||
|
total_checks = EXCLUDED.total_checks,
|
||||||
|
ok_count = EXCLUDED.ok_count,
|
||||||
|
operational_count = EXCLUDED.operational_count,
|
||||||
|
degraded_count = EXCLUDED.degraded_count,
|
||||||
|
failed_count = EXCLUDED.failed_count,
|
||||||
|
error_count = EXCLUDED.error_count,
|
||||||
|
sum_latency_ms = EXCLUDED.sum_latency_ms,
|
||||||
|
count_latency = EXCLUDED.count_latency,
|
||||||
|
sum_ping_latency_ms = EXCLUDED.sum_ping_latency_ms,
|
||||||
|
count_ping_latency = EXCLUDED.count_ping_latency,
|
||||||
|
computed_at = NOW(),
|
||||||
|
deleted_at = NULL
|
||||||
|
`
|
||||||
|
res, err := r.db.ExecContext(ctx, q, targetDate)
|
||||||
|
if err != nil {
|
||||||
|
return 0, fmt.Errorf("upsert daily rollups for %s: %w", targetDate.Format("2006-01-02"), err)
|
||||||
|
}
|
||||||
|
n, err := res.RowsAffected()
|
||||||
|
if err != nil {
|
||||||
|
return 0, fmt.Errorf("rows affected (upsert rollups): %w", err)
|
||||||
|
}
|
||||||
|
return n, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteRollupsBefore 软删 bucket_date < beforeDate 的聚合行。
|
||||||
|
// 走 ent client,利用 SoftDeleteMixin 把 DELETE 自动改写为 UPDATE deleted_at = NOW()。
|
||||||
|
func (r *channelMonitorRepository) DeleteRollupsBefore(ctx context.Context, beforeDate time.Time) (int64, error) {
|
||||||
|
client := clientFromContext(ctx, r.client)
|
||||||
|
n, err := client.ChannelMonitorDailyRollup.Delete().
|
||||||
|
Where(channelmonitordailyrollup.BucketDateLT(beforeDate)).
|
||||||
|
Exec(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return 0, fmt.Errorf("delete rollups before: %w", err)
|
||||||
|
}
|
||||||
|
return int64(n), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadAggregationWatermark 读 watermark 表(id=1)。
|
||||||
|
// watermark 表不是 ent schema(只有一行),直接走原生 SQL。
|
||||||
|
// - 行不存在或 last_aggregated_date IS NULL:返回 (nil, nil),由调用方决定首次回填策略
|
||||||
|
func (r *channelMonitorRepository) LoadAggregationWatermark(ctx context.Context) (*time.Time, error) {
|
||||||
|
const q = `SELECT last_aggregated_date FROM channel_monitor_aggregation_watermark WHERE id = 1`
|
||||||
|
var t sql.NullTime
|
||||||
|
if err := r.db.QueryRowContext(ctx, q).Scan(&t); err != nil {
|
||||||
|
if err == sql.ErrNoRows {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("load aggregation watermark: %w", err)
|
||||||
|
}
|
||||||
|
if !t.Valid {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return &t.Time, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateAggregationWatermark 更新 watermark(UPSERT 到 id=1)。
|
||||||
|
// $1::date 让 PG 把入参 truncate 到 UTC 日期,与 last_aggregated_date 列的 DATE 类型一致。
|
||||||
|
func (r *channelMonitorRepository) UpdateAggregationWatermark(ctx context.Context, date time.Time) error {
|
||||||
|
const q = `
|
||||||
|
INSERT INTO channel_monitor_aggregation_watermark (id, last_aggregated_date, updated_at)
|
||||||
|
VALUES (1, $1::date, NOW())
|
||||||
|
ON CONFLICT (id) DO UPDATE SET
|
||||||
|
last_aggregated_date = EXCLUDED.last_aggregated_date,
|
||||||
|
updated_at = NOW()
|
||||||
|
`
|
||||||
|
if _, err := r.db.ExecContext(ctx, q, date); err != nil {
|
||||||
|
return fmt.Errorf("update aggregation watermark: %w", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// ---------- helpers ----------
|
// ---------- helpers ----------
|
||||||
|
|
||||||
func entToServiceMonitor(row *dbent.ChannelMonitor) *service.ChannelMonitor {
|
func entToServiceMonitor(row *dbent.ChannelMonitor) *service.ChannelMonitor {
|
||||||
|
|||||||
@@ -15,8 +15,16 @@ const (
|
|||||||
monitorPingTimeout = 8 * time.Second
|
monitorPingTimeout = 8 * time.Second
|
||||||
// monitorDegradedThreshold 主请求成功但耗时超过该阈值视为 degraded。
|
// monitorDegradedThreshold 主请求成功但耗时超过该阈值视为 degraded。
|
||||||
monitorDegradedThreshold = 6 * time.Second
|
monitorDegradedThreshold = 6 * time.Second
|
||||||
// monitorHistoryRetentionDays 历史保留天数(每天清理一次)。
|
// monitorHistoryRetentionDays 明细历史保留天数。
|
||||||
monitorHistoryRetentionDays = 30
|
// 明细只保留 1 天,超出由 SoftDeleteMixin 软删;
|
||||||
|
// 维护任务每天凌晨跑(由 OpsCleanupService 统一调度)。
|
||||||
|
monitorHistoryRetentionDays = 1
|
||||||
|
// monitorRollupRetentionDays 日聚合保留天数。
|
||||||
|
// 日聚合行由 RunDailyMaintenance 在超过该窗口后软删。
|
||||||
|
monitorRollupRetentionDays = 30
|
||||||
|
// monitorMaintenanceMaxDaysPerRun 单次维护任务最多聚合的天数。
|
||||||
|
// 用于限制首次上线回填(30 天)+ 少量余量,避免长事务。
|
||||||
|
monitorMaintenanceMaxDaysPerRun = 35
|
||||||
// monitorWorkerConcurrency 调度器并发执行的监控数(pond 池容量)。
|
// monitorWorkerConcurrency 调度器并发执行的监控数(pond 池容量)。
|
||||||
monitorWorkerConcurrency = 5
|
monitorWorkerConcurrency = 5
|
||||||
// monitorTickerInterval 调度器扫描"到期监控"的间隔。
|
// monitorTickerInterval 调度器扫描"到期监控"的间隔。
|
||||||
@@ -55,11 +63,6 @@ const (
|
|||||||
monitorAvailability15Days = 15
|
monitorAvailability15Days = 15
|
||||||
monitorAvailability30Days = 30
|
monitorAvailability30Days = 30
|
||||||
|
|
||||||
// monitorCleanupCheckInterval 历史清理调度器的检查频率(每小时检查"是否到 03:00")。
|
|
||||||
monitorCleanupCheckInterval = time.Hour
|
|
||||||
// monitorCleanupHour 凌晨 3 点执行历史清理。
|
|
||||||
monitorCleanupHour = 3
|
|
||||||
|
|
||||||
// MonitorHistoryDefaultLimit 历史查询默认返回条数(handler 层共享)。
|
// MonitorHistoryDefaultLimit 历史查询默认返回条数(handler 层共享)。
|
||||||
MonitorHistoryDefaultLimit = 100
|
MonitorHistoryDefaultLimit = 100
|
||||||
// MonitorHistoryMaxLimit 历史查询最大返回条数(handler 层共享)。
|
// MonitorHistoryMaxLimit 历史查询最大返回条数(handler 层共享)。
|
||||||
@@ -82,10 +85,6 @@ const (
|
|||||||
monitorListDueTimeout = 10 * time.Second
|
monitorListDueTimeout = 10 * time.Second
|
||||||
// monitorRunOneBuffer runOne 的总超时缓冲(除请求超时与 ping 超时外的额外裕量)。
|
// monitorRunOneBuffer runOne 的总超时缓冲(除请求超时与 ping 超时外的额外裕量)。
|
||||||
monitorRunOneBuffer = 10 * time.Second
|
monitorRunOneBuffer = 10 * time.Second
|
||||||
// monitorCleanupTimeout 历史清理任务的总超时。
|
|
||||||
monitorCleanupTimeout = 30 * time.Second
|
|
||||||
// monitorCleanupDayLayout 历史清理用于"今日是否已跑过"判定的日期格式。
|
|
||||||
monitorCleanupDayLayout = "2006-01-02"
|
|
||||||
|
|
||||||
// monitorIdleConnTimeout HTTP transport 空闲连接关闭超时。
|
// monitorIdleConnTimeout HTTP transport 空闲连接关闭超时。
|
||||||
monitorIdleConnTimeout = 30 * time.Second
|
monitorIdleConnTimeout = 30 * time.Second
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ import (
|
|||||||
// 职责:
|
// 职责:
|
||||||
// - 每 monitorTickerInterval 扫描一次"到期需要检测"的监控
|
// - 每 monitorTickerInterval 扫描一次"到期需要检测"的监控
|
||||||
// - 通过 pond 池(容量 monitorWorkerConcurrency)异步执行检测
|
// - 通过 pond 池(容量 monitorWorkerConcurrency)异步执行检测
|
||||||
// - 每小时检查一次时钟,到 monitorCleanupHour 点时执行历史清理
|
|
||||||
// - Stop 时优雅关闭:池 drain + ticker.Stop + wg.Wait
|
// - Stop 时优雅关闭:池 drain + ticker.Stop + wg.Wait
|
||||||
//
|
//
|
||||||
// 不引入 cron 库;清理调度通过"每小时检查时间"实现,足够 MVP。
|
// 历史清理与日聚合维护不再由 runner 负责,由 OpsCleanupService 的统一 cron
|
||||||
|
// 在凌晨触发 ChannelMonitorService.RunDailyMaintenance(复用 leader lock + heartbeat)。
|
||||||
//
|
//
|
||||||
// 定时任务维护:删除/创建/编辑 monitor 无需显式 reload,每个 tick 都会重新查 DB
|
// 定时任务维护:删除/创建/编辑 monitor 无需显式 reload,每个 tick 都会重新查 DB
|
||||||
// (ListEnabled + listDueForCheck),新 monitor 的 LastCheckedAt 为 nil 天然立即到期,
|
// (ListEnabled + listDueForCheck),新 monitor 的 LastCheckedAt 为 nil 天然立即到期,
|
||||||
@@ -35,10 +35,6 @@ type ChannelMonitorRunner struct {
|
|||||||
// 防止单次检测耗时 > interval 时同一 monitor 被并发执行。
|
// 防止单次检测耗时 > interval 时同一 monitor 被并发执行。
|
||||||
inFlight map[int64]struct{}
|
inFlight map[int64]struct{}
|
||||||
inFlightMu sync.Mutex
|
inFlightMu sync.Mutex
|
||||||
|
|
||||||
// 清理状态:lastCleanupDay 记录上次清理的"年-月-日",避免同一天重复跑。
|
|
||||||
lastCleanupDay string
|
|
||||||
cleanupMu sync.Mutex
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewChannelMonitorRunner 构造调度器。Start 在 wire 中调用。
|
// NewChannelMonitorRunner 构造调度器。Start 在 wire 中调用。
|
||||||
@@ -52,7 +48,7 @@ func NewChannelMonitorRunner(svc *ChannelMonitorService, settingService *Setting
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start 启动 ticker + worker pool + cleanup loop。
|
// Start 启动 ticker + worker pool。
|
||||||
// 调用方需保证只调一次(wire ProvideChannelMonitorRunner 内只调一次)。
|
// 调用方需保证只调一次(wire ProvideChannelMonitorRunner 内只调一次)。
|
||||||
func (r *ChannelMonitorRunner) Start() {
|
func (r *ChannelMonitorRunner) Start() {
|
||||||
if r == nil || r.svc == nil {
|
if r == nil || r.svc == nil {
|
||||||
@@ -61,12 +57,11 @@ func (r *ChannelMonitorRunner) Start() {
|
|||||||
// 容量 5 的 pond 池:超出时调用方等待,避免调度堆积无限增长。
|
// 容量 5 的 pond 池:超出时调用方等待,避免调度堆积无限增长。
|
||||||
r.pool = pond.NewPool(monitorWorkerConcurrency)
|
r.pool = pond.NewPool(monitorWorkerConcurrency)
|
||||||
|
|
||||||
r.wg.Add(2)
|
r.wg.Add(1)
|
||||||
go r.dueCheckLoop()
|
go r.dueCheckLoop()
|
||||||
go r.cleanupLoop()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop 优雅停止:close stopCh -> 等待两个 loop 退出 -> 池 drain。
|
// Stop 优雅停止:close stopCh -> 等待 loop 退出 -> 池 drain。
|
||||||
func (r *ChannelMonitorRunner) Stop() {
|
func (r *ChannelMonitorRunner) Stop() {
|
||||||
if r == nil {
|
if r == nil {
|
||||||
return
|
return
|
||||||
@@ -176,45 +171,3 @@ func (r *ChannelMonitorRunner) runOne(id int64, name string) {
|
|||||||
"monitor_id", id, "name", name, "error", err)
|
"monitor_id", id, "name", name, "error", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// cleanupLoop 每小时检查当前时间,到 monitorCleanupHour 点(且当天还没清理过)则跑一次清理。
|
|
||||||
// 启动时立即检查一次,避免长时间运行才跑首次清理。
|
|
||||||
func (r *ChannelMonitorRunner) cleanupLoop() {
|
|
||||||
defer r.wg.Done()
|
|
||||||
|
|
||||||
ticker := time.NewTicker(monitorCleanupCheckInterval)
|
|
||||||
defer ticker.Stop()
|
|
||||||
|
|
||||||
r.maybeRunCleanup()
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-r.stopCh:
|
|
||||||
return
|
|
||||||
case <-ticker.C:
|
|
||||||
r.maybeRunCleanup()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// maybeRunCleanup 如果当前小时是 monitorCleanupHour 且当天未跑过,则执行清理。
|
|
||||||
func (r *ChannelMonitorRunner) maybeRunCleanup() {
|
|
||||||
now := time.Now()
|
|
||||||
if now.Hour() != monitorCleanupHour {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
day := now.Format(monitorCleanupDayLayout)
|
|
||||||
|
|
||||||
r.cleanupMu.Lock()
|
|
||||||
if r.lastCleanupDay == day {
|
|
||||||
r.cleanupMu.Unlock()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
r.lastCleanupDay = day
|
|
||||||
r.cleanupMu.Unlock()
|
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), monitorCleanupTimeout)
|
|
||||||
defer cancel()
|
|
||||||
if err := r.svc.cleanupOldHistory(ctx); err != nil {
|
|
||||||
slog.Warn("channel_monitor: cleanup history failed", "error", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -41,6 +41,20 @@ type ChannelMonitorRepository interface {
|
|||||||
// ListRecentHistoryForMonitors 批量取多个 monitor 各自主模型(primaryModels[monitorID])最近 perMonitorLimit 条历史。
|
// ListRecentHistoryForMonitors 批量取多个 monitor 各自主模型(primaryModels[monitorID])最近 perMonitorLimit 条历史。
|
||||||
// 返回的 entry 已按 checked_at DESC 排序(最新在前),不含 message 字段。
|
// 返回的 entry 已按 checked_at DESC 排序(最新在前),不含 message 字段。
|
||||||
ListRecentHistoryForMonitors(ctx context.Context, ids []int64, primaryModels map[int64]string, perMonitorLimit int) (map[int64][]*ChannelMonitorHistoryEntry, error)
|
ListRecentHistoryForMonitors(ctx context.Context, ids []int64, primaryModels map[int64]string, perMonitorLimit int) (map[int64][]*ChannelMonitorHistoryEntry, error)
|
||||||
|
|
||||||
|
// ---------- 聚合维护(OpsCleanupService 调用) ----------
|
||||||
|
|
||||||
|
// UpsertDailyRollupsFor 把 targetDate 当天的明细按 (monitor_id, model, bucket_date)
|
||||||
|
// 聚合到 channel_monitor_daily_rollups。targetDate 会被截断到日期;
|
||||||
|
// 用 ON CONFLICT DO UPDATE 实现幂等回填,返回 upsert 影响的行数。
|
||||||
|
UpsertDailyRollupsFor(ctx context.Context, targetDate time.Time) (int64, error)
|
||||||
|
// DeleteRollupsBefore 软删 bucket_date < beforeDate 的聚合行,返回删除行数。
|
||||||
|
DeleteRollupsBefore(ctx context.Context, beforeDate time.Time) (int64, error)
|
||||||
|
// LoadAggregationWatermark 读 watermark(id=1)。
|
||||||
|
// 返回 nil 表示从未聚合过;watermark 表本身预期已存在单行(migration 110 写入)。
|
||||||
|
LoadAggregationWatermark(ctx context.Context) (*time.Time, error)
|
||||||
|
// UpdateAggregationWatermark 写 watermark(UPSERT 到 id=1)。
|
||||||
|
UpdateAggregationWatermark(ctx context.Context, date time.Time) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChannelMonitorService 渠道监控管理服务。
|
// ChannelMonitorService 渠道监控管理服务。
|
||||||
@@ -300,9 +314,10 @@ func (s *ChannelMonitorService) listDueForCheck(ctx context.Context) ([]*Channel
|
|||||||
return due, nil
|
return due, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// cleanupOldHistory 删除 monitorHistoryRetentionDays 天之前的历史记录。
|
// cleanupOldHistory 删除 monitorHistoryRetentionDays 天之前的明细历史记录。
|
||||||
|
// 由 RunDailyMaintenance 调用;SoftDeleteMixin 自动把 DELETE 改为 UPDATE deleted_at。
|
||||||
func (s *ChannelMonitorService) cleanupOldHistory(ctx context.Context) error {
|
func (s *ChannelMonitorService) cleanupOldHistory(ctx context.Context) error {
|
||||||
before := time.Now().AddDate(0, 0, -monitorHistoryRetentionDays)
|
before := time.Now().UTC().AddDate(0, 0, -monitorHistoryRetentionDays)
|
||||||
deleted, err := s.repo.DeleteHistoryBefore(ctx, before)
|
deleted, err := s.repo.DeleteHistoryBefore(ctx, before)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("delete history before %s: %w", before.Format(time.RFC3339), err)
|
return fmt.Errorf("delete history before %s: %w", before.Format(time.RFC3339), err)
|
||||||
@@ -314,6 +329,94 @@ func (s *ChannelMonitorService) cleanupOldHistory(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RunDailyMaintenance 每日维护任务:聚合昨天之前未聚合的明细,软删过期明细和聚合。
|
||||||
|
// 由 OpsCleanupService 的 cron 调度触发(共享 schedule 和 leader lock)。
|
||||||
|
//
|
||||||
|
// 幂等性:
|
||||||
|
// - watermark 保证已聚合的日期不会重复处理;
|
||||||
|
// - UpsertDailyRollupsFor 内部使用 ON CONFLICT DO UPDATE,同一日重复跑结果一致。
|
||||||
|
//
|
||||||
|
// 每一步失败都只记 slog.Warn,整体函数始终返回 nil 让后续步骤能继续跑
|
||||||
|
// (与 OpsCleanupService.runCleanupOnce 风格一致)。
|
||||||
|
func (s *ChannelMonitorService) RunDailyMaintenance(ctx context.Context) error {
|
||||||
|
now := time.Now().UTC()
|
||||||
|
today := now.Truncate(24 * time.Hour)
|
||||||
|
|
||||||
|
if err := s.runDailyAggregation(ctx, today); err != nil {
|
||||||
|
slog.Warn("channel_monitor: maintenance step failed",
|
||||||
|
"step", "aggregate", "error", err)
|
||||||
|
}
|
||||||
|
if err := s.cleanupOldHistory(ctx); err != nil {
|
||||||
|
slog.Warn("channel_monitor: maintenance step failed",
|
||||||
|
"step", "prune_history", "error", err)
|
||||||
|
}
|
||||||
|
if err := s.cleanupOldRollups(ctx, today); err != nil {
|
||||||
|
slog.Warn("channel_monitor: maintenance step failed",
|
||||||
|
"step", "prune_rollups", "error", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// runDailyAggregation 从 watermark+1 聚合到昨天(UTC)。
|
||||||
|
// 首次跑(watermark nil):从 today-monitorRollupRetentionDays 开始回填。
|
||||||
|
// 每次最多聚合 monitorMaintenanceMaxDaysPerRun 天,避免长事务。
|
||||||
|
func (s *ChannelMonitorService) runDailyAggregation(ctx context.Context, today time.Time) error {
|
||||||
|
watermark, err := s.repo.LoadAggregationWatermark(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("load watermark: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
start := s.resolveAggregationStart(watermark, today)
|
||||||
|
if !start.Before(today) {
|
||||||
|
return nil // 没有需要聚合的日期
|
||||||
|
}
|
||||||
|
|
||||||
|
iterations := 0
|
||||||
|
for d := start; d.Before(today); d = d.Add(24 * time.Hour) {
|
||||||
|
if iterations >= monitorMaintenanceMaxDaysPerRun {
|
||||||
|
slog.Info("channel_monitor: maintenance aggregation capped",
|
||||||
|
"max_days", monitorMaintenanceMaxDaysPerRun,
|
||||||
|
"next_resume", d.Format("2006-01-02"))
|
||||||
|
break
|
||||||
|
}
|
||||||
|
affected, upErr := s.repo.UpsertDailyRollupsFor(ctx, d)
|
||||||
|
if upErr != nil {
|
||||||
|
return fmt.Errorf("upsert rollups for %s: %w", d.Format("2006-01-02"), upErr)
|
||||||
|
}
|
||||||
|
if err := s.repo.UpdateAggregationWatermark(ctx, d); err != nil {
|
||||||
|
return fmt.Errorf("update watermark to %s: %w", d.Format("2006-01-02"), err)
|
||||||
|
}
|
||||||
|
slog.Info("channel_monitor: rollups upserted",
|
||||||
|
"date", d.Format("2006-01-02"), "affected_rows", affected)
|
||||||
|
iterations++
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// resolveAggregationStart 计算本次聚合起点:
|
||||||
|
// - watermark == nil:today - monitorRollupRetentionDays(首次回填最多 30 天)
|
||||||
|
// - watermark != nil:*watermark + 1 day
|
||||||
|
func (s *ChannelMonitorService) resolveAggregationStart(watermark *time.Time, today time.Time) time.Time {
|
||||||
|
if watermark == nil {
|
||||||
|
return today.AddDate(0, 0, -monitorRollupRetentionDays)
|
||||||
|
}
|
||||||
|
return watermark.UTC().Truncate(24 * time.Hour).Add(24 * time.Hour)
|
||||||
|
}
|
||||||
|
|
||||||
|
// cleanupOldRollups 软删 bucket_date < today - monitorRollupRetentionDays 的日聚合行。
|
||||||
|
func (s *ChannelMonitorService) cleanupOldRollups(ctx context.Context, today time.Time) error {
|
||||||
|
cutoff := today.AddDate(0, 0, -monitorRollupRetentionDays)
|
||||||
|
deleted, err := s.repo.DeleteRollupsBefore(ctx, cutoff)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("delete rollups before %s: %w", cutoff.Format("2006-01-02"), err)
|
||||||
|
}
|
||||||
|
if deleted > 0 {
|
||||||
|
slog.Info("channel_monitor: rollups cleanup",
|
||||||
|
"deleted_rows", deleted, "before", cutoff.Format("2006-01-02"))
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// ---------- helpers ----------
|
// ---------- helpers ----------
|
||||||
|
|
||||||
// decryptInPlace 把 ChannelMonitor.APIKey 从密文解密为明文。
|
// decryptInPlace 把 ChannelMonitor.APIKey 从密文解密为明文。
|
||||||
|
|||||||
@@ -36,11 +36,15 @@ return 0
|
|||||||
// - Scheduling: 5-field cron spec (minute hour dom month dow).
|
// - Scheduling: 5-field cron spec (minute hour dom month dow).
|
||||||
// - Multi-instance: best-effort Redis leader lock so only one node runs cleanup.
|
// - Multi-instance: best-effort Redis leader lock so only one node runs cleanup.
|
||||||
// - Safety: deletes in batches to avoid long transactions.
|
// - Safety: deletes in batches to avoid long transactions.
|
||||||
|
//
|
||||||
|
// 附带:在 runCleanupOnce 末尾调用 ChannelMonitorService.RunDailyMaintenance,
|
||||||
|
// 统一共享 cron schedule + leader lock + heartbeat,避免再引一套调度。
|
||||||
type OpsCleanupService struct {
|
type OpsCleanupService struct {
|
||||||
opsRepo OpsRepository
|
opsRepo OpsRepository
|
||||||
db *sql.DB
|
db *sql.DB
|
||||||
redisClient *redis.Client
|
redisClient *redis.Client
|
||||||
cfg *config.Config
|
cfg *config.Config
|
||||||
|
channelMonitorSvc *ChannelMonitorService
|
||||||
|
|
||||||
instanceID string
|
instanceID string
|
||||||
|
|
||||||
@@ -57,13 +61,15 @@ func NewOpsCleanupService(
|
|||||||
db *sql.DB,
|
db *sql.DB,
|
||||||
redisClient *redis.Client,
|
redisClient *redis.Client,
|
||||||
cfg *config.Config,
|
cfg *config.Config,
|
||||||
|
channelMonitorSvc *ChannelMonitorService,
|
||||||
) *OpsCleanupService {
|
) *OpsCleanupService {
|
||||||
return &OpsCleanupService{
|
return &OpsCleanupService{
|
||||||
opsRepo: opsRepo,
|
opsRepo: opsRepo,
|
||||||
db: db,
|
db: db,
|
||||||
redisClient: redisClient,
|
redisClient: redisClient,
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
instanceID: uuid.NewString(),
|
channelMonitorSvc: channelMonitorSvc,
|
||||||
|
instanceID: uuid.NewString(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,6 +254,15 @@ func (s *OpsCleanupService) runCleanupOnce(ctx context.Context) (opsCleanupDelet
|
|||||||
out.dailyPreagg = n
|
out.dailyPreagg = n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Channel monitor 每日维护(聚合昨日明细 + 软删过期明细/聚合)。
|
||||||
|
// 失败只记日志,不影响 ops 清理的成功状态(与 ops 各步骤风格一致);
|
||||||
|
// 维护本身已经把每步错误打到 slog,heartbeat result 不再分项记录。
|
||||||
|
if s.channelMonitorSvc != nil {
|
||||||
|
if err := s.channelMonitorSvc.RunDailyMaintenance(ctx); err != nil {
|
||||||
|
logger.LegacyPrintf("service.ops_cleanup", "[OpsCleanup] channel monitor maintenance failed: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -262,13 +262,16 @@ func ProvideOpsAlertEvaluatorService(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ProvideOpsCleanupService creates and starts OpsCleanupService (cron scheduled).
|
// ProvideOpsCleanupService creates and starts OpsCleanupService (cron scheduled).
|
||||||
|
// channelMonitorSvc 让维护任务(聚合 + 历史/聚合软删)跟随 ops 清理 cron 一起跑,
|
||||||
|
// 共享 leader lock + heartbeat。
|
||||||
func ProvideOpsCleanupService(
|
func ProvideOpsCleanupService(
|
||||||
opsRepo OpsRepository,
|
opsRepo OpsRepository,
|
||||||
db *sql.DB,
|
db *sql.DB,
|
||||||
redisClient *redis.Client,
|
redisClient *redis.Client,
|
||||||
cfg *config.Config,
|
cfg *config.Config,
|
||||||
|
channelMonitorSvc *ChannelMonitorService,
|
||||||
) *OpsCleanupService {
|
) *OpsCleanupService {
|
||||||
svc := NewOpsCleanupService(opsRepo, db, redisClient, cfg)
|
svc := NewOpsCleanupService(opsRepo, db, redisClient, cfg, channelMonitorSvc)
|
||||||
svc.Start()
|
svc.Start()
|
||||||
return svc
|
return svc
|
||||||
}
|
}
|
||||||
|
|||||||
60
backend/migrations/126_add_channel_monitor_aggregation.sql
Normal file
60
backend/migrations/126_add_channel_monitor_aggregation.sql
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
-- Migration: 126_add_channel_monitor_aggregation
|
||||||
|
-- 渠道监控日聚合:把 channel_monitor_histories 的明细按天聚合,明细只保留 1 天,
|
||||||
|
-- 聚合保留 30 天。明细和聚合表都用软删除(deleted_at),由 ops cleanup 任务每天
|
||||||
|
-- 凌晨随运维监控清理一起跑(共享 cron)。
|
||||||
|
--
|
||||||
|
-- 设计要点:
|
||||||
|
-- - channel_monitor_histories 加 deleted_at 软删除字段(SoftDeleteMixin 全局
|
||||||
|
-- Hook 会把 DELETE 自动改写成 UPDATE deleted_at = NOW())。
|
||||||
|
-- - channel_monitor_daily_rollups 按 (monitor_id, model, bucket_date) 唯一,
|
||||||
|
-- 用 ON CONFLICT DO UPDATE 实现幂等回填,状态分布和延迟分子分母都保留,
|
||||||
|
-- 方便后续按窗口任意求加权可用率和均值。
|
||||||
|
-- - watermark 表只有一行(id=1),记录最近一次聚合到达的日期,避免重启后重复
|
||||||
|
-- 扫全表。
|
||||||
|
-- - rollup 上 (bucket_date) 索引服务清理任务的 DELETE WHERE bucket_date < cutoff。
|
||||||
|
|
||||||
|
-- 1) 给历史明细表加软删除字段
|
||||||
|
ALTER TABLE channel_monitor_histories
|
||||||
|
ADD COLUMN IF NOT EXISTS deleted_at TIMESTAMPTZ;
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_channel_monitor_histories_deleted_at
|
||||||
|
ON channel_monitor_histories (deleted_at);
|
||||||
|
|
||||||
|
-- 2) 创建日聚合表
|
||||||
|
CREATE TABLE IF NOT EXISTS channel_monitor_daily_rollups (
|
||||||
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
monitor_id BIGINT NOT NULL REFERENCES channel_monitors(id) ON DELETE CASCADE,
|
||||||
|
model VARCHAR(200) NOT NULL,
|
||||||
|
bucket_date DATE NOT NULL,
|
||||||
|
total_checks INT NOT NULL DEFAULT 0,
|
||||||
|
ok_count INT NOT NULL DEFAULT 0,
|
||||||
|
operational_count INT NOT NULL DEFAULT 0,
|
||||||
|
degraded_count INT NOT NULL DEFAULT 0,
|
||||||
|
failed_count INT NOT NULL DEFAULT 0,
|
||||||
|
error_count INT NOT NULL DEFAULT 0,
|
||||||
|
sum_latency_ms BIGINT NOT NULL DEFAULT 0,
|
||||||
|
count_latency INT NOT NULL DEFAULT 0,
|
||||||
|
sum_ping_latency_ms BIGINT NOT NULL DEFAULT 0,
|
||||||
|
count_ping_latency INT NOT NULL DEFAULT 0,
|
||||||
|
computed_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||||
|
deleted_at TIMESTAMPTZ
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_channel_monitor_daily_rollups_unique
|
||||||
|
ON channel_monitor_daily_rollups (monitor_id, model, bucket_date);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_channel_monitor_daily_rollups_bucket
|
||||||
|
ON channel_monitor_daily_rollups (bucket_date);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_channel_monitor_daily_rollups_deleted_at
|
||||||
|
ON channel_monitor_daily_rollups (deleted_at);
|
||||||
|
|
||||||
|
-- 3) 创建 watermark 表(单行:id=1)
|
||||||
|
CREATE TABLE IF NOT EXISTS channel_monitor_aggregation_watermark (
|
||||||
|
id INT PRIMARY KEY DEFAULT 1,
|
||||||
|
last_aggregated_date DATE,
|
||||||
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||||
|
CONSTRAINT channel_monitor_aggregation_watermark_singleton CHECK (id = 1)
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO channel_monitor_aggregation_watermark (id, last_aggregated_date, updated_at)
|
||||||
|
VALUES (1, NULL, NOW())
|
||||||
|
ON CONFLICT (id) DO NOTHING;
|
||||||
@@ -113,6 +113,7 @@
|
|||||||
:loading="myKeysLoading"
|
:loading="myKeysLoading"
|
||||||
:keys="myActiveKeys"
|
:keys="myActiveKeys"
|
||||||
:provider="form.provider"
|
:provider="form.provider"
|
||||||
|
:user-group-rates="userGroupRates"
|
||||||
@close="showKeyPicker = false"
|
@close="showKeyPicker = false"
|
||||||
@pick="pickMyKey"
|
@pick="pickMyKey"
|
||||||
/>
|
/>
|
||||||
@@ -125,6 +126,7 @@ import { useAppStore } from '@/stores/app'
|
|||||||
import { extractApiErrorMessage } from '@/utils/apiError'
|
import { extractApiErrorMessage } from '@/utils/apiError'
|
||||||
import { adminAPI } from '@/api/admin'
|
import { adminAPI } from '@/api/admin'
|
||||||
import { keysAPI } from '@/api/keys'
|
import { keysAPI } from '@/api/keys'
|
||||||
|
import { userGroupsAPI } from '@/api/groups'
|
||||||
import type {
|
import type {
|
||||||
ChannelMonitor,
|
ChannelMonitor,
|
||||||
CreateParams,
|
CreateParams,
|
||||||
@@ -175,6 +177,7 @@ const submitting = ref(false)
|
|||||||
const showKeyPicker = ref(false)
|
const showKeyPicker = ref(false)
|
||||||
const myKeysLoading = ref(false)
|
const myKeysLoading = ref(false)
|
||||||
const myActiveKeys = ref<ApiKey[]>([])
|
const myActiveKeys = ref<ApiKey[]>([])
|
||||||
|
const userGroupRates = ref<Record<number, number>>({})
|
||||||
|
|
||||||
interface MonitorForm {
|
interface MonitorForm {
|
||||||
name: string
|
name: string
|
||||||
@@ -263,7 +266,10 @@ async function openMyKeyPicker() {
|
|||||||
if (myActiveKeys.value.length > 0) return
|
if (myActiveKeys.value.length > 0) return
|
||||||
myKeysLoading.value = true
|
myKeysLoading.value = true
|
||||||
try {
|
try {
|
||||||
const res = await keysAPI.list(1, 100, { status: 'active' })
|
const [res, rates] = await Promise.all([
|
||||||
|
keysAPI.list(1, 100, { status: 'active' }),
|
||||||
|
userGroupsAPI.getUserGroupRates(),
|
||||||
|
])
|
||||||
const items = res.items || []
|
const items = res.items || []
|
||||||
const now = Date.now()
|
const now = Date.now()
|
||||||
myActiveKeys.value = items.filter(k => {
|
myActiveKeys.value = items.filter(k => {
|
||||||
@@ -271,6 +277,7 @@ async function openMyKeyPicker() {
|
|||||||
if (!k.expires_at) return true
|
if (!k.expires_at) return true
|
||||||
return new Date(k.expires_at).getTime() > now
|
return new Date(k.expires_at).getTime() > now
|
||||||
})
|
})
|
||||||
|
userGroupRates.value = rates
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
appStore.showError(extractApiErrorMessage(err, t('admin.channelMonitor.form.noActiveKey')))
|
appStore.showError(extractApiErrorMessage(err, t('admin.channelMonitor.form.noActiveKey')))
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -47,9 +47,14 @@
|
|||||||
<td class="px-3 py-2 font-medium text-gray-900 dark:text-white">{{ k.name }}</td>
|
<td class="px-3 py-2 font-medium text-gray-900 dark:text-white">{{ k.name }}</td>
|
||||||
<td class="px-3 py-2 font-mono text-xs text-gray-500 dark:text-gray-400">{{ maskApiKey(k.key) }}</td>
|
<td class="px-3 py-2 font-mono text-xs text-gray-500 dark:text-gray-400">{{ maskApiKey(k.key) }}</td>
|
||||||
<td class="px-3 py-2">
|
<td class="px-3 py-2">
|
||||||
<span v-if="k.group" class="inline-flex items-center rounded-md bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-dark-700 dark:text-gray-300">
|
<GroupBadge
|
||||||
{{ k.group.name }}
|
v-if="k.group"
|
||||||
</span>
|
:name="k.group.name"
|
||||||
|
:platform="k.group.platform"
|
||||||
|
:subscription-type="k.group.subscription_type"
|
||||||
|
:rate-multiplier="k.group.rate_multiplier"
|
||||||
|
:user-rate-multiplier="userGroupRates[k.group.id]"
|
||||||
|
/>
|
||||||
<span v-else class="text-xs text-gray-400">—</span>
|
<span v-else class="text-xs text-gray-400">—</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -73,14 +78,18 @@ import { useI18n } from 'vue-i18n'
|
|||||||
import type { ApiKey } from '@/types'
|
import type { ApiKey } from '@/types'
|
||||||
import type { Provider } from '@/api/admin/channelMonitor'
|
import type { Provider } from '@/api/admin/channelMonitor'
|
||||||
import BaseDialog from '@/components/common/BaseDialog.vue'
|
import BaseDialog from '@/components/common/BaseDialog.vue'
|
||||||
|
import GroupBadge from '@/components/common/GroupBadge.vue'
|
||||||
import { maskApiKey } from '@/utils/maskApiKey'
|
import { maskApiKey } from '@/utils/maskApiKey'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
show: boolean
|
show: boolean
|
||||||
loading: boolean
|
loading: boolean
|
||||||
keys: ApiKey[]
|
keys: ApiKey[]
|
||||||
provider: Provider
|
provider: Provider
|
||||||
}>()
|
userGroupRates?: Record<number, number>
|
||||||
|
}>(), {
|
||||||
|
userGroupRates: () => ({}),
|
||||||
|
})
|
||||||
|
|
||||||
defineEmits<{
|
defineEmits<{
|
||||||
(e: 'close'): void
|
(e: 'close'): void
|
||||||
|
|||||||
Reference in New Issue
Block a user