mirror of
https://gitee.com/wanwujie/sub2api
synced 2026-05-04 21:20:51 +08:00
fix(channel-monitor): drop soft delete, refactor feature flag to declarative form
### 后端修复:日志表不该用软删除 channel_monitor_histories / channel_monitor_daily_rollups 都是日志/聚合表, 没有恢复需求。110 里加的 SoftDeleteMixin 会让 DELETE 自动变成 UPDATE deleted_at, 导致行和索引只增不减,徒增磁盘占用和查询成本。 改回分批物理删(参考 OpsCleanupService.deleteOldRowsByID 模板): - ent schema 移除 SoftDeleteMixin,重新 go generate - repo 新增 deleteChannelMonitorBatched 辅助 + 两条 prune SQL 常量 (WITH batch AS SELECT id LIMIT 5000 → DELETE IN batch) - DeleteHistoryBefore / DeleteRollupsBefore 改调分批 raw SQL - 移除 ComputeAvailability / ComputeAvailabilityForMonitors / UpsertDailyRollupsFor / ListLatestPerModel / ListLatestForMonitorIDs / ListRecentHistoryForMonitors 等 raw SQL 中的 deleted_at IS NULL 过滤 - UpsertDailyRollupsFor 的 ON CONFLICT 去掉 deleted_at = NULL 重置 - migration 111 DROP COLUMN deleted_at + 对应索引(110 已部署但 maintenance 首跑在次日 02:00,此时尚无业务数据在依赖软删除) ### 前端重构:feature flag 声明式 + 复用 AppSidebar.vue 里 7 处 `...(flag ? [item] : [])` 样板代码删光,改为 NavItem 加 featureFlag?: () => boolean | undefined 字段,加一个 applyFeatureFlags 递归 过滤(含 children)。语义统一为 `!== false`(宽容策略,undefined 时默认显示, 避免 public settings 未加载完成时菜单闪烁消失 — 对应用户反馈"刷新后菜单消失 要去保存设置才回来")。 - 集中声明 4 个 flag getter:flagChannelMonitor / flagPayment / flagOpsMonitoring / flagAdminPayment - 提取 buildSelfNavItems 复用用户端主菜单和管理员"我的账户"子菜单 - 未来新增开关:在统一位置加一个 flag getter + 给对应 NavItem 加字段 (不用再动渲染逻辑) bump 0.1.114.29
This commit is contained in:
@@ -18,8 +18,6 @@ type ChannelMonitorDailyRollup 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.
|
||||||
@@ -83,7 +81,7 @@ func (*ChannelMonitorDailyRollup) scanValues(columns []string) ([]any, error) {
|
|||||||
values[i] = new(sql.NullInt64)
|
values[i] = new(sql.NullInt64)
|
||||||
case channelmonitordailyrollup.FieldModel:
|
case channelmonitordailyrollup.FieldModel:
|
||||||
values[i] = new(sql.NullString)
|
values[i] = new(sql.NullString)
|
||||||
case channelmonitordailyrollup.FieldDeletedAt, channelmonitordailyrollup.FieldBucketDate, channelmonitordailyrollup.FieldComputedAt:
|
case channelmonitordailyrollup.FieldBucketDate, channelmonitordailyrollup.FieldComputedAt:
|
||||||
values[i] = new(sql.NullTime)
|
values[i] = new(sql.NullTime)
|
||||||
default:
|
default:
|
||||||
values[i] = new(sql.UnknownType)
|
values[i] = new(sql.UnknownType)
|
||||||
@@ -106,13 +104,6 @@ func (_m *ChannelMonitorDailyRollup) assignValues(columns []string, values []any
|
|||||||
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 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:
|
case channelmonitordailyrollup.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])
|
||||||
@@ -238,11 +229,6 @@ func (_m *ChannelMonitorDailyRollup) String() string {
|
|||||||
var builder strings.Builder
|
var builder strings.Builder
|
||||||
builder.WriteString("ChannelMonitorDailyRollup(")
|
builder.WriteString("ChannelMonitorDailyRollup(")
|
||||||
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(", ")
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ package channelmonitordailyrollup
|
|||||||
import (
|
import (
|
||||||
"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,8 +14,6 @@ const (
|
|||||||
Label = "channel_monitor_daily_rollup"
|
Label = "channel_monitor_daily_rollup"
|
||||||
// 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.
|
||||||
@@ -61,7 +58,6 @@ const (
|
|||||||
// Columns holds all SQL columns for channelmonitordailyrollup fields.
|
// Columns holds all SQL columns for channelmonitordailyrollup fields.
|
||||||
var Columns = []string{
|
var Columns = []string{
|
||||||
FieldID,
|
FieldID,
|
||||||
FieldDeletedAt,
|
|
||||||
FieldMonitorID,
|
FieldMonitorID,
|
||||||
FieldModel,
|
FieldModel,
|
||||||
FieldBucketDate,
|
FieldBucketDate,
|
||||||
@@ -88,14 +84,7 @@ 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
|
||||||
// DefaultTotalChecks holds the default value on creation for the "total_checks" field.
|
// DefaultTotalChecks holds the default value on creation for the "total_checks" field.
|
||||||
@@ -132,11 +121,6 @@ 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,11 +55,6 @@ func IDLTE(id int64) predicate.ChannelMonitorDailyRollup {
|
|||||||
return predicate.ChannelMonitorDailyRollup(sql.FieldLTE(FieldID, id))
|
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.
|
// MonitorID applies equality check predicate on the "monitor_id" field. It's identical to MonitorIDEQ.
|
||||||
func MonitorID(v int64) predicate.ChannelMonitorDailyRollup {
|
func MonitorID(v int64) predicate.ChannelMonitorDailyRollup {
|
||||||
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldMonitorID, v))
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldMonitorID, v))
|
||||||
@@ -130,56 +125,6 @@ func ComputedAt(v time.Time) predicate.ChannelMonitorDailyRollup {
|
|||||||
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldComputedAt, v))
|
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.
|
// MonitorIDEQ applies the EQ predicate on the "monitor_id" field.
|
||||||
func MonitorIDEQ(v int64) predicate.ChannelMonitorDailyRollup {
|
func MonitorIDEQ(v int64) predicate.ChannelMonitorDailyRollup {
|
||||||
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldMonitorID, v))
|
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldMonitorID, v))
|
||||||
|
|||||||
@@ -23,20 +23,6 @@ type ChannelMonitorDailyRollupCreate struct {
|
|||||||
conflict []sql.ConflictOption
|
conflict []sql.ConflictOption
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDeletedAt sets the "deleted_at" field.
|
|
||||||
func (_c *ChannelMonitorDailyRollupCreate) SetDeletedAt(v time.Time) *ChannelMonitorDailyRollupCreate {
|
|
||||||
_c.mutation.SetDeletedAt(v)
|
|
||||||
return _c
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
||||||
func (_c *ChannelMonitorDailyRollupCreate) SetNillableDeletedAt(v *time.Time) *ChannelMonitorDailyRollupCreate {
|
|
||||||
if v != nil {
|
|
||||||
_c.SetDeletedAt(*v)
|
|
||||||
}
|
|
||||||
return _c
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetMonitorID sets the "monitor_id" field.
|
// SetMonitorID sets the "monitor_id" field.
|
||||||
func (_c *ChannelMonitorDailyRollupCreate) SetMonitorID(v int64) *ChannelMonitorDailyRollupCreate {
|
func (_c *ChannelMonitorDailyRollupCreate) SetMonitorID(v int64) *ChannelMonitorDailyRollupCreate {
|
||||||
_c.mutation.SetMonitorID(v)
|
_c.mutation.SetMonitorID(v)
|
||||||
@@ -221,9 +207,7 @@ func (_c *ChannelMonitorDailyRollupCreate) Mutation() *ChannelMonitorDailyRollup
|
|||||||
|
|
||||||
// Save creates the ChannelMonitorDailyRollup in the database.
|
// Save creates the ChannelMonitorDailyRollup in the database.
|
||||||
func (_c *ChannelMonitorDailyRollupCreate) Save(ctx context.Context) (*ChannelMonitorDailyRollup, error) {
|
func (_c *ChannelMonitorDailyRollupCreate) Save(ctx context.Context) (*ChannelMonitorDailyRollup, error) {
|
||||||
if err := _c.defaults(); err != nil {
|
_c.defaults()
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,7 +234,7 @@ func (_c *ChannelMonitorDailyRollupCreate) 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 *ChannelMonitorDailyRollupCreate) defaults() error {
|
func (_c *ChannelMonitorDailyRollupCreate) defaults() {
|
||||||
if _, ok := _c.mutation.TotalChecks(); !ok {
|
if _, ok := _c.mutation.TotalChecks(); !ok {
|
||||||
v := channelmonitordailyrollup.DefaultTotalChecks
|
v := channelmonitordailyrollup.DefaultTotalChecks
|
||||||
_c.mutation.SetTotalChecks(v)
|
_c.mutation.SetTotalChecks(v)
|
||||||
@@ -292,13 +276,9 @@ func (_c *ChannelMonitorDailyRollupCreate) defaults() error {
|
|||||||
_c.mutation.SetCountPingLatency(v)
|
_c.mutation.SetCountPingLatency(v)
|
||||||
}
|
}
|
||||||
if _, ok := _c.mutation.ComputedAt(); !ok {
|
if _, ok := _c.mutation.ComputedAt(); !ok {
|
||||||
if channelmonitordailyrollup.DefaultComputedAt == nil {
|
|
||||||
return fmt.Errorf("ent: uninitialized channelmonitordailyrollup.DefaultComputedAt (forgotten import ent/runtime?)")
|
|
||||||
}
|
|
||||||
v := channelmonitordailyrollup.DefaultComputedAt()
|
v := channelmonitordailyrollup.DefaultComputedAt()
|
||||||
_c.mutation.SetComputedAt(v)
|
_c.mutation.SetComputedAt(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.
|
||||||
@@ -380,10 +360,6 @@ func (_c *ChannelMonitorDailyRollupCreate) createSpec() (*ChannelMonitorDailyRol
|
|||||||
_spec = sqlgraph.NewCreateSpec(channelmonitordailyrollup.Table, sqlgraph.NewFieldSpec(channelmonitordailyrollup.FieldID, field.TypeInt64))
|
_spec = sqlgraph.NewCreateSpec(channelmonitordailyrollup.Table, sqlgraph.NewFieldSpec(channelmonitordailyrollup.FieldID, field.TypeInt64))
|
||||||
)
|
)
|
||||||
_spec.OnConflict = _c.conflict
|
_spec.OnConflict = _c.conflict
|
||||||
if value, ok := _c.mutation.DeletedAt(); ok {
|
|
||||||
_spec.SetField(channelmonitordailyrollup.FieldDeletedAt, field.TypeTime, value)
|
|
||||||
_node.DeletedAt = &value
|
|
||||||
}
|
|
||||||
if value, ok := _c.mutation.Model(); ok {
|
if value, ok := _c.mutation.Model(); ok {
|
||||||
_spec.SetField(channelmonitordailyrollup.FieldModel, field.TypeString, value)
|
_spec.SetField(channelmonitordailyrollup.FieldModel, field.TypeString, value)
|
||||||
_node.Model = value
|
_node.Model = value
|
||||||
@@ -460,7 +436,7 @@ func (_c *ChannelMonitorDailyRollupCreate) createSpec() (*ChannelMonitorDailyRol
|
|||||||
// of the `INSERT` statement. For example:
|
// of the `INSERT` statement. For example:
|
||||||
//
|
//
|
||||||
// client.ChannelMonitorDailyRollup.Create().
|
// client.ChannelMonitorDailyRollup.Create().
|
||||||
// SetDeletedAt(v).
|
// SetMonitorID(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.
|
||||||
@@ -469,7 +445,7 @@ func (_c *ChannelMonitorDailyRollupCreate) createSpec() (*ChannelMonitorDailyRol
|
|||||||
// // Override some of the fields with custom
|
// // Override some of the fields with custom
|
||||||
// // update values.
|
// // update values.
|
||||||
// Update(func(u *ent.ChannelMonitorDailyRollupUpsert) {
|
// Update(func(u *ent.ChannelMonitorDailyRollupUpsert) {
|
||||||
// SetDeletedAt(v+v).
|
// SetMonitorID(v+v).
|
||||||
// }).
|
// }).
|
||||||
// Exec(ctx)
|
// Exec(ctx)
|
||||||
func (_c *ChannelMonitorDailyRollupCreate) OnConflict(opts ...sql.ConflictOption) *ChannelMonitorDailyRollupUpsertOne {
|
func (_c *ChannelMonitorDailyRollupCreate) OnConflict(opts ...sql.ConflictOption) *ChannelMonitorDailyRollupUpsertOne {
|
||||||
@@ -505,24 +481,6 @@ type (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// SetDeletedAt sets the "deleted_at" field.
|
|
||||||
func (u *ChannelMonitorDailyRollupUpsert) SetDeletedAt(v time.Time) *ChannelMonitorDailyRollupUpsert {
|
|
||||||
u.Set(channelmonitordailyrollup.FieldDeletedAt, v)
|
|
||||||
return u
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
||||||
func (u *ChannelMonitorDailyRollupUpsert) UpdateDeletedAt() *ChannelMonitorDailyRollupUpsert {
|
|
||||||
u.SetExcluded(channelmonitordailyrollup.FieldDeletedAt)
|
|
||||||
return u
|
|
||||||
}
|
|
||||||
|
|
||||||
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
||||||
func (u *ChannelMonitorDailyRollupUpsert) ClearDeletedAt() *ChannelMonitorDailyRollupUpsert {
|
|
||||||
u.SetNull(channelmonitordailyrollup.FieldDeletedAt)
|
|
||||||
return u
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetMonitorID sets the "monitor_id" field.
|
// SetMonitorID sets the "monitor_id" field.
|
||||||
func (u *ChannelMonitorDailyRollupUpsert) SetMonitorID(v int64) *ChannelMonitorDailyRollupUpsert {
|
func (u *ChannelMonitorDailyRollupUpsert) SetMonitorID(v int64) *ChannelMonitorDailyRollupUpsert {
|
||||||
u.Set(channelmonitordailyrollup.FieldMonitorID, v)
|
u.Set(channelmonitordailyrollup.FieldMonitorID, v)
|
||||||
@@ -791,27 +749,6 @@ func (u *ChannelMonitorDailyRollupUpsertOne) Update(set func(*ChannelMonitorDail
|
|||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDeletedAt sets the "deleted_at" field.
|
|
||||||
func (u *ChannelMonitorDailyRollupUpsertOne) SetDeletedAt(v time.Time) *ChannelMonitorDailyRollupUpsertOne {
|
|
||||||
return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
|
|
||||||
s.SetDeletedAt(v)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
||||||
func (u *ChannelMonitorDailyRollupUpsertOne) UpdateDeletedAt() *ChannelMonitorDailyRollupUpsertOne {
|
|
||||||
return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
|
|
||||||
s.UpdateDeletedAt()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
||||||
func (u *ChannelMonitorDailyRollupUpsertOne) ClearDeletedAt() *ChannelMonitorDailyRollupUpsertOne {
|
|
||||||
return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
|
|
||||||
s.ClearDeletedAt()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetMonitorID sets the "monitor_id" field.
|
// SetMonitorID sets the "monitor_id" field.
|
||||||
func (u *ChannelMonitorDailyRollupUpsertOne) SetMonitorID(v int64) *ChannelMonitorDailyRollupUpsertOne {
|
func (u *ChannelMonitorDailyRollupUpsertOne) SetMonitorID(v int64) *ChannelMonitorDailyRollupUpsertOne {
|
||||||
return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
|
return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
|
||||||
@@ -1213,7 +1150,7 @@ func (_c *ChannelMonitorDailyRollupCreateBulk) 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.ChannelMonitorDailyRollupUpsert) {
|
// Update(func(u *ent.ChannelMonitorDailyRollupUpsert) {
|
||||||
// SetDeletedAt(v+v).
|
// SetMonitorID(v+v).
|
||||||
// }).
|
// }).
|
||||||
// Exec(ctx)
|
// Exec(ctx)
|
||||||
func (_c *ChannelMonitorDailyRollupCreateBulk) OnConflict(opts ...sql.ConflictOption) *ChannelMonitorDailyRollupUpsertBulk {
|
func (_c *ChannelMonitorDailyRollupCreateBulk) OnConflict(opts ...sql.ConflictOption) *ChannelMonitorDailyRollupUpsertBulk {
|
||||||
@@ -1282,27 +1219,6 @@ func (u *ChannelMonitorDailyRollupUpsertBulk) Update(set func(*ChannelMonitorDai
|
|||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDeletedAt sets the "deleted_at" field.
|
|
||||||
func (u *ChannelMonitorDailyRollupUpsertBulk) SetDeletedAt(v time.Time) *ChannelMonitorDailyRollupUpsertBulk {
|
|
||||||
return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
|
|
||||||
s.SetDeletedAt(v)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
||||||
func (u *ChannelMonitorDailyRollupUpsertBulk) UpdateDeletedAt() *ChannelMonitorDailyRollupUpsertBulk {
|
|
||||||
return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
|
|
||||||
s.UpdateDeletedAt()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
||||||
func (u *ChannelMonitorDailyRollupUpsertBulk) ClearDeletedAt() *ChannelMonitorDailyRollupUpsertBulk {
|
|
||||||
return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
|
|
||||||
s.ClearDeletedAt()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetMonitorID sets the "monitor_id" field.
|
// SetMonitorID sets the "monitor_id" field.
|
||||||
func (u *ChannelMonitorDailyRollupUpsertBulk) SetMonitorID(v int64) *ChannelMonitorDailyRollupUpsertBulk {
|
func (u *ChannelMonitorDailyRollupUpsertBulk) SetMonitorID(v int64) *ChannelMonitorDailyRollupUpsertBulk {
|
||||||
return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
|
return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
|
||||||
|
|||||||
@@ -300,12 +300,12 @@ func (_q *ChannelMonitorDailyRollupQuery) WithMonitor(opts ...func(*ChannelMonit
|
|||||||
// Example:
|
// Example:
|
||||||
//
|
//
|
||||||
// var v []struct {
|
// var v []struct {
|
||||||
// DeletedAt time.Time `json:"deleted_at,omitempty"`
|
// MonitorID int64 `json:"monitor_id,omitempty"`
|
||||||
// Count int `json:"count,omitempty"`
|
// Count int `json:"count,omitempty"`
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// client.ChannelMonitorDailyRollup.Query().
|
// client.ChannelMonitorDailyRollup.Query().
|
||||||
// GroupBy(channelmonitordailyrollup.FieldDeletedAt).
|
// GroupBy(channelmonitordailyrollup.FieldMonitorID).
|
||||||
// Aggregate(ent.Count()).
|
// Aggregate(ent.Count()).
|
||||||
// Scan(ctx, &v)
|
// Scan(ctx, &v)
|
||||||
func (_q *ChannelMonitorDailyRollupQuery) GroupBy(field string, fields ...string) *ChannelMonitorDailyRollupGroupBy {
|
func (_q *ChannelMonitorDailyRollupQuery) GroupBy(field string, fields ...string) *ChannelMonitorDailyRollupGroupBy {
|
||||||
@@ -323,11 +323,11 @@ func (_q *ChannelMonitorDailyRollupQuery) GroupBy(field string, fields ...string
|
|||||||
// Example:
|
// Example:
|
||||||
//
|
//
|
||||||
// var v []struct {
|
// var v []struct {
|
||||||
// DeletedAt time.Time `json:"deleted_at,omitempty"`
|
// MonitorID int64 `json:"monitor_id,omitempty"`
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// client.ChannelMonitorDailyRollup.Query().
|
// client.ChannelMonitorDailyRollup.Query().
|
||||||
// Select(channelmonitordailyrollup.FieldDeletedAt).
|
// Select(channelmonitordailyrollup.FieldMonitorID).
|
||||||
// Scan(ctx, &v)
|
// Scan(ctx, &v)
|
||||||
func (_q *ChannelMonitorDailyRollupQuery) Select(fields ...string) *ChannelMonitorDailyRollupSelect {
|
func (_q *ChannelMonitorDailyRollupQuery) Select(fields ...string) *ChannelMonitorDailyRollupSelect {
|
||||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||||
|
|||||||
@@ -29,26 +29,6 @@ func (_u *ChannelMonitorDailyRollupUpdate) Where(ps ...predicate.ChannelMonitorD
|
|||||||
return _u
|
return _u
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDeletedAt sets the "deleted_at" field.
|
|
||||||
func (_u *ChannelMonitorDailyRollupUpdate) SetDeletedAt(v time.Time) *ChannelMonitorDailyRollupUpdate {
|
|
||||||
_u.mutation.SetDeletedAt(v)
|
|
||||||
return _u
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
||||||
func (_u *ChannelMonitorDailyRollupUpdate) SetNillableDeletedAt(v *time.Time) *ChannelMonitorDailyRollupUpdate {
|
|
||||||
if v != nil {
|
|
||||||
_u.SetDeletedAt(*v)
|
|
||||||
}
|
|
||||||
return _u
|
|
||||||
}
|
|
||||||
|
|
||||||
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
||||||
func (_u *ChannelMonitorDailyRollupUpdate) ClearDeletedAt() *ChannelMonitorDailyRollupUpdate {
|
|
||||||
_u.mutation.ClearDeletedAt()
|
|
||||||
return _u
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetMonitorID sets the "monitor_id" field.
|
// SetMonitorID sets the "monitor_id" field.
|
||||||
func (_u *ChannelMonitorDailyRollupUpdate) SetMonitorID(v int64) *ChannelMonitorDailyRollupUpdate {
|
func (_u *ChannelMonitorDailyRollupUpdate) SetMonitorID(v int64) *ChannelMonitorDailyRollupUpdate {
|
||||||
_u.mutation.SetMonitorID(v)
|
_u.mutation.SetMonitorID(v)
|
||||||
@@ -325,9 +305,7 @@ func (_u *ChannelMonitorDailyRollupUpdate) ClearMonitor() *ChannelMonitorDailyRo
|
|||||||
|
|
||||||
// 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 *ChannelMonitorDailyRollupUpdate) Save(ctx context.Context) (int, error) {
|
func (_u *ChannelMonitorDailyRollupUpdate) Save(ctx context.Context) (int, error) {
|
||||||
if err := _u.defaults(); err != nil {
|
_u.defaults()
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,15 +332,11 @@ func (_u *ChannelMonitorDailyRollupUpdate) 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 (_u *ChannelMonitorDailyRollupUpdate) defaults() error {
|
func (_u *ChannelMonitorDailyRollupUpdate) defaults() {
|
||||||
if _, ok := _u.mutation.ComputedAt(); !ok {
|
if _, ok := _u.mutation.ComputedAt(); !ok {
|
||||||
if channelmonitordailyrollup.UpdateDefaultComputedAt == nil {
|
|
||||||
return fmt.Errorf("ent: uninitialized channelmonitordailyrollup.UpdateDefaultComputedAt (forgotten import ent/runtime?)")
|
|
||||||
}
|
|
||||||
v := channelmonitordailyrollup.UpdateDefaultComputedAt()
|
v := channelmonitordailyrollup.UpdateDefaultComputedAt()
|
||||||
_u.mutation.SetComputedAt(v)
|
_u.mutation.SetComputedAt(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.
|
||||||
@@ -390,12 +364,6 @@ func (_u *ChannelMonitorDailyRollupUpdate) sqlSave(ctx context.Context) (_node i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if value, ok := _u.mutation.DeletedAt(); ok {
|
|
||||||
_spec.SetField(channelmonitordailyrollup.FieldDeletedAt, field.TypeTime, value)
|
|
||||||
}
|
|
||||||
if _u.mutation.DeletedAtCleared() {
|
|
||||||
_spec.ClearField(channelmonitordailyrollup.FieldDeletedAt, field.TypeTime)
|
|
||||||
}
|
|
||||||
if value, ok := _u.mutation.Model(); ok {
|
if value, ok := _u.mutation.Model(); ok {
|
||||||
_spec.SetField(channelmonitordailyrollup.FieldModel, field.TypeString, value)
|
_spec.SetField(channelmonitordailyrollup.FieldModel, field.TypeString, value)
|
||||||
}
|
}
|
||||||
@@ -514,26 +482,6 @@ type ChannelMonitorDailyRollupUpdateOne struct {
|
|||||||
mutation *ChannelMonitorDailyRollupMutation
|
mutation *ChannelMonitorDailyRollupMutation
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDeletedAt sets the "deleted_at" field.
|
|
||||||
func (_u *ChannelMonitorDailyRollupUpdateOne) SetDeletedAt(v time.Time) *ChannelMonitorDailyRollupUpdateOne {
|
|
||||||
_u.mutation.SetDeletedAt(v)
|
|
||||||
return _u
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
||||||
func (_u *ChannelMonitorDailyRollupUpdateOne) SetNillableDeletedAt(v *time.Time) *ChannelMonitorDailyRollupUpdateOne {
|
|
||||||
if v != nil {
|
|
||||||
_u.SetDeletedAt(*v)
|
|
||||||
}
|
|
||||||
return _u
|
|
||||||
}
|
|
||||||
|
|
||||||
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
||||||
func (_u *ChannelMonitorDailyRollupUpdateOne) ClearDeletedAt() *ChannelMonitorDailyRollupUpdateOne {
|
|
||||||
_u.mutation.ClearDeletedAt()
|
|
||||||
return _u
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetMonitorID sets the "monitor_id" field.
|
// SetMonitorID sets the "monitor_id" field.
|
||||||
func (_u *ChannelMonitorDailyRollupUpdateOne) SetMonitorID(v int64) *ChannelMonitorDailyRollupUpdateOne {
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetMonitorID(v int64) *ChannelMonitorDailyRollupUpdateOne {
|
||||||
_u.mutation.SetMonitorID(v)
|
_u.mutation.SetMonitorID(v)
|
||||||
@@ -823,9 +771,7 @@ func (_u *ChannelMonitorDailyRollupUpdateOne) Select(field string, fields ...str
|
|||||||
|
|
||||||
// Save executes the query and returns the updated ChannelMonitorDailyRollup entity.
|
// Save executes the query and returns the updated ChannelMonitorDailyRollup entity.
|
||||||
func (_u *ChannelMonitorDailyRollupUpdateOne) Save(ctx context.Context) (*ChannelMonitorDailyRollup, error) {
|
func (_u *ChannelMonitorDailyRollupUpdateOne) Save(ctx context.Context) (*ChannelMonitorDailyRollup, error) {
|
||||||
if err := _u.defaults(); err != nil {
|
_u.defaults()
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -852,15 +798,11 @@ func (_u *ChannelMonitorDailyRollupUpdateOne) 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 (_u *ChannelMonitorDailyRollupUpdateOne) defaults() error {
|
func (_u *ChannelMonitorDailyRollupUpdateOne) defaults() {
|
||||||
if _, ok := _u.mutation.ComputedAt(); !ok {
|
if _, ok := _u.mutation.ComputedAt(); !ok {
|
||||||
if channelmonitordailyrollup.UpdateDefaultComputedAt == nil {
|
|
||||||
return fmt.Errorf("ent: uninitialized channelmonitordailyrollup.UpdateDefaultComputedAt (forgotten import ent/runtime?)")
|
|
||||||
}
|
|
||||||
v := channelmonitordailyrollup.UpdateDefaultComputedAt()
|
v := channelmonitordailyrollup.UpdateDefaultComputedAt()
|
||||||
_u.mutation.SetComputedAt(v)
|
_u.mutation.SetComputedAt(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.
|
||||||
@@ -905,12 +847,6 @@ func (_u *ChannelMonitorDailyRollupUpdateOne) sqlSave(ctx context.Context) (_nod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if value, ok := _u.mutation.DeletedAt(); ok {
|
|
||||||
_spec.SetField(channelmonitordailyrollup.FieldDeletedAt, field.TypeTime, value)
|
|
||||||
}
|
|
||||||
if _u.mutation.DeletedAtCleared() {
|
|
||||||
_spec.ClearField(channelmonitordailyrollup.FieldDeletedAt, field.TypeTime)
|
|
||||||
}
|
|
||||||
if value, ok := _u.mutation.Model(); ok {
|
if value, ok := _u.mutation.Model(); ok {
|
||||||
_spec.SetField(channelmonitordailyrollup.FieldModel, field.TypeString, value)
|
_spec.SetField(channelmonitordailyrollup.FieldModel, field.TypeString, value)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ 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.
|
||||||
@@ -69,7 +67,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.FieldDeletedAt, channelmonitorhistory.FieldCheckedAt:
|
case channelmonitorhistory.FieldCheckedAt:
|
||||||
values[i] = new(sql.NullTime)
|
values[i] = new(sql.NullTime)
|
||||||
default:
|
default:
|
||||||
values[i] = new(sql.UnknownType)
|
values[i] = new(sql.UnknownType)
|
||||||
@@ -92,13 +90,6 @@ 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])
|
||||||
@@ -184,11 +175,6 @@ 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,7 +6,6 @@ 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"
|
||||||
)
|
)
|
||||||
@@ -16,8 +15,6 @@ 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.
|
||||||
@@ -48,7 +45,6 @@ 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,
|
||||||
@@ -68,14 +64,7 @@ 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.
|
||||||
@@ -119,11 +108,6 @@ 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,11 +55,6 @@ 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))
|
||||||
@@ -90,56 +85,6 @@ 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,20 +23,6 @@ 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)
|
||||||
@@ -123,9 +109,7 @@ 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) {
|
||||||
if err := _c.defaults(); err != nil {
|
_c.defaults()
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,19 +136,15 @@ 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() error {
|
func (_c *ChannelMonitorHistoryCreate) defaults() {
|
||||||
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.
|
||||||
@@ -226,10 +206,6 @@ 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
|
||||||
@@ -278,7 +254,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().
|
||||||
// SetDeletedAt(v).
|
// SetMonitorID(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.
|
||||||
@@ -287,7 +263,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) {
|
||||||
// SetDeletedAt(v+v).
|
// SetMonitorID(v+v).
|
||||||
// }).
|
// }).
|
||||||
// Exec(ctx)
|
// Exec(ctx)
|
||||||
func (_c *ChannelMonitorHistoryCreate) OnConflict(opts ...sql.ConflictOption) *ChannelMonitorHistoryUpsertOne {
|
func (_c *ChannelMonitorHistoryCreate) OnConflict(opts ...sql.ConflictOption) *ChannelMonitorHistoryUpsertOne {
|
||||||
@@ -323,24 +299,6 @@ 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)
|
||||||
@@ -495,27 +453,6 @@ 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) {
|
||||||
@@ -784,7 +721,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) {
|
||||||
// SetDeletedAt(v+v).
|
// SetMonitorID(v+v).
|
||||||
// }).
|
// }).
|
||||||
// Exec(ctx)
|
// Exec(ctx)
|
||||||
func (_c *ChannelMonitorHistoryCreateBulk) OnConflict(opts ...sql.ConflictOption) *ChannelMonitorHistoryUpsertBulk {
|
func (_c *ChannelMonitorHistoryCreateBulk) OnConflict(opts ...sql.ConflictOption) *ChannelMonitorHistoryUpsertBulk {
|
||||||
@@ -853,27 +790,6 @@ 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 {
|
||||||
// DeletedAt time.Time `json:"deleted_at,omitempty"`
|
// MonitorID int64 `json:"monitor_id,omitempty"`
|
||||||
// Count int `json:"count,omitempty"`
|
// Count int `json:"count,omitempty"`
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// client.ChannelMonitorHistory.Query().
|
// client.ChannelMonitorHistory.Query().
|
||||||
// GroupBy(channelmonitorhistory.FieldDeletedAt).
|
// GroupBy(channelmonitorhistory.FieldMonitorID).
|
||||||
// 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 {
|
||||||
// DeletedAt time.Time `json:"deleted_at,omitempty"`
|
// MonitorID int64 `json:"monitor_id,omitempty"`
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// client.ChannelMonitorHistory.Query().
|
// client.ChannelMonitorHistory.Query().
|
||||||
// Select(channelmonitorhistory.FieldDeletedAt).
|
// Select(channelmonitorhistory.FieldMonitorID).
|
||||||
// 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,26 +29,6 @@ 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)
|
||||||
@@ -257,12 +237,6 @@ 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)
|
||||||
}
|
}
|
||||||
@@ -345,26 +319,6 @@ 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)
|
||||||
@@ -603,12 +557,6 @@ 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)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1912,14 +1912,12 @@ func (c *ChannelMonitorDailyRollupClient) QueryMonitor(_m *ChannelMonitorDailyRo
|
|||||||
|
|
||||||
// Hooks returns the client hooks.
|
// Hooks returns the client hooks.
|
||||||
func (c *ChannelMonitorDailyRollupClient) Hooks() []Hook {
|
func (c *ChannelMonitorDailyRollupClient) Hooks() []Hook {
|
||||||
hooks := c.hooks.ChannelMonitorDailyRollup
|
return c.hooks.ChannelMonitorDailyRollup
|
||||||
return append(hooks[:len(hooks):len(hooks)], channelmonitordailyrollup.Hooks[:]...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interceptors returns the client interceptors.
|
// Interceptors returns the client interceptors.
|
||||||
func (c *ChannelMonitorDailyRollupClient) Interceptors() []Interceptor {
|
func (c *ChannelMonitorDailyRollupClient) Interceptors() []Interceptor {
|
||||||
inters := c.inters.ChannelMonitorDailyRollup
|
return c.inters.ChannelMonitorDailyRollup
|
||||||
return append(inters[:len(inters):len(inters)], channelmonitordailyrollup.Interceptors[:]...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ChannelMonitorDailyRollupClient) mutate(ctx context.Context, m *ChannelMonitorDailyRollupMutation) (Value, error) {
|
func (c *ChannelMonitorDailyRollupClient) mutate(ctx context.Context, m *ChannelMonitorDailyRollupMutation) (Value, error) {
|
||||||
@@ -2063,14 +2061,12 @@ 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 {
|
||||||
hooks := c.hooks.ChannelMonitorHistory
|
return 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 {
|
||||||
inters := c.inters.ChannelMonitorHistory
|
return 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) {
|
||||||
|
|||||||
@@ -464,7 +464,6 @@ var (
|
|||||||
// ChannelMonitorDailyRollupsColumns holds the columns for the "channel_monitor_daily_rollups" table.
|
// ChannelMonitorDailyRollupsColumns holds the columns for the "channel_monitor_daily_rollups" table.
|
||||||
ChannelMonitorDailyRollupsColumns = []*schema.Column{
|
ChannelMonitorDailyRollupsColumns = []*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: "bucket_date", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "date"}},
|
{Name: "bucket_date", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "date"}},
|
||||||
{Name: "total_checks", Type: field.TypeInt, Default: 0},
|
{Name: "total_checks", Type: field.TypeInt, Default: 0},
|
||||||
@@ -488,7 +487,7 @@ var (
|
|||||||
ForeignKeys: []*schema.ForeignKey{
|
ForeignKeys: []*schema.ForeignKey{
|
||||||
{
|
{
|
||||||
Symbol: "channel_monitor_daily_rollups_channel_monitors_daily_rollups",
|
Symbol: "channel_monitor_daily_rollups_channel_monitors_daily_rollups",
|
||||||
Columns: []*schema.Column{ChannelMonitorDailyRollupsColumns[15]},
|
Columns: []*schema.Column{ChannelMonitorDailyRollupsColumns[14]},
|
||||||
RefColumns: []*schema.Column{ChannelMonitorsColumns[0]},
|
RefColumns: []*schema.Column{ChannelMonitorsColumns[0]},
|
||||||
OnDelete: schema.Cascade,
|
OnDelete: schema.Cascade,
|
||||||
},
|
},
|
||||||
@@ -497,19 +496,18 @@ var (
|
|||||||
{
|
{
|
||||||
Name: "channelmonitordailyrollup_monitor_id_model_bucket_date",
|
Name: "channelmonitordailyrollup_monitor_id_model_bucket_date",
|
||||||
Unique: true,
|
Unique: true,
|
||||||
Columns: []*schema.Column{ChannelMonitorDailyRollupsColumns[15], ChannelMonitorDailyRollupsColumns[2], ChannelMonitorDailyRollupsColumns[3]},
|
Columns: []*schema.Column{ChannelMonitorDailyRollupsColumns[14], ChannelMonitorDailyRollupsColumns[1], ChannelMonitorDailyRollupsColumns[2]},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "channelmonitordailyrollup_bucket_date",
|
Name: "channelmonitordailyrollup_bucket_date",
|
||||||
Unique: false,
|
Unique: false,
|
||||||
Columns: []*schema.Column{ChannelMonitorDailyRollupsColumns[3]},
|
Columns: []*schema.Column{ChannelMonitorDailyRollupsColumns[2]},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
// 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},
|
||||||
@@ -526,7 +524,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[8]},
|
Columns: []*schema.Column{ChannelMonitorHistoriesColumns[7]},
|
||||||
RefColumns: []*schema.Column{ChannelMonitorsColumns[0]},
|
RefColumns: []*schema.Column{ChannelMonitorsColumns[0]},
|
||||||
OnDelete: schema.Cascade,
|
OnDelete: schema.Cascade,
|
||||||
},
|
},
|
||||||
@@ -535,12 +533,12 @@ var (
|
|||||||
{
|
{
|
||||||
Name: "channelmonitorhistory_monitor_id_model_checked_at",
|
Name: "channelmonitorhistory_monitor_id_model_checked_at",
|
||||||
Unique: false,
|
Unique: false,
|
||||||
Columns: []*schema.Column{ChannelMonitorHistoriesColumns[8], ChannelMonitorHistoriesColumns[2], ChannelMonitorHistoriesColumns[7]},
|
Columns: []*schema.Column{ChannelMonitorHistoriesColumns[7], ChannelMonitorHistoriesColumns[1], ChannelMonitorHistoriesColumns[6]},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "channelmonitorhistory_checked_at",
|
Name: "channelmonitorhistory_checked_at",
|
||||||
Unique: false,
|
Unique: false,
|
||||||
Columns: []*schema.Column{ChannelMonitorHistoriesColumns[7]},
|
Columns: []*schema.Column{ChannelMonitorHistoriesColumns[6]},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10022,7 +10022,6 @@ type ChannelMonitorDailyRollupMutation struct {
|
|||||||
op Op
|
op Op
|
||||||
typ string
|
typ string
|
||||||
id *int64
|
id *int64
|
||||||
deleted_at *time.Time
|
|
||||||
model *string
|
model *string
|
||||||
bucket_date *time.Time
|
bucket_date *time.Time
|
||||||
total_checks *int
|
total_checks *int
|
||||||
@@ -10152,55 +10151,6 @@ func (m *ChannelMonitorDailyRollupMutation) IDs(ctx context.Context) ([]int64, e
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDeletedAt sets the "deleted_at" field.
|
|
||||||
func (m *ChannelMonitorDailyRollupMutation) SetDeletedAt(t time.Time) {
|
|
||||||
m.deleted_at = &t
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeletedAt returns the value of the "deleted_at" field in the mutation.
|
|
||||||
func (m *ChannelMonitorDailyRollupMutation) DeletedAt() (r time.Time, exists bool) {
|
|
||||||
v := m.deleted_at
|
|
||||||
if v == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return *v, true
|
|
||||||
}
|
|
||||||
|
|
||||||
// OldDeletedAt returns the old "deleted_at" field's value of the ChannelMonitorDailyRollup entity.
|
|
||||||
// If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
|
|
||||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
||||||
func (m *ChannelMonitorDailyRollupMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
|
|
||||||
if !m.op.Is(OpUpdateOne) {
|
|
||||||
return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
|
|
||||||
}
|
|
||||||
if m.id == nil || m.oldValue == nil {
|
|
||||||
return v, errors.New("OldDeletedAt requires an ID field in the mutation")
|
|
||||||
}
|
|
||||||
oldValue, err := m.oldValue(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
|
|
||||||
}
|
|
||||||
return oldValue.DeletedAt, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
||||||
func (m *ChannelMonitorDailyRollupMutation) ClearDeletedAt() {
|
|
||||||
m.deleted_at = nil
|
|
||||||
m.clearedFields[channelmonitordailyrollup.FieldDeletedAt] = struct{}{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
|
|
||||||
func (m *ChannelMonitorDailyRollupMutation) DeletedAtCleared() bool {
|
|
||||||
_, ok := m.clearedFields[channelmonitordailyrollup.FieldDeletedAt]
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
// ResetDeletedAt resets all changes to the "deleted_at" field.
|
|
||||||
func (m *ChannelMonitorDailyRollupMutation) ResetDeletedAt() {
|
|
||||||
m.deleted_at = nil
|
|
||||||
delete(m.clearedFields, channelmonitordailyrollup.FieldDeletedAt)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetMonitorID sets the "monitor_id" field.
|
// SetMonitorID sets the "monitor_id" field.
|
||||||
func (m *ChannelMonitorDailyRollupMutation) SetMonitorID(i int64) {
|
func (m *ChannelMonitorDailyRollupMutation) SetMonitorID(i int64) {
|
||||||
m.monitor = &i
|
m.monitor = &i
|
||||||
@@ -10966,10 +10916,7 @@ func (m *ChannelMonitorDailyRollupMutation) Type() string {
|
|||||||
// order to get all numeric fields that were incremented/decremented, call
|
// order to get all numeric fields that were incremented/decremented, call
|
||||||
// AddedFields().
|
// AddedFields().
|
||||||
func (m *ChannelMonitorDailyRollupMutation) Fields() []string {
|
func (m *ChannelMonitorDailyRollupMutation) Fields() []string {
|
||||||
fields := make([]string, 0, 15)
|
fields := make([]string, 0, 14)
|
||||||
if m.deleted_at != nil {
|
|
||||||
fields = append(fields, channelmonitordailyrollup.FieldDeletedAt)
|
|
||||||
}
|
|
||||||
if m.monitor != nil {
|
if m.monitor != nil {
|
||||||
fields = append(fields, channelmonitordailyrollup.FieldMonitorID)
|
fields = append(fields, channelmonitordailyrollup.FieldMonitorID)
|
||||||
}
|
}
|
||||||
@@ -11020,8 +10967,6 @@ func (m *ChannelMonitorDailyRollupMutation) Fields() []string {
|
|||||||
// schema.
|
// schema.
|
||||||
func (m *ChannelMonitorDailyRollupMutation) Field(name string) (ent.Value, bool) {
|
func (m *ChannelMonitorDailyRollupMutation) Field(name string) (ent.Value, bool) {
|
||||||
switch name {
|
switch name {
|
||||||
case channelmonitordailyrollup.FieldDeletedAt:
|
|
||||||
return m.DeletedAt()
|
|
||||||
case channelmonitordailyrollup.FieldMonitorID:
|
case channelmonitordailyrollup.FieldMonitorID:
|
||||||
return m.MonitorID()
|
return m.MonitorID()
|
||||||
case channelmonitordailyrollup.FieldModel:
|
case channelmonitordailyrollup.FieldModel:
|
||||||
@@ -11059,8 +11004,6 @@ func (m *ChannelMonitorDailyRollupMutation) Field(name string) (ent.Value, bool)
|
|||||||
// database failed.
|
// database failed.
|
||||||
func (m *ChannelMonitorDailyRollupMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
func (m *ChannelMonitorDailyRollupMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
||||||
switch name {
|
switch name {
|
||||||
case channelmonitordailyrollup.FieldDeletedAt:
|
|
||||||
return m.OldDeletedAt(ctx)
|
|
||||||
case channelmonitordailyrollup.FieldMonitorID:
|
case channelmonitordailyrollup.FieldMonitorID:
|
||||||
return m.OldMonitorID(ctx)
|
return m.OldMonitorID(ctx)
|
||||||
case channelmonitordailyrollup.FieldModel:
|
case channelmonitordailyrollup.FieldModel:
|
||||||
@@ -11098,13 +11041,6 @@ func (m *ChannelMonitorDailyRollupMutation) OldField(ctx context.Context, name s
|
|||||||
// type.
|
// type.
|
||||||
func (m *ChannelMonitorDailyRollupMutation) SetField(name string, value ent.Value) error {
|
func (m *ChannelMonitorDailyRollupMutation) SetField(name string, value ent.Value) error {
|
||||||
switch name {
|
switch name {
|
||||||
case channelmonitordailyrollup.FieldDeletedAt:
|
|
||||||
v, ok := value.(time.Time)
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
||||||
}
|
|
||||||
m.SetDeletedAt(v)
|
|
||||||
return nil
|
|
||||||
case channelmonitordailyrollup.FieldMonitorID:
|
case channelmonitordailyrollup.FieldMonitorID:
|
||||||
v, ok := value.(int64)
|
v, ok := value.(int64)
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -11355,11 +11291,7 @@ func (m *ChannelMonitorDailyRollupMutation) AddField(name string, value ent.Valu
|
|||||||
// ClearedFields returns all nullable fields that were cleared during this
|
// ClearedFields returns all nullable fields that were cleared during this
|
||||||
// mutation.
|
// mutation.
|
||||||
func (m *ChannelMonitorDailyRollupMutation) ClearedFields() []string {
|
func (m *ChannelMonitorDailyRollupMutation) ClearedFields() []string {
|
||||||
var fields []string
|
return nil
|
||||||
if m.FieldCleared(channelmonitordailyrollup.FieldDeletedAt) {
|
|
||||||
fields = append(fields, channelmonitordailyrollup.FieldDeletedAt)
|
|
||||||
}
|
|
||||||
return fields
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FieldCleared returns a boolean indicating if a field with the given name was
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
||||||
@@ -11372,11 +11304,6 @@ func (m *ChannelMonitorDailyRollupMutation) FieldCleared(name string) bool {
|
|||||||
// ClearField clears the value of the field with the given name. It returns an
|
// ClearField clears the value of the field with the given name. It returns an
|
||||||
// error if the field is not defined in the schema.
|
// error if the field is not defined in the schema.
|
||||||
func (m *ChannelMonitorDailyRollupMutation) ClearField(name string) error {
|
func (m *ChannelMonitorDailyRollupMutation) ClearField(name string) error {
|
||||||
switch name {
|
|
||||||
case channelmonitordailyrollup.FieldDeletedAt:
|
|
||||||
m.ClearDeletedAt()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return fmt.Errorf("unknown ChannelMonitorDailyRollup nullable field %s", name)
|
return fmt.Errorf("unknown ChannelMonitorDailyRollup nullable field %s", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11384,9 +11311,6 @@ func (m *ChannelMonitorDailyRollupMutation) ClearField(name string) error {
|
|||||||
// It returns an error if the field is not defined in the schema.
|
// It returns an error if the field is not defined in the schema.
|
||||||
func (m *ChannelMonitorDailyRollupMutation) ResetField(name string) error {
|
func (m *ChannelMonitorDailyRollupMutation) ResetField(name string) error {
|
||||||
switch name {
|
switch name {
|
||||||
case channelmonitordailyrollup.FieldDeletedAt:
|
|
||||||
m.ResetDeletedAt()
|
|
||||||
return nil
|
|
||||||
case channelmonitordailyrollup.FieldMonitorID:
|
case channelmonitordailyrollup.FieldMonitorID:
|
||||||
m.ResetMonitorID()
|
m.ResetMonitorID()
|
||||||
return nil
|
return nil
|
||||||
@@ -11513,7 +11437,6 @@ type ChannelMonitorHistoryMutation struct {
|
|||||||
op Op
|
op Op
|
||||||
typ string
|
typ string
|
||||||
id *int64
|
id *int64
|
||||||
deleted_at *time.Time
|
|
||||||
model *string
|
model *string
|
||||||
status *channelmonitorhistory.Status
|
status *channelmonitorhistory.Status
|
||||||
latency_ms *int
|
latency_ms *int
|
||||||
@@ -11628,55 +11551,6 @@ func (m *ChannelMonitorHistoryMutation) IDs(ctx context.Context) ([]int64, error
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDeletedAt sets the "deleted_at" field.
|
|
||||||
func (m *ChannelMonitorHistoryMutation) SetDeletedAt(t time.Time) {
|
|
||||||
m.deleted_at = &t
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeletedAt returns the value of the "deleted_at" field in the mutation.
|
|
||||||
func (m *ChannelMonitorHistoryMutation) DeletedAt() (r time.Time, exists bool) {
|
|
||||||
v := m.deleted_at
|
|
||||||
if v == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return *v, true
|
|
||||||
}
|
|
||||||
|
|
||||||
// OldDeletedAt returns the old "deleted_at" field's value of the ChannelMonitorHistory entity.
|
|
||||||
// If the ChannelMonitorHistory object wasn't provided to the builder, the object is fetched from the database.
|
|
||||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
||||||
func (m *ChannelMonitorHistoryMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
|
|
||||||
if !m.op.Is(OpUpdateOne) {
|
|
||||||
return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
|
|
||||||
}
|
|
||||||
if m.id == nil || m.oldValue == nil {
|
|
||||||
return v, errors.New("OldDeletedAt requires an ID field in the mutation")
|
|
||||||
}
|
|
||||||
oldValue, err := m.oldValue(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
|
|
||||||
}
|
|
||||||
return oldValue.DeletedAt, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
||||||
func (m *ChannelMonitorHistoryMutation) ClearDeletedAt() {
|
|
||||||
m.deleted_at = nil
|
|
||||||
m.clearedFields[channelmonitorhistory.FieldDeletedAt] = struct{}{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
|
|
||||||
func (m *ChannelMonitorHistoryMutation) DeletedAtCleared() bool {
|
|
||||||
_, ok := m.clearedFields[channelmonitorhistory.FieldDeletedAt]
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
// ResetDeletedAt resets all changes to the "deleted_at" field.
|
|
||||||
func (m *ChannelMonitorHistoryMutation) ResetDeletedAt() {
|
|
||||||
m.deleted_at = nil
|
|
||||||
delete(m.clearedFields, channelmonitorhistory.FieldDeletedAt)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetMonitorID sets the "monitor_id" field.
|
// SetMonitorID sets the "monitor_id" field.
|
||||||
func (m *ChannelMonitorHistoryMutation) SetMonitorID(i int64) {
|
func (m *ChannelMonitorHistoryMutation) SetMonitorID(i int64) {
|
||||||
m.monitor = &i
|
m.monitor = &i
|
||||||
@@ -12071,10 +11945,7 @@ func (m *ChannelMonitorHistoryMutation) Type() string {
|
|||||||
// order to get all numeric fields that were incremented/decremented, call
|
// order to get all numeric fields that were incremented/decremented, call
|
||||||
// AddedFields().
|
// AddedFields().
|
||||||
func (m *ChannelMonitorHistoryMutation) Fields() []string {
|
func (m *ChannelMonitorHistoryMutation) Fields() []string {
|
||||||
fields := make([]string, 0, 8)
|
fields := make([]string, 0, 7)
|
||||||
if m.deleted_at != nil {
|
|
||||||
fields = append(fields, channelmonitorhistory.FieldDeletedAt)
|
|
||||||
}
|
|
||||||
if m.monitor != nil {
|
if m.monitor != nil {
|
||||||
fields = append(fields, channelmonitorhistory.FieldMonitorID)
|
fields = append(fields, channelmonitorhistory.FieldMonitorID)
|
||||||
}
|
}
|
||||||
@@ -12104,8 +11975,6 @@ func (m *ChannelMonitorHistoryMutation) Fields() []string {
|
|||||||
// schema.
|
// schema.
|
||||||
func (m *ChannelMonitorHistoryMutation) Field(name string) (ent.Value, bool) {
|
func (m *ChannelMonitorHistoryMutation) Field(name string) (ent.Value, bool) {
|
||||||
switch name {
|
switch name {
|
||||||
case channelmonitorhistory.FieldDeletedAt:
|
|
||||||
return m.DeletedAt()
|
|
||||||
case channelmonitorhistory.FieldMonitorID:
|
case channelmonitorhistory.FieldMonitorID:
|
||||||
return m.MonitorID()
|
return m.MonitorID()
|
||||||
case channelmonitorhistory.FieldModel:
|
case channelmonitorhistory.FieldModel:
|
||||||
@@ -12129,8 +11998,6 @@ func (m *ChannelMonitorHistoryMutation) Field(name string) (ent.Value, bool) {
|
|||||||
// database failed.
|
// database failed.
|
||||||
func (m *ChannelMonitorHistoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
func (m *ChannelMonitorHistoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
||||||
switch name {
|
switch name {
|
||||||
case channelmonitorhistory.FieldDeletedAt:
|
|
||||||
return m.OldDeletedAt(ctx)
|
|
||||||
case channelmonitorhistory.FieldMonitorID:
|
case channelmonitorhistory.FieldMonitorID:
|
||||||
return m.OldMonitorID(ctx)
|
return m.OldMonitorID(ctx)
|
||||||
case channelmonitorhistory.FieldModel:
|
case channelmonitorhistory.FieldModel:
|
||||||
@@ -12154,13 +12021,6 @@ func (m *ChannelMonitorHistoryMutation) OldField(ctx context.Context, name strin
|
|||||||
// type.
|
// type.
|
||||||
func (m *ChannelMonitorHistoryMutation) SetField(name string, value ent.Value) error {
|
func (m *ChannelMonitorHistoryMutation) SetField(name string, value ent.Value) error {
|
||||||
switch name {
|
switch name {
|
||||||
case channelmonitorhistory.FieldDeletedAt:
|
|
||||||
v, ok := value.(time.Time)
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
||||||
}
|
|
||||||
m.SetDeletedAt(v)
|
|
||||||
return nil
|
|
||||||
case channelmonitorhistory.FieldMonitorID:
|
case channelmonitorhistory.FieldMonitorID:
|
||||||
v, ok := value.(int64)
|
v, ok := value.(int64)
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -12267,9 +12127,6 @@ func (m *ChannelMonitorHistoryMutation) AddField(name string, value ent.Value) e
|
|||||||
// mutation.
|
// mutation.
|
||||||
func (m *ChannelMonitorHistoryMutation) ClearedFields() []string {
|
func (m *ChannelMonitorHistoryMutation) ClearedFields() []string {
|
||||||
var fields []string
|
var fields []string
|
||||||
if m.FieldCleared(channelmonitorhistory.FieldDeletedAt) {
|
|
||||||
fields = append(fields, channelmonitorhistory.FieldDeletedAt)
|
|
||||||
}
|
|
||||||
if m.FieldCleared(channelmonitorhistory.FieldLatencyMs) {
|
if m.FieldCleared(channelmonitorhistory.FieldLatencyMs) {
|
||||||
fields = append(fields, channelmonitorhistory.FieldLatencyMs)
|
fields = append(fields, channelmonitorhistory.FieldLatencyMs)
|
||||||
}
|
}
|
||||||
@@ -12293,9 +12150,6 @@ func (m *ChannelMonitorHistoryMutation) FieldCleared(name string) bool {
|
|||||||
// error if the field is not defined in the schema.
|
// error if the field is not defined in the schema.
|
||||||
func (m *ChannelMonitorHistoryMutation) ClearField(name string) error {
|
func (m *ChannelMonitorHistoryMutation) ClearField(name string) error {
|
||||||
switch name {
|
switch name {
|
||||||
case channelmonitorhistory.FieldDeletedAt:
|
|
||||||
m.ClearDeletedAt()
|
|
||||||
return nil
|
|
||||||
case channelmonitorhistory.FieldLatencyMs:
|
case channelmonitorhistory.FieldLatencyMs:
|
||||||
m.ClearLatencyMs()
|
m.ClearLatencyMs()
|
||||||
return nil
|
return nil
|
||||||
@@ -12313,9 +12167,6 @@ func (m *ChannelMonitorHistoryMutation) ClearField(name string) error {
|
|||||||
// It returns an error if the field is not defined in the schema.
|
// It returns an error if the field is not defined in the schema.
|
||||||
func (m *ChannelMonitorHistoryMutation) ResetField(name string) error {
|
func (m *ChannelMonitorHistoryMutation) ResetField(name string) error {
|
||||||
switch name {
|
switch name {
|
||||||
case channelmonitorhistory.FieldDeletedAt:
|
|
||||||
m.ResetDeletedAt()
|
|
||||||
return nil
|
|
||||||
case channelmonitorhistory.FieldMonitorID:
|
case channelmonitorhistory.FieldMonitorID:
|
||||||
m.ResetMonitorID()
|
m.ResetMonitorID()
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -521,11 +521,6 @@ 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 := schema.ChannelMonitorDailyRollup{}.Fields()
|
||||||
_ = channelmonitordailyrollupFields
|
_ = channelmonitordailyrollupFields
|
||||||
// channelmonitordailyrollupDescModel is the schema descriptor for model field.
|
// channelmonitordailyrollupDescModel is the schema descriptor for model field.
|
||||||
@@ -592,11 +587,6 @@ func init() {
|
|||||||
channelmonitordailyrollup.DefaultComputedAt = channelmonitordailyrollupDescComputedAt.Default.(func() time.Time)
|
channelmonitordailyrollup.DefaultComputedAt = channelmonitordailyrollupDescComputedAt.Default.(func() time.Time)
|
||||||
// channelmonitordailyrollup.UpdateDefaultComputedAt holds the default value on update for the computed_at field.
|
// channelmonitordailyrollup.UpdateDefaultComputedAt holds the default value on update for the computed_at field.
|
||||||
channelmonitordailyrollup.UpdateDefaultComputedAt = channelmonitordailyrollupDescComputedAt.UpdateDefault.(func() time.Time)
|
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.
|
||||||
|
|||||||
@@ -10,13 +10,12 @@ 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"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ChannelMonitorDailyRollup 按 (monitor_id, model, bucket_date) 维度聚合的渠道监控日统计。
|
// ChannelMonitorDailyRollup 按 (monitor_id, model, bucket_date) 维度聚合的渠道监控日统计。
|
||||||
// 每天的明细被收敛为一行(保留 status 分布 + 延迟和),用于 7d/15d/30d 窗口的可用率
|
// 每天的明细被收敛为一行(保留 status 分布 + 延迟和),用于 7d/15d/30d 窗口的可用率
|
||||||
// 加权计算(avg_latency = sum_latency_ms / count_latency;availability = ok_count / total_checks)。
|
// 加权计算(avg_latency = sum_latency_ms / count_latency;availability = ok_count / total_checks)。
|
||||||
|
// 超过保留期由每日维护任务分批物理删(不用软删除,理由同 channel_monitor_history)。
|
||||||
type ChannelMonitorDailyRollup struct {
|
type ChannelMonitorDailyRollup struct {
|
||||||
ent.Schema
|
ent.Schema
|
||||||
}
|
}
|
||||||
@@ -27,12 +26,6 @@ func (ChannelMonitorDailyRollup) Annotations() []schema.Annotation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ChannelMonitorDailyRollup) Mixin() []ent.Mixin {
|
|
||||||
return []ent.Mixin{
|
|
||||||
mixins.SoftDeleteMixin{},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ChannelMonitorDailyRollup) Fields() []ent.Field {
|
func (ChannelMonitorDailyRollup) Fields() []ent.Field {
|
||||||
return []ent.Field{
|
return []ent.Field{
|
||||||
field.Int64("monitor_id"),
|
field.Int64("monitor_id"),
|
||||||
|
|||||||
@@ -9,13 +9,12 @@ 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.
|
||||||
// 渠道监控历史:每次检测每个模型一行记录。明细只保留 1 天,超过 1 天的数据被聚合到
|
// 渠道监控历史:每次检测每个模型一行记录。明细只保留 1 天,超过 1 天由每日维护任务
|
||||||
// channel_monitor_daily_rollups 后软删(deleted_at),由后续懒清理任务物理移除。
|
// 先聚合到 channel_monitor_daily_rollups,再分批物理删(不用软删除:日志类表无恢复
|
||||||
|
// 需求,软删会让行和索引只增不减,徒增磁盘和查询开销)。
|
||||||
type ChannelMonitorHistory struct {
|
type ChannelMonitorHistory struct {
|
||||||
ent.Schema
|
ent.Schema
|
||||||
}
|
}
|
||||||
@@ -26,12 +25,6 @@ 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"),
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ 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"
|
||||||
@@ -195,15 +194,10 @@ func (r *channelMonitorRepository) InsertHistoryBatch(ctx context.Context, rows
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeleteHistoryBefore 物理删 checked_at < before 的明细,分批 channelMonitorPruneBatchSize 行一批,
|
||||||
|
// 避免单事务删除过多引起锁/WAL 压力。借助 (checked_at) 索引定位小批 id,再按 id 删。
|
||||||
func (r *channelMonitorRepository) DeleteHistoryBefore(ctx context.Context, before time.Time) (int64, error) {
|
func (r *channelMonitorRepository) DeleteHistoryBefore(ctx context.Context, before time.Time) (int64, error) {
|
||||||
client := clientFromContext(ctx, r.client)
|
return deleteChannelMonitorBatched(ctx, r.db, channelMonitorPruneHistorySQL, before)
|
||||||
n, err := client.ChannelMonitorHistory.Delete().
|
|
||||||
Where(channelmonitorhistory.CheckedAtLT(before)).
|
|
||||||
Exec(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return 0, fmt.Errorf("delete history before: %w", err)
|
|
||||||
}
|
|
||||||
return int64(n), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListHistory 按 checked_at 倒序返回某个监控的最近 N 条历史记录。
|
// ListHistory 按 checked_at 倒序返回某个监控的最近 N 条历史记录。
|
||||||
@@ -247,7 +241,6 @@ 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)
|
||||||
@@ -302,7 +295,6 @@ func (r *channelMonitorRepository) ComputeAvailability(ctx context.Context, moni
|
|||||||
COUNT(latency_ms) AS count_latency
|
COUNT(latency_ms) AS count_latency
|
||||||
FROM channel_monitor_histories
|
FROM channel_monitor_histories
|
||||||
WHERE monitor_id = $1
|
WHERE monitor_id = $1
|
||||||
AND deleted_at IS NULL
|
|
||||||
AND checked_at >= CURRENT_DATE
|
AND checked_at >= CURRENT_DATE
|
||||||
GROUP BY model
|
GROUP BY model
|
||||||
),
|
),
|
||||||
@@ -310,7 +302,6 @@ func (r *channelMonitorRepository) ComputeAvailability(ctx context.Context, moni
|
|||||||
SELECT model, total_checks, ok_count, sum_latency_ms, count_latency
|
SELECT model, total_checks, ok_count, sum_latency_ms, count_latency
|
||||||
FROM channel_monitor_daily_rollups
|
FROM channel_monitor_daily_rollups
|
||||||
WHERE monitor_id = $1
|
WHERE monitor_id = $1
|
||||||
AND deleted_at IS NULL
|
|
||||||
AND bucket_date >= (CURRENT_DATE - $2::int)
|
AND bucket_date >= (CURRENT_DATE - $2::int)
|
||||||
AND bucket_date < CURRENT_DATE
|
AND bucket_date < CURRENT_DATE
|
||||||
)
|
)
|
||||||
@@ -376,7 +367,6 @@ 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))
|
||||||
@@ -437,7 +427,6 @@ 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
|
||||||
@@ -524,7 +513,6 @@ func (r *channelMonitorRepository) ComputeAvailabilityForMonitors(ctx context.Co
|
|||||||
COUNT(latency_ms) AS count_latency
|
COUNT(latency_ms) AS count_latency
|
||||||
FROM channel_monitor_histories
|
FROM channel_monitor_histories
|
||||||
WHERE monitor_id = ANY($1)
|
WHERE monitor_id = ANY($1)
|
||||||
AND deleted_at IS NULL
|
|
||||||
AND checked_at >= CURRENT_DATE
|
AND checked_at >= CURRENT_DATE
|
||||||
GROUP BY monitor_id, model
|
GROUP BY monitor_id, model
|
||||||
),
|
),
|
||||||
@@ -532,7 +520,6 @@ func (r *channelMonitorRepository) ComputeAvailabilityForMonitors(ctx context.Co
|
|||||||
SELECT monitor_id, model, total_checks, ok_count, sum_latency_ms, count_latency
|
SELECT monitor_id, model, total_checks, ok_count, sum_latency_ms, count_latency
|
||||||
FROM channel_monitor_daily_rollups
|
FROM channel_monitor_daily_rollups
|
||||||
WHERE monitor_id = ANY($1)
|
WHERE monitor_id = ANY($1)
|
||||||
AND deleted_at IS NULL
|
|
||||||
AND bucket_date >= (CURRENT_DATE - $2::int)
|
AND bucket_date >= (CURRENT_DATE - $2::int)
|
||||||
AND bucket_date < CURRENT_DATE
|
AND bucket_date < CURRENT_DATE
|
||||||
)
|
)
|
||||||
@@ -572,11 +559,10 @@ func (r *channelMonitorRepository) ComputeAvailabilityForMonitors(ctx context.Co
|
|||||||
|
|
||||||
// ---------- 聚合维护 ----------
|
// ---------- 聚合维护 ----------
|
||||||
|
|
||||||
// UpsertDailyRollupsFor 把 targetDate 当天([targetDate, targetDate+1d))未软删的明细
|
// UpsertDailyRollupsFor 把 targetDate 当天([targetDate, targetDate+1d))的明细
|
||||||
// 按 (monitor_id, model, bucket_date) 聚合写入 channel_monitor_daily_rollups。
|
// 按 (monitor_id, model, bucket_date) 聚合写入 channel_monitor_daily_rollups。
|
||||||
// - 用 ON CONFLICT (monitor_id, model, bucket_date) DO UPDATE 实现幂等回填,
|
// - 用 ON CONFLICT (monitor_id, model, bucket_date) DO UPDATE 实现幂等回填,
|
||||||
// 重复执行只会用最新统计覆盖;
|
// 重复执行只会用最新统计覆盖;
|
||||||
// - 同时把 deleted_at 重置为 NULL,避免历史误删后聚合行被持续过滤掉;
|
|
||||||
// - $1::date 让 PG 自动把入参 truncate 到 UTC 日期,调用方不需要预处理 targetDate。
|
// - $1::date 让 PG 自动把入参 truncate 到 UTC 日期,调用方不需要预处理 targetDate。
|
||||||
func (r *channelMonitorRepository) UpsertDailyRollupsFor(ctx context.Context, targetDate time.Time) (int64, error) {
|
func (r *channelMonitorRepository) UpsertDailyRollupsFor(ctx context.Context, targetDate time.Time) (int64, error) {
|
||||||
const q = `
|
const q = `
|
||||||
@@ -604,8 +590,7 @@ func (r *channelMonitorRepository) UpsertDailyRollupsFor(ctx context.Context, ta
|
|||||||
COUNT(ping_latency_ms) AS count_ping_latency,
|
COUNT(ping_latency_ms) AS count_ping_latency,
|
||||||
NOW()
|
NOW()
|
||||||
FROM channel_monitor_histories
|
FROM channel_monitor_histories
|
||||||
WHERE deleted_at IS NULL
|
WHERE checked_at >= $1::date
|
||||||
AND checked_at >= $1::date
|
|
||||||
AND checked_at < ($1::date + INTERVAL '1 day')
|
AND checked_at < ($1::date + INTERVAL '1 day')
|
||||||
GROUP BY monitor_id, model
|
GROUP BY monitor_id, model
|
||||||
ON CONFLICT (monitor_id, model, bucket_date) DO UPDATE SET
|
ON CONFLICT (monitor_id, model, bucket_date) DO UPDATE SET
|
||||||
@@ -619,8 +604,7 @@ func (r *channelMonitorRepository) UpsertDailyRollupsFor(ctx context.Context, ta
|
|||||||
count_latency = EXCLUDED.count_latency,
|
count_latency = EXCLUDED.count_latency,
|
||||||
sum_ping_latency_ms = EXCLUDED.sum_ping_latency_ms,
|
sum_ping_latency_ms = EXCLUDED.sum_ping_latency_ms,
|
||||||
count_ping_latency = EXCLUDED.count_ping_latency,
|
count_ping_latency = EXCLUDED.count_ping_latency,
|
||||||
computed_at = NOW(),
|
computed_at = NOW()
|
||||||
deleted_at = NULL
|
|
||||||
`
|
`
|
||||||
res, err := r.db.ExecContext(ctx, q, targetDate)
|
res, err := r.db.ExecContext(ctx, q, targetDate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -633,17 +617,59 @@ func (r *channelMonitorRepository) UpsertDailyRollupsFor(ctx context.Context, ta
|
|||||||
return n, nil
|
return n, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteRollupsBefore 软删 bucket_date < beforeDate 的聚合行。
|
// DeleteRollupsBefore 物理删 bucket_date < beforeDate 的聚合行,同样分批。
|
||||||
// 走 ent client,利用 SoftDeleteMixin 把 DELETE 自动改写为 UPDATE deleted_at = NOW()。
|
|
||||||
func (r *channelMonitorRepository) DeleteRollupsBefore(ctx context.Context, beforeDate time.Time) (int64, error) {
|
func (r *channelMonitorRepository) DeleteRollupsBefore(ctx context.Context, beforeDate time.Time) (int64, error) {
|
||||||
client := clientFromContext(ctx, r.client)
|
return deleteChannelMonitorBatched(ctx, r.db, channelMonitorPruneRollupSQL, beforeDate)
|
||||||
n, err := client.ChannelMonitorDailyRollup.Delete().
|
}
|
||||||
Where(channelmonitordailyrollup.BucketDateLT(beforeDate)).
|
|
||||||
Exec(ctx)
|
// channelMonitorPruneBatchSize 单批删除上限。与 ops_cleanup_service 保持一致的 5000,
|
||||||
if err != nil {
|
// 在大表上按 id 小批删可以避免长事务和 WAL 堆积。
|
||||||
return 0, fmt.Errorf("delete rollups before: %w", err)
|
const channelMonitorPruneBatchSize = 5000
|
||||||
|
|
||||||
|
// channelMonitorPruneHistorySQL 分批物理删明细表过期行。
|
||||||
|
const channelMonitorPruneHistorySQL = `
|
||||||
|
WITH batch AS (
|
||||||
|
SELECT id FROM channel_monitor_histories
|
||||||
|
WHERE checked_at < $1
|
||||||
|
ORDER BY id
|
||||||
|
LIMIT $2
|
||||||
|
)
|
||||||
|
DELETE FROM channel_monitor_histories
|
||||||
|
WHERE id IN (SELECT id FROM batch)
|
||||||
|
`
|
||||||
|
|
||||||
|
// channelMonitorPruneRollupSQL 分批物理删 rollup 表过期行。bucket_date 需要 ::date 转型
|
||||||
|
// 保证与 DATE 列一致比较。
|
||||||
|
const channelMonitorPruneRollupSQL = `
|
||||||
|
WITH batch AS (
|
||||||
|
SELECT id FROM channel_monitor_daily_rollups
|
||||||
|
WHERE bucket_date < $1::date
|
||||||
|
ORDER BY id
|
||||||
|
LIMIT $2
|
||||||
|
)
|
||||||
|
DELETE FROM channel_monitor_daily_rollups
|
||||||
|
WHERE id IN (SELECT id FROM batch)
|
||||||
|
`
|
||||||
|
|
||||||
|
// deleteChannelMonitorBatched 循环执行分批 DELETE,直到影响行为 0。返回累计删除行数。
|
||||||
|
// cutoff 由调用方按列类型传入(明细用 time.Time 对 TIMESTAMPTZ,rollup 用 time.Time SQL 侧 ::date 转型)。
|
||||||
|
func deleteChannelMonitorBatched(ctx context.Context, db *sql.DB, query string, cutoff time.Time) (int64, error) {
|
||||||
|
var total int64
|
||||||
|
for {
|
||||||
|
res, err := db.ExecContext(ctx, query, cutoff, channelMonitorPruneBatchSize)
|
||||||
|
if err != nil {
|
||||||
|
return total, fmt.Errorf("channel_monitor prune batch: %w", err)
|
||||||
|
}
|
||||||
|
affected, err := res.RowsAffected()
|
||||||
|
if err != nil {
|
||||||
|
return total, fmt.Errorf("channel_monitor prune rows affected: %w", err)
|
||||||
|
}
|
||||||
|
total += affected
|
||||||
|
if affected == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return int64(n), nil
|
return total, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadAggregationWatermark 读 watermark 表(id=1)。
|
// LoadAggregationWatermark 读 watermark 表(id=1)。
|
||||||
|
|||||||
16
backend/migrations/127_drop_channel_monitor_deleted_at.sql
Normal file
16
backend/migrations/127_drop_channel_monitor_deleted_at.sql
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
-- Migration: 127_drop_channel_monitor_deleted_at
|
||||||
|
-- 纠正 110 引入的 SoftDeleteMixin:日志/聚合表无恢复需求,软删会让行和索引只增不减,
|
||||||
|
-- 徒增磁盘和查询开销。改回分批物理删(由 OpsCleanupService 每天凌晨统一调度,
|
||||||
|
-- deleteOldRowsByID 模板,batch=5000)。
|
||||||
|
--
|
||||||
|
-- 110 尚未跑过聚合/清理(首次 maintenance 在次日 02:00),所以此处不担心业务数据。
|
||||||
|
-- 直接 DROP 列 + 索引;对应的 Go 侧 ent schema 已移除 SoftDeleteMixin、repo 的
|
||||||
|
-- raw SQL 已移除 deleted_at IS NULL 过滤。
|
||||||
|
|
||||||
|
DROP INDEX IF EXISTS idx_channel_monitor_histories_deleted_at;
|
||||||
|
ALTER TABLE channel_monitor_histories
|
||||||
|
DROP COLUMN IF EXISTS deleted_at;
|
||||||
|
|
||||||
|
DROP INDEX IF EXISTS idx_channel_monitor_daily_rollups_deleted_at;
|
||||||
|
ALTER TABLE channel_monitor_daily_rollups
|
||||||
|
DROP COLUMN IF EXISTS deleted_at;
|
||||||
@@ -199,6 +199,28 @@ interface NavItem {
|
|||||||
* does NOT navigate to its `path`. The `path` is purely a stable key.
|
* does NOT navigate to its `path`. The `path` is purely a stable key.
|
||||||
*/
|
*/
|
||||||
expandOnly?: boolean
|
expandOnly?: boolean
|
||||||
|
/**
|
||||||
|
* 可选的功能开关 getter。返回 false 时菜单项被隐藏;返回 undefined/true 时显示。
|
||||||
|
* 宽容策略(undefined → 显示)避免 public settings 未加载完成时菜单闪烁消失。
|
||||||
|
* Getter 里访问的 reactive 来源(store / composable)会被 computed 自动追踪,
|
||||||
|
* 开关切换时菜单自动更新。
|
||||||
|
*/
|
||||||
|
featureFlag?: () => boolean | undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
// applyFeatureFlags 递归过滤掉 featureFlag() === false 的节点(含子节点)。
|
||||||
|
// 使用 `!== false` 宽容语义:undefined(设置未加载)或 true 都视为显示。
|
||||||
|
function applyFeatureFlags(items: NavItem[]): NavItem[] {
|
||||||
|
const out: NavItem[] = []
|
||||||
|
for (const item of items) {
|
||||||
|
if (item.featureFlag && item.featureFlag() === false) continue
|
||||||
|
if (item.children) {
|
||||||
|
out.push({ ...item, children: applyFeatureFlags(item.children) })
|
||||||
|
} else {
|
||||||
|
out.push(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
@@ -605,36 +627,27 @@ const ChevronDownIcon = {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// User navigation items (for regular users)
|
// 各个开关集中声明:所有菜单项引用这里的 getter,未来加新开关只需在此加一个常量。
|
||||||
const userNavItems = computed((): NavItem[] => {
|
// getter 返回 false = 隐藏;undefined/true = 显示(宽容策略,避免 public settings 未加载闪烁)。
|
||||||
const items: NavItem[] = [
|
const flagChannelMonitor = () => appStore.cachedPublicSettings?.channel_monitor_enabled
|
||||||
{ path: '/dashboard', label: t('nav.dashboard'), icon: DashboardIcon },
|
const flagPayment = () => appStore.cachedPublicSettings?.payment_enabled
|
||||||
|
const flagOpsMonitoring = () => adminSettingsStore.opsMonitoringEnabled
|
||||||
|
const flagAdminPayment = () => adminSettingsStore.paymentEnabled
|
||||||
|
|
||||||
|
// buildSelfNavItems 构造用户自己的导航项(用户端主菜单和管理员的"我的账户"子菜单共享这组声明)。
|
||||||
|
// withDashboard=true 时包含仪表盘(用户端),false 时不含(管理员的个人区已经有独立仪表盘入口)。
|
||||||
|
function buildSelfNavItems(withDashboard: boolean): NavItem[] {
|
||||||
|
const items: NavItem[] = []
|
||||||
|
if (withDashboard) {
|
||||||
|
items.push({ path: '/dashboard', label: t('nav.dashboard'), icon: DashboardIcon })
|
||||||
|
}
|
||||||
|
items.push(
|
||||||
{ path: '/keys', label: t('nav.apiKeys'), icon: KeyIcon },
|
{ path: '/keys', label: t('nav.apiKeys'), icon: KeyIcon },
|
||||||
{ path: '/usage', label: t('nav.usage'), icon: ChartIcon, hideInSimpleMode: true },
|
{ path: '/usage', label: t('nav.usage'), icon: ChartIcon, hideInSimpleMode: true },
|
||||||
...(appStore.cachedPublicSettings?.channel_monitor_enabled
|
{ path: '/monitor', label: t('nav.channelStatus'), icon: SignalIcon, featureFlag: flagChannelMonitor },
|
||||||
? [{ path: '/monitor', label: t('nav.channelStatus'), icon: SignalIcon }]
|
|
||||||
: []),
|
|
||||||
{ path: '/subscriptions', label: t('nav.mySubscriptions'), icon: CreditCardIcon, hideInSimpleMode: true },
|
{ path: '/subscriptions', label: t('nav.mySubscriptions'), icon: CreditCardIcon, hideInSimpleMode: true },
|
||||||
...(appStore.cachedPublicSettings?.payment_enabled
|
{ path: '/purchase', label: t('nav.buySubscription'), icon: RechargeSubscriptionIcon, hideInSimpleMode: true, featureFlag: flagPayment },
|
||||||
? [
|
{ path: '/orders', label: t('nav.myOrders'), icon: OrderListIcon, hideInSimpleMode: true, featureFlag: flagPayment },
|
||||||
{
|
|
||||||
path: '/purchase',
|
|
||||||
label: t('nav.buySubscription'),
|
|
||||||
icon: RechargeSubscriptionIcon,
|
|
||||||
hideInSimpleMode: true
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
...(appStore.cachedPublicSettings?.payment_enabled
|
|
||||||
? [
|
|
||||||
{
|
|
||||||
path: '/orders',
|
|
||||||
label: t('nav.myOrders'),
|
|
||||||
icon: OrderListIcon,
|
|
||||||
hideInSimpleMode: true
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
{ path: '/redeem', label: t('nav.redeem'), icon: GiftIcon, hideInSimpleMode: true },
|
{ path: '/redeem', label: t('nav.redeem'), icon: GiftIcon, hideInSimpleMode: true },
|
||||||
{ path: '/profile', label: t('nav.profile'), icon: UserIcon },
|
{ path: '/profile', label: t('nav.profile'), icon: UserIcon },
|
||||||
...customMenuItemsForUser.value.map((item): NavItem => ({
|
...customMenuItemsForUser.value.map((item): NavItem => ({
|
||||||
@@ -643,50 +656,21 @@ const userNavItems = computed((): NavItem[] => {
|
|||||||
icon: null,
|
icon: null,
|
||||||
iconSvg: item.icon_svg,
|
iconSvg: item.icon_svg,
|
||||||
})),
|
})),
|
||||||
]
|
)
|
||||||
return authStore.isSimpleMode ? items.filter(item => !item.hideInSimpleMode) : items
|
return items
|
||||||
})
|
}
|
||||||
|
|
||||||
|
// finalizeNav 合并三重过滤:featureFlag 过滤 + simple 模式过滤。
|
||||||
|
function finalizeNav(items: NavItem[]): NavItem[] {
|
||||||
|
const visible = applyFeatureFlags(items)
|
||||||
|
return authStore.isSimpleMode ? visible.filter(item => !item.hideInSimpleMode) : visible
|
||||||
|
}
|
||||||
|
|
||||||
|
// User navigation items (for regular users)
|
||||||
|
const userNavItems = computed((): NavItem[] => finalizeNav(buildSelfNavItems(true)))
|
||||||
|
|
||||||
// Personal navigation items (for admin's "My Account" section, without Dashboard)
|
// Personal navigation items (for admin's "My Account" section, without Dashboard)
|
||||||
const personalNavItems = computed((): NavItem[] => {
|
const personalNavItems = computed((): NavItem[] => finalizeNav(buildSelfNavItems(false)))
|
||||||
const items: NavItem[] = [
|
|
||||||
{ path: '/keys', label: t('nav.apiKeys'), icon: KeyIcon },
|
|
||||||
{ path: '/usage', label: t('nav.usage'), icon: ChartIcon, hideInSimpleMode: true },
|
|
||||||
...(appStore.cachedPublicSettings?.channel_monitor_enabled
|
|
||||||
? [{ path: '/monitor', label: t('nav.channelStatus'), icon: SignalIcon }]
|
|
||||||
: []),
|
|
||||||
{ path: '/subscriptions', label: t('nav.mySubscriptions'), icon: CreditCardIcon, hideInSimpleMode: true },
|
|
||||||
...(appStore.cachedPublicSettings?.payment_enabled
|
|
||||||
? [
|
|
||||||
{
|
|
||||||
path: '/purchase',
|
|
||||||
label: t('nav.buySubscription'),
|
|
||||||
icon: RechargeSubscriptionIcon,
|
|
||||||
hideInSimpleMode: true
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
...(appStore.cachedPublicSettings?.payment_enabled
|
|
||||||
? [
|
|
||||||
{
|
|
||||||
path: '/orders',
|
|
||||||
label: t('nav.myOrders'),
|
|
||||||
icon: OrderListIcon,
|
|
||||||
hideInSimpleMode: true
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
{ path: '/redeem', label: t('nav.redeem'), icon: GiftIcon, hideInSimpleMode: true },
|
|
||||||
{ path: '/profile', label: t('nav.profile'), icon: UserIcon },
|
|
||||||
...customMenuItemsForUser.value.map((item): NavItem => ({
|
|
||||||
path: `/custom/${item.id}`,
|
|
||||||
label: item.label,
|
|
||||||
icon: null,
|
|
||||||
iconSvg: item.icon_svg,
|
|
||||||
})),
|
|
||||||
]
|
|
||||||
return authStore.isSimpleMode ? items.filter(item => !item.hideInSimpleMode) : items
|
|
||||||
})
|
|
||||||
|
|
||||||
// Custom menu items filtered by visibility
|
// Custom menu items filtered by visibility
|
||||||
const customMenuItemsForUser = computed(() => {
|
const customMenuItemsForUser = computed(() => {
|
||||||
@@ -706,9 +690,7 @@ const customMenuItemsForAdmin = computed(() => {
|
|||||||
const adminNavItems = computed((): NavItem[] => {
|
const adminNavItems = computed((): NavItem[] => {
|
||||||
const baseItems: NavItem[] = [
|
const baseItems: NavItem[] = [
|
||||||
{ path: '/admin/dashboard', label: t('nav.dashboard'), icon: DashboardIcon },
|
{ path: '/admin/dashboard', label: t('nav.dashboard'), icon: DashboardIcon },
|
||||||
...(adminSettingsStore.opsMonitoringEnabled
|
{ path: '/admin/ops', label: t('nav.ops'), icon: ChartIcon, featureFlag: flagOpsMonitoring },
|
||||||
? [{ path: '/admin/ops', label: t('nav.ops'), icon: ChartIcon }]
|
|
||||||
: []),
|
|
||||||
{ path: '/admin/users', label: t('nav.users'), icon: UsersIcon, hideInSimpleMode: true },
|
{ path: '/admin/users', label: t('nav.users'), icon: UsersIcon, hideInSimpleMode: true },
|
||||||
{ path: '/admin/groups', label: t('nav.groups'), icon: FolderIcon, hideInSimpleMode: true },
|
{ path: '/admin/groups', label: t('nav.groups'), icon: FolderIcon, hideInSimpleMode: true },
|
||||||
{
|
{
|
||||||
@@ -719,9 +701,7 @@ const adminNavItems = computed((): NavItem[] => {
|
|||||||
expandOnly: true,
|
expandOnly: true,
|
||||||
children: [
|
children: [
|
||||||
{ path: '/admin/channels/pricing', label: t('nav.channelPricing'), icon: PriceTagIcon },
|
{ path: '/admin/channels/pricing', label: t('nav.channelPricing'), icon: PriceTagIcon },
|
||||||
...(appStore.cachedPublicSettings?.channel_monitor_enabled
|
{ path: '/admin/channels/monitor', label: t('nav.channelMonitor'), icon: SignalIcon, featureFlag: flagChannelMonitor },
|
||||||
? [{ path: '/admin/channels/monitor', label: t('nav.channelMonitor'), icon: SignalIcon }]
|
|
||||||
: []),
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{ path: '/admin/subscriptions', label: t('nav.subscriptions'), icon: CreditCardIcon, hideInSimpleMode: true },
|
{ path: '/admin/subscriptions', label: t('nav.subscriptions'), icon: CreditCardIcon, hideInSimpleMode: true },
|
||||||
@@ -730,43 +710,40 @@ const adminNavItems = computed((): NavItem[] => {
|
|||||||
{ path: '/admin/proxies', label: t('nav.proxies'), icon: ServerIcon },
|
{ path: '/admin/proxies', label: t('nav.proxies'), icon: ServerIcon },
|
||||||
{ path: '/admin/redeem', label: t('nav.redeemCodes'), icon: TicketIcon, hideInSimpleMode: true },
|
{ path: '/admin/redeem', label: t('nav.redeemCodes'), icon: TicketIcon, hideInSimpleMode: true },
|
||||||
{ path: '/admin/promo-codes', label: t('nav.promoCodes'), icon: GiftIcon, hideInSimpleMode: true },
|
{ path: '/admin/promo-codes', label: t('nav.promoCodes'), icon: GiftIcon, hideInSimpleMode: true },
|
||||||
...(adminSettingsStore.paymentEnabled
|
{
|
||||||
? [
|
path: '/admin/orders',
|
||||||
{
|
label: t('nav.orderManagement'),
|
||||||
path: '/admin/orders',
|
icon: OrderIcon,
|
||||||
label: t('nav.orderManagement'),
|
hideInSimpleMode: true,
|
||||||
icon: OrderIcon,
|
expandOnly: true,
|
||||||
hideInSimpleMode: true,
|
featureFlag: flagAdminPayment,
|
||||||
expandOnly: true,
|
children: [
|
||||||
children: [
|
{ path: '/admin/orders/dashboard', label: t('nav.paymentDashboard'), icon: ChartIcon },
|
||||||
{ path: '/admin/orders/dashboard', label: t('nav.paymentDashboard'), icon: ChartIcon },
|
{ path: '/admin/orders', label: t('nav.orderManagement'), icon: OrderIcon },
|
||||||
{ path: '/admin/orders', label: t('nav.orderManagement'), icon: OrderIcon },
|
{ path: '/admin/orders/plans', label: t('nav.paymentPlans'), icon: CreditCardIcon },
|
||||||
{ path: '/admin/orders/plans', label: t('nav.paymentPlans'), icon: CreditCardIcon },
|
],
|
||||||
],
|
},
|
||||||
},
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
{ path: '/admin/usage', label: t('nav.usage'), icon: ChartIcon }
|
{ path: '/admin/usage', label: t('nav.usage'), icon: ChartIcon }
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const visible = applyFeatureFlags(baseItems)
|
||||||
|
|
||||||
// 简单模式下,在系统设置前插入 API密钥
|
// 简单模式下,在系统设置前插入 API密钥
|
||||||
if (authStore.isSimpleMode) {
|
if (authStore.isSimpleMode) {
|
||||||
const filtered = baseItems.filter(item => !item.hideInSimpleMode)
|
const filtered = visible.filter(item => !item.hideInSimpleMode)
|
||||||
filtered.push({ path: '/keys', label: t('nav.apiKeys'), icon: KeyIcon })
|
filtered.push({ path: '/keys', label: t('nav.apiKeys'), icon: KeyIcon })
|
||||||
filtered.push({ path: '/admin/settings', label: t('nav.settings'), icon: CogIcon })
|
filtered.push({ path: '/admin/settings', label: t('nav.settings'), icon: CogIcon })
|
||||||
// Add admin custom menu items after settings
|
|
||||||
for (const cm of customMenuItemsForAdmin.value) {
|
for (const cm of customMenuItemsForAdmin.value) {
|
||||||
filtered.push({ path: `/custom/${cm.id}`, label: cm.label, icon: null, iconSvg: cm.icon_svg })
|
filtered.push({ path: `/custom/${cm.id}`, label: cm.label, icon: null, iconSvg: cm.icon_svg })
|
||||||
}
|
}
|
||||||
return filtered
|
return filtered
|
||||||
}
|
}
|
||||||
|
|
||||||
baseItems.push({ path: '/admin/settings', label: t('nav.settings'), icon: CogIcon })
|
visible.push({ path: '/admin/settings', label: t('nav.settings'), icon: CogIcon })
|
||||||
// Add admin custom menu items after settings
|
|
||||||
for (const cm of customMenuItemsForAdmin.value) {
|
for (const cm of customMenuItemsForAdmin.value) {
|
||||||
baseItems.push({ path: `/custom/${cm.id}`, label: cm.label, icon: null, iconSvg: cm.icon_svg })
|
visible.push({ path: `/custom/${cm.id}`, label: cm.label, icon: null, iconSvg: cm.icon_svg })
|
||||||
}
|
}
|
||||||
return baseItems
|
return visible
|
||||||
})
|
})
|
||||||
|
|
||||||
function toggleSidebar() {
|
function toggleSidebar() {
|
||||||
|
|||||||
Reference in New Issue
Block a user