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:"-"`
|
||||
// ID of the ent.
|
||||
ID int64 `json:"id,omitempty"`
|
||||
// DeletedAt holds the value of the "deleted_at" field.
|
||||
DeletedAt *time.Time `json:"deleted_at,omitempty"`
|
||||
// MonitorID holds the value of the "monitor_id" field.
|
||||
MonitorID int64 `json:"monitor_id,omitempty"`
|
||||
// Model holds the value of the "model" field.
|
||||
@@ -83,7 +81,7 @@ func (*ChannelMonitorDailyRollup) scanValues(columns []string) ([]any, error) {
|
||||
values[i] = new(sql.NullInt64)
|
||||
case channelmonitordailyrollup.FieldModel:
|
||||
values[i] = new(sql.NullString)
|
||||
case channelmonitordailyrollup.FieldDeletedAt, channelmonitordailyrollup.FieldBucketDate, channelmonitordailyrollup.FieldComputedAt:
|
||||
case channelmonitordailyrollup.FieldBucketDate, channelmonitordailyrollup.FieldComputedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
default:
|
||||
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)
|
||||
}
|
||||
_m.ID = int64(value.Int64)
|
||||
case channelmonitordailyrollup.FieldDeletedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.DeletedAt = new(time.Time)
|
||||
*_m.DeletedAt = value.Time
|
||||
}
|
||||
case channelmonitordailyrollup.FieldMonitorID:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field monitor_id", values[i])
|
||||
@@ -238,11 +229,6 @@ func (_m *ChannelMonitorDailyRollup) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("ChannelMonitorDailyRollup(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
if v := _m.DeletedAt; v != nil {
|
||||
builder.WriteString("deleted_at=")
|
||||
builder.WriteString(v.Format(time.ANSIC))
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("monitor_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.MonitorID))
|
||||
builder.WriteString(", ")
|
||||
|
||||
@@ -5,7 +5,6 @@ package channelmonitordailyrollup
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
@@ -15,8 +14,6 @@ const (
|
||||
Label = "channel_monitor_daily_rollup"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldDeletedAt holds the string denoting the deleted_at field in the database.
|
||||
FieldDeletedAt = "deleted_at"
|
||||
// FieldMonitorID holds the string denoting the monitor_id field in the database.
|
||||
FieldMonitorID = "monitor_id"
|
||||
// FieldModel holds the string denoting the model field in the database.
|
||||
@@ -61,7 +58,6 @@ const (
|
||||
// Columns holds all SQL columns for channelmonitordailyrollup fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldDeletedAt,
|
||||
FieldMonitorID,
|
||||
FieldModel,
|
||||
FieldBucketDate,
|
||||
@@ -88,14 +84,7 @@ func ValidColumn(column string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Note that the variables below are initialized by the runtime
|
||||
// package on the initialization of the application. Therefore,
|
||||
// it should be imported in the main as follows:
|
||||
//
|
||||
// import _ "github.com/Wei-Shaw/sub2api/ent/runtime"
|
||||
var (
|
||||
Hooks [1]ent.Hook
|
||||
Interceptors [1]ent.Interceptor
|
||||
// ModelValidator is a validator for the "model" field. It is called by the builders before save.
|
||||
ModelValidator func(string) error
|
||||
// DefaultTotalChecks holds the default value on creation for the "total_checks" field.
|
||||
@@ -132,11 +121,6 @@ func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDeletedAt orders the results by the deleted_at field.
|
||||
func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByMonitorID orders the results by the monitor_id field.
|
||||
func ByMonitorID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldMonitorID, opts...).ToFunc()
|
||||
|
||||
@@ -55,11 +55,6 @@ func IDLTE(id int64) predicate.ChannelMonitorDailyRollup {
|
||||
return predicate.ChannelMonitorDailyRollup(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ.
|
||||
func DeletedAt(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldDeletedAt, v))
|
||||
}
|
||||
|
||||
// MonitorID applies equality check predicate on the "monitor_id" field. It's identical to MonitorIDEQ.
|
||||
func MonitorID(v int64) predicate.ChannelMonitorDailyRollup {
|
||||
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldMonitorID, v))
|
||||
@@ -130,56 +125,6 @@ func ComputedAt(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldComputedAt, v))
|
||||
}
|
||||
|
||||
// DeletedAtEQ applies the EQ predicate on the "deleted_at" field.
|
||||
func DeletedAtEQ(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldDeletedAt, v))
|
||||
}
|
||||
|
||||
// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field.
|
||||
func DeletedAtNEQ(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||
return predicate.ChannelMonitorDailyRollup(sql.FieldNEQ(FieldDeletedAt, v))
|
||||
}
|
||||
|
||||
// DeletedAtIn applies the In predicate on the "deleted_at" field.
|
||||
func DeletedAtIn(vs ...time.Time) predicate.ChannelMonitorDailyRollup {
|
||||
return predicate.ChannelMonitorDailyRollup(sql.FieldIn(FieldDeletedAt, vs...))
|
||||
}
|
||||
|
||||
// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field.
|
||||
func DeletedAtNotIn(vs ...time.Time) predicate.ChannelMonitorDailyRollup {
|
||||
return predicate.ChannelMonitorDailyRollup(sql.FieldNotIn(FieldDeletedAt, vs...))
|
||||
}
|
||||
|
||||
// DeletedAtGT applies the GT predicate on the "deleted_at" field.
|
||||
func DeletedAtGT(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||
return predicate.ChannelMonitorDailyRollup(sql.FieldGT(FieldDeletedAt, v))
|
||||
}
|
||||
|
||||
// DeletedAtGTE applies the GTE predicate on the "deleted_at" field.
|
||||
func DeletedAtGTE(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||
return predicate.ChannelMonitorDailyRollup(sql.FieldGTE(FieldDeletedAt, v))
|
||||
}
|
||||
|
||||
// DeletedAtLT applies the LT predicate on the "deleted_at" field.
|
||||
func DeletedAtLT(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||
return predicate.ChannelMonitorDailyRollup(sql.FieldLT(FieldDeletedAt, v))
|
||||
}
|
||||
|
||||
// DeletedAtLTE applies the LTE predicate on the "deleted_at" field.
|
||||
func DeletedAtLTE(v time.Time) predicate.ChannelMonitorDailyRollup {
|
||||
return predicate.ChannelMonitorDailyRollup(sql.FieldLTE(FieldDeletedAt, v))
|
||||
}
|
||||
|
||||
// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field.
|
||||
func DeletedAtIsNil() predicate.ChannelMonitorDailyRollup {
|
||||
return predicate.ChannelMonitorDailyRollup(sql.FieldIsNull(FieldDeletedAt))
|
||||
}
|
||||
|
||||
// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field.
|
||||
func DeletedAtNotNil() predicate.ChannelMonitorDailyRollup {
|
||||
return predicate.ChannelMonitorDailyRollup(sql.FieldNotNull(FieldDeletedAt))
|
||||
}
|
||||
|
||||
// MonitorIDEQ applies the EQ predicate on the "monitor_id" field.
|
||||
func MonitorIDEQ(v int64) predicate.ChannelMonitorDailyRollup {
|
||||
return predicate.ChannelMonitorDailyRollup(sql.FieldEQ(FieldMonitorID, v))
|
||||
|
||||
@@ -23,20 +23,6 @@ type ChannelMonitorDailyRollupCreate struct {
|
||||
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.
|
||||
func (_c *ChannelMonitorDailyRollupCreate) SetMonitorID(v int64) *ChannelMonitorDailyRollupCreate {
|
||||
_c.mutation.SetMonitorID(v)
|
||||
@@ -221,9 +207,7 @@ func (_c *ChannelMonitorDailyRollupCreate) Mutation() *ChannelMonitorDailyRollup
|
||||
|
||||
// Save creates the ChannelMonitorDailyRollup in the database.
|
||||
func (_c *ChannelMonitorDailyRollupCreate) Save(ctx context.Context) (*ChannelMonitorDailyRollup, error) {
|
||||
if err := _c.defaults(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_c.defaults()
|
||||
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.
|
||||
func (_c *ChannelMonitorDailyRollupCreate) defaults() error {
|
||||
func (_c *ChannelMonitorDailyRollupCreate) defaults() {
|
||||
if _, ok := _c.mutation.TotalChecks(); !ok {
|
||||
v := channelmonitordailyrollup.DefaultTotalChecks
|
||||
_c.mutation.SetTotalChecks(v)
|
||||
@@ -292,13 +276,9 @@ func (_c *ChannelMonitorDailyRollupCreate) defaults() error {
|
||||
_c.mutation.SetCountPingLatency(v)
|
||||
}
|
||||
if _, ok := _c.mutation.ComputedAt(); !ok {
|
||||
if channelmonitordailyrollup.DefaultComputedAt == nil {
|
||||
return fmt.Errorf("ent: uninitialized channelmonitordailyrollup.DefaultComputedAt (forgotten import ent/runtime?)")
|
||||
}
|
||||
v := channelmonitordailyrollup.DefaultComputedAt()
|
||||
_c.mutation.SetComputedAt(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 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.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 {
|
||||
_spec.SetField(channelmonitordailyrollup.FieldModel, field.TypeString, value)
|
||||
_node.Model = value
|
||||
@@ -460,7 +436,7 @@ func (_c *ChannelMonitorDailyRollupCreate) createSpec() (*ChannelMonitorDailyRol
|
||||
// of the `INSERT` statement. For example:
|
||||
//
|
||||
// client.ChannelMonitorDailyRollup.Create().
|
||||
// SetDeletedAt(v).
|
||||
// SetMonitorID(v).
|
||||
// OnConflict(
|
||||
// // Update the row with the new values
|
||||
// // the was proposed for insertion.
|
||||
@@ -469,7 +445,7 @@ func (_c *ChannelMonitorDailyRollupCreate) createSpec() (*ChannelMonitorDailyRol
|
||||
// // Override some of the fields with custom
|
||||
// // update values.
|
||||
// Update(func(u *ent.ChannelMonitorDailyRollupUpsert) {
|
||||
// SetDeletedAt(v+v).
|
||||
// SetMonitorID(v+v).
|
||||
// }).
|
||||
// Exec(ctx)
|
||||
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.
|
||||
func (u *ChannelMonitorDailyRollupUpsert) SetMonitorID(v int64) *ChannelMonitorDailyRollupUpsert {
|
||||
u.Set(channelmonitordailyrollup.FieldMonitorID, v)
|
||||
@@ -791,27 +749,6 @@ func (u *ChannelMonitorDailyRollupUpsertOne) Update(set func(*ChannelMonitorDail
|
||||
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.
|
||||
func (u *ChannelMonitorDailyRollupUpsertOne) SetMonitorID(v int64) *ChannelMonitorDailyRollupUpsertOne {
|
||||
return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
|
||||
@@ -1213,7 +1150,7 @@ func (_c *ChannelMonitorDailyRollupCreateBulk) ExecX(ctx context.Context) {
|
||||
// // Override some of the fields with custom
|
||||
// // update values.
|
||||
// Update(func(u *ent.ChannelMonitorDailyRollupUpsert) {
|
||||
// SetDeletedAt(v+v).
|
||||
// SetMonitorID(v+v).
|
||||
// }).
|
||||
// Exec(ctx)
|
||||
func (_c *ChannelMonitorDailyRollupCreateBulk) OnConflict(opts ...sql.ConflictOption) *ChannelMonitorDailyRollupUpsertBulk {
|
||||
@@ -1282,27 +1219,6 @@ func (u *ChannelMonitorDailyRollupUpsertBulk) Update(set func(*ChannelMonitorDai
|
||||
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.
|
||||
func (u *ChannelMonitorDailyRollupUpsertBulk) SetMonitorID(v int64) *ChannelMonitorDailyRollupUpsertBulk {
|
||||
return u.Update(func(s *ChannelMonitorDailyRollupUpsert) {
|
||||
|
||||
@@ -300,12 +300,12 @@ func (_q *ChannelMonitorDailyRollupQuery) WithMonitor(opts ...func(*ChannelMonit
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// DeletedAt time.Time `json:"deleted_at,omitempty"`
|
||||
// MonitorID int64 `json:"monitor_id,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.ChannelMonitorDailyRollup.Query().
|
||||
// GroupBy(channelmonitordailyrollup.FieldDeletedAt).
|
||||
// GroupBy(channelmonitordailyrollup.FieldMonitorID).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *ChannelMonitorDailyRollupQuery) GroupBy(field string, fields ...string) *ChannelMonitorDailyRollupGroupBy {
|
||||
@@ -323,11 +323,11 @@ func (_q *ChannelMonitorDailyRollupQuery) GroupBy(field string, fields ...string
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// DeletedAt time.Time `json:"deleted_at,omitempty"`
|
||||
// MonitorID int64 `json:"monitor_id,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.ChannelMonitorDailyRollup.Query().
|
||||
// Select(channelmonitordailyrollup.FieldDeletedAt).
|
||||
// Select(channelmonitordailyrollup.FieldMonitorID).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *ChannelMonitorDailyRollupQuery) Select(fields ...string) *ChannelMonitorDailyRollupSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
|
||||
@@ -29,26 +29,6 @@ func (_u *ChannelMonitorDailyRollupUpdate) Where(ps ...predicate.ChannelMonitorD
|
||||
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.
|
||||
func (_u *ChannelMonitorDailyRollupUpdate) SetMonitorID(v int64) *ChannelMonitorDailyRollupUpdate {
|
||||
_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.
|
||||
func (_u *ChannelMonitorDailyRollupUpdate) Save(ctx context.Context) (int, error) {
|
||||
if err := _u.defaults(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
_u.defaults()
|
||||
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.
|
||||
func (_u *ChannelMonitorDailyRollupUpdate) defaults() error {
|
||||
func (_u *ChannelMonitorDailyRollupUpdate) defaults() {
|
||||
if _, ok := _u.mutation.ComputedAt(); !ok {
|
||||
if channelmonitordailyrollup.UpdateDefaultComputedAt == nil {
|
||||
return fmt.Errorf("ent: uninitialized channelmonitordailyrollup.UpdateDefaultComputedAt (forgotten import ent/runtime?)")
|
||||
}
|
||||
v := channelmonitordailyrollup.UpdateDefaultComputedAt()
|
||||
_u.mutation.SetComputedAt(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 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 {
|
||||
_spec.SetField(channelmonitordailyrollup.FieldModel, field.TypeString, value)
|
||||
}
|
||||
@@ -514,26 +482,6 @@ type ChannelMonitorDailyRollupUpdateOne struct {
|
||||
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.
|
||||
func (_u *ChannelMonitorDailyRollupUpdateOne) SetMonitorID(v int64) *ChannelMonitorDailyRollupUpdateOne {
|
||||
_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.
|
||||
func (_u *ChannelMonitorDailyRollupUpdateOne) Save(ctx context.Context) (*ChannelMonitorDailyRollup, error) {
|
||||
if err := _u.defaults(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_u.defaults()
|
||||
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.
|
||||
func (_u *ChannelMonitorDailyRollupUpdateOne) defaults() error {
|
||||
func (_u *ChannelMonitorDailyRollupUpdateOne) defaults() {
|
||||
if _, ok := _u.mutation.ComputedAt(); !ok {
|
||||
if channelmonitordailyrollup.UpdateDefaultComputedAt == nil {
|
||||
return fmt.Errorf("ent: uninitialized channelmonitordailyrollup.UpdateDefaultComputedAt (forgotten import ent/runtime?)")
|
||||
}
|
||||
v := channelmonitordailyrollup.UpdateDefaultComputedAt()
|
||||
_u.mutation.SetComputedAt(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 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 {
|
||||
_spec.SetField(channelmonitordailyrollup.FieldModel, field.TypeString, value)
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ type ChannelMonitorHistory struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int64 `json:"id,omitempty"`
|
||||
// DeletedAt holds the value of the "deleted_at" field.
|
||||
DeletedAt *time.Time `json:"deleted_at,omitempty"`
|
||||
// MonitorID holds the value of the "monitor_id" field.
|
||||
MonitorID int64 `json:"monitor_id,omitempty"`
|
||||
// Model holds the value of the "model" field.
|
||||
@@ -69,7 +67,7 @@ func (*ChannelMonitorHistory) scanValues(columns []string) ([]any, error) {
|
||||
values[i] = new(sql.NullInt64)
|
||||
case channelmonitorhistory.FieldModel, channelmonitorhistory.FieldStatus, channelmonitorhistory.FieldMessage:
|
||||
values[i] = new(sql.NullString)
|
||||
case channelmonitorhistory.FieldDeletedAt, channelmonitorhistory.FieldCheckedAt:
|
||||
case channelmonitorhistory.FieldCheckedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
default:
|
||||
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)
|
||||
}
|
||||
_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:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
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
|
||||
builder.WriteString("ChannelMonitorHistory(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
if v := _m.DeletedAt; v != nil {
|
||||
builder.WriteString("deleted_at=")
|
||||
builder.WriteString(v.Format(time.ANSIC))
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("monitor_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.MonitorID))
|
||||
builder.WriteString(", ")
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
@@ -16,8 +15,6 @@ const (
|
||||
Label = "channel_monitor_history"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldDeletedAt holds the string denoting the deleted_at field in the database.
|
||||
FieldDeletedAt = "deleted_at"
|
||||
// FieldMonitorID holds the string denoting the monitor_id field in the database.
|
||||
FieldMonitorID = "monitor_id"
|
||||
// FieldModel holds the string denoting the model field in the database.
|
||||
@@ -48,7 +45,6 @@ const (
|
||||
// Columns holds all SQL columns for channelmonitorhistory fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldDeletedAt,
|
||||
FieldMonitorID,
|
||||
FieldModel,
|
||||
FieldStatus,
|
||||
@@ -68,14 +64,7 @@ func ValidColumn(column string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Note that the variables below are initialized by the runtime
|
||||
// package on the initialization of the application. Therefore,
|
||||
// it should be imported in the main as follows:
|
||||
//
|
||||
// import _ "github.com/Wei-Shaw/sub2api/ent/runtime"
|
||||
var (
|
||||
Hooks [1]ent.Hook
|
||||
Interceptors [1]ent.Interceptor
|
||||
// ModelValidator is a validator for the "model" field. It is called by the builders before save.
|
||||
ModelValidator func(string) error
|
||||
// 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()
|
||||
}
|
||||
|
||||
// ByDeletedAt orders the results by the deleted_at field.
|
||||
func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByMonitorID orders the results by the monitor_id field.
|
||||
func ByMonitorID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldMonitorID, opts...).ToFunc()
|
||||
|
||||
@@ -55,11 +55,6 @@ func IDLTE(id int64) predicate.ChannelMonitorHistory {
|
||||
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.
|
||||
func MonitorID(v int64) predicate.ChannelMonitorHistory {
|
||||
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))
|
||||
}
|
||||
|
||||
// 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.
|
||||
func MonitorIDEQ(v int64) predicate.ChannelMonitorHistory {
|
||||
return predicate.ChannelMonitorHistory(sql.FieldEQ(FieldMonitorID, v))
|
||||
|
||||
@@ -23,20 +23,6 @@ type ChannelMonitorHistoryCreate struct {
|
||||
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.
|
||||
func (_c *ChannelMonitorHistoryCreate) SetMonitorID(v int64) *ChannelMonitorHistoryCreate {
|
||||
_c.mutation.SetMonitorID(v)
|
||||
@@ -123,9 +109,7 @@ func (_c *ChannelMonitorHistoryCreate) Mutation() *ChannelMonitorHistoryMutation
|
||||
|
||||
// Save creates the ChannelMonitorHistory in the database.
|
||||
func (_c *ChannelMonitorHistoryCreate) Save(ctx context.Context) (*ChannelMonitorHistory, error) {
|
||||
if err := _c.defaults(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_c.defaults()
|
||||
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.
|
||||
func (_c *ChannelMonitorHistoryCreate) defaults() error {
|
||||
func (_c *ChannelMonitorHistoryCreate) defaults() {
|
||||
if _, ok := _c.mutation.Message(); !ok {
|
||||
v := channelmonitorhistory.DefaultMessage
|
||||
_c.mutation.SetMessage(v)
|
||||
}
|
||||
if _, ok := _c.mutation.CheckedAt(); !ok {
|
||||
if channelmonitorhistory.DefaultCheckedAt == nil {
|
||||
return fmt.Errorf("ent: uninitialized channelmonitorhistory.DefaultCheckedAt (forgotten import ent/runtime?)")
|
||||
}
|
||||
v := channelmonitorhistory.DefaultCheckedAt()
|
||||
_c.mutation.SetCheckedAt(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 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.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 {
|
||||
_spec.SetField(channelmonitorhistory.FieldModel, field.TypeString, value)
|
||||
_node.Model = value
|
||||
@@ -278,7 +254,7 @@ func (_c *ChannelMonitorHistoryCreate) createSpec() (*ChannelMonitorHistory, *sq
|
||||
// of the `INSERT` statement. For example:
|
||||
//
|
||||
// client.ChannelMonitorHistory.Create().
|
||||
// SetDeletedAt(v).
|
||||
// SetMonitorID(v).
|
||||
// OnConflict(
|
||||
// // Update the row with the new values
|
||||
// // the was proposed for insertion.
|
||||
@@ -287,7 +263,7 @@ func (_c *ChannelMonitorHistoryCreate) createSpec() (*ChannelMonitorHistory, *sq
|
||||
// // Override some of the fields with custom
|
||||
// // update values.
|
||||
// Update(func(u *ent.ChannelMonitorHistoryUpsert) {
|
||||
// SetDeletedAt(v+v).
|
||||
// SetMonitorID(v+v).
|
||||
// }).
|
||||
// Exec(ctx)
|
||||
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.
|
||||
func (u *ChannelMonitorHistoryUpsert) SetMonitorID(v int64) *ChannelMonitorHistoryUpsert {
|
||||
u.Set(channelmonitorhistory.FieldMonitorID, v)
|
||||
@@ -495,27 +453,6 @@ func (u *ChannelMonitorHistoryUpsertOne) Update(set func(*ChannelMonitorHistoryU
|
||||
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.
|
||||
func (u *ChannelMonitorHistoryUpsertOne) SetMonitorID(v int64) *ChannelMonitorHistoryUpsertOne {
|
||||
return u.Update(func(s *ChannelMonitorHistoryUpsert) {
|
||||
@@ -784,7 +721,7 @@ func (_c *ChannelMonitorHistoryCreateBulk) ExecX(ctx context.Context) {
|
||||
// // Override some of the fields with custom
|
||||
// // update values.
|
||||
// Update(func(u *ent.ChannelMonitorHistoryUpsert) {
|
||||
// SetDeletedAt(v+v).
|
||||
// SetMonitorID(v+v).
|
||||
// }).
|
||||
// Exec(ctx)
|
||||
func (_c *ChannelMonitorHistoryCreateBulk) OnConflict(opts ...sql.ConflictOption) *ChannelMonitorHistoryUpsertBulk {
|
||||
@@ -853,27 +790,6 @@ func (u *ChannelMonitorHistoryUpsertBulk) Update(set func(*ChannelMonitorHistory
|
||||
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.
|
||||
func (u *ChannelMonitorHistoryUpsertBulk) SetMonitorID(v int64) *ChannelMonitorHistoryUpsertBulk {
|
||||
return u.Update(func(s *ChannelMonitorHistoryUpsert) {
|
||||
|
||||
@@ -300,12 +300,12 @@ func (_q *ChannelMonitorHistoryQuery) WithMonitor(opts ...func(*ChannelMonitorQu
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// DeletedAt time.Time `json:"deleted_at,omitempty"`
|
||||
// MonitorID int64 `json:"monitor_id,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.ChannelMonitorHistory.Query().
|
||||
// GroupBy(channelmonitorhistory.FieldDeletedAt).
|
||||
// GroupBy(channelmonitorhistory.FieldMonitorID).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *ChannelMonitorHistoryQuery) GroupBy(field string, fields ...string) *ChannelMonitorHistoryGroupBy {
|
||||
@@ -323,11 +323,11 @@ func (_q *ChannelMonitorHistoryQuery) GroupBy(field string, fields ...string) *C
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// DeletedAt time.Time `json:"deleted_at,omitempty"`
|
||||
// MonitorID int64 `json:"monitor_id,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.ChannelMonitorHistory.Query().
|
||||
// Select(channelmonitorhistory.FieldDeletedAt).
|
||||
// Select(channelmonitorhistory.FieldMonitorID).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *ChannelMonitorHistoryQuery) Select(fields ...string) *ChannelMonitorHistorySelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
|
||||
@@ -29,26 +29,6 @@ func (_u *ChannelMonitorHistoryUpdate) Where(ps ...predicate.ChannelMonitorHisto
|
||||
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.
|
||||
func (_u *ChannelMonitorHistoryUpdate) SetMonitorID(v int64) *ChannelMonitorHistoryUpdate {
|
||||
_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 {
|
||||
_spec.SetField(channelmonitorhistory.FieldModel, field.TypeString, value)
|
||||
}
|
||||
@@ -345,26 +319,6 @@ type ChannelMonitorHistoryUpdateOne struct {
|
||||
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.
|
||||
func (_u *ChannelMonitorHistoryUpdateOne) SetMonitorID(v int64) *ChannelMonitorHistoryUpdateOne {
|
||||
_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 {
|
||||
_spec.SetField(channelmonitorhistory.FieldModel, field.TypeString, value)
|
||||
}
|
||||
|
||||
@@ -1912,14 +1912,12 @@ func (c *ChannelMonitorDailyRollupClient) QueryMonitor(_m *ChannelMonitorDailyRo
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *ChannelMonitorDailyRollupClient) Hooks() []Hook {
|
||||
hooks := c.hooks.ChannelMonitorDailyRollup
|
||||
return append(hooks[:len(hooks):len(hooks)], channelmonitordailyrollup.Hooks[:]...)
|
||||
return c.hooks.ChannelMonitorDailyRollup
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *ChannelMonitorDailyRollupClient) Interceptors() []Interceptor {
|
||||
inters := c.inters.ChannelMonitorDailyRollup
|
||||
return append(inters[:len(inters):len(inters)], channelmonitordailyrollup.Interceptors[:]...)
|
||||
return c.inters.ChannelMonitorDailyRollup
|
||||
}
|
||||
|
||||
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.
|
||||
func (c *ChannelMonitorHistoryClient) Hooks() []Hook {
|
||||
hooks := c.hooks.ChannelMonitorHistory
|
||||
return append(hooks[:len(hooks):len(hooks)], channelmonitorhistory.Hooks[:]...)
|
||||
return c.hooks.ChannelMonitorHistory
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *ChannelMonitorHistoryClient) Interceptors() []Interceptor {
|
||||
inters := c.inters.ChannelMonitorHistory
|
||||
return append(inters[:len(inters):len(inters)], channelmonitorhistory.Interceptors[:]...)
|
||||
return c.inters.ChannelMonitorHistory
|
||||
}
|
||||
|
||||
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 = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt64, Increment: true},
|
||||
{Name: "deleted_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"postgres": "timestamptz"}},
|
||||
{Name: "model", Type: field.TypeString, Size: 200},
|
||||
{Name: "bucket_date", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "date"}},
|
||||
{Name: "total_checks", Type: field.TypeInt, Default: 0},
|
||||
@@ -488,7 +487,7 @@ var (
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "channel_monitor_daily_rollups_channel_monitors_daily_rollups",
|
||||
Columns: []*schema.Column{ChannelMonitorDailyRollupsColumns[15]},
|
||||
Columns: []*schema.Column{ChannelMonitorDailyRollupsColumns[14]},
|
||||
RefColumns: []*schema.Column{ChannelMonitorsColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
@@ -497,19 +496,18 @@ var (
|
||||
{
|
||||
Name: "channelmonitordailyrollup_monitor_id_model_bucket_date",
|
||||
Unique: true,
|
||||
Columns: []*schema.Column{ChannelMonitorDailyRollupsColumns[15], ChannelMonitorDailyRollupsColumns[2], ChannelMonitorDailyRollupsColumns[3]},
|
||||
Columns: []*schema.Column{ChannelMonitorDailyRollupsColumns[14], ChannelMonitorDailyRollupsColumns[1], ChannelMonitorDailyRollupsColumns[2]},
|
||||
},
|
||||
{
|
||||
Name: "channelmonitordailyrollup_bucket_date",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{ChannelMonitorDailyRollupsColumns[3]},
|
||||
Columns: []*schema.Column{ChannelMonitorDailyRollupsColumns[2]},
|
||||
},
|
||||
},
|
||||
}
|
||||
// ChannelMonitorHistoriesColumns holds the columns for the "channel_monitor_histories" table.
|
||||
ChannelMonitorHistoriesColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt64, Increment: true},
|
||||
{Name: "deleted_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"postgres": "timestamptz"}},
|
||||
{Name: "model", Type: field.TypeString, Size: 200},
|
||||
{Name: "status", Type: field.TypeEnum, Enums: []string{"operational", "degraded", "failed", "error"}},
|
||||
{Name: "latency_ms", Type: field.TypeInt, Nullable: true},
|
||||
@@ -526,7 +524,7 @@ var (
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "channel_monitor_histories_channel_monitors_history",
|
||||
Columns: []*schema.Column{ChannelMonitorHistoriesColumns[8]},
|
||||
Columns: []*schema.Column{ChannelMonitorHistoriesColumns[7]},
|
||||
RefColumns: []*schema.Column{ChannelMonitorsColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
@@ -535,12 +533,12 @@ var (
|
||||
{
|
||||
Name: "channelmonitorhistory_monitor_id_model_checked_at",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{ChannelMonitorHistoriesColumns[8], ChannelMonitorHistoriesColumns[2], ChannelMonitorHistoriesColumns[7]},
|
||||
Columns: []*schema.Column{ChannelMonitorHistoriesColumns[7], ChannelMonitorHistoriesColumns[1], ChannelMonitorHistoriesColumns[6]},
|
||||
},
|
||||
{
|
||||
Name: "channelmonitorhistory_checked_at",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{ChannelMonitorHistoriesColumns[7]},
|
||||
Columns: []*schema.Column{ChannelMonitorHistoriesColumns[6]},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -10022,7 +10022,6 @@ type ChannelMonitorDailyRollupMutation struct {
|
||||
op Op
|
||||
typ string
|
||||
id *int64
|
||||
deleted_at *time.Time
|
||||
model *string
|
||||
bucket_date *time.Time
|
||||
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.
|
||||
func (m *ChannelMonitorDailyRollupMutation) SetMonitorID(i int64) {
|
||||
m.monitor = &i
|
||||
@@ -10966,10 +10916,7 @@ func (m *ChannelMonitorDailyRollupMutation) Type() string {
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *ChannelMonitorDailyRollupMutation) Fields() []string {
|
||||
fields := make([]string, 0, 15)
|
||||
if m.deleted_at != nil {
|
||||
fields = append(fields, channelmonitordailyrollup.FieldDeletedAt)
|
||||
}
|
||||
fields := make([]string, 0, 14)
|
||||
if m.monitor != nil {
|
||||
fields = append(fields, channelmonitordailyrollup.FieldMonitorID)
|
||||
}
|
||||
@@ -11020,8 +10967,6 @@ func (m *ChannelMonitorDailyRollupMutation) Fields() []string {
|
||||
// schema.
|
||||
func (m *ChannelMonitorDailyRollupMutation) Field(name string) (ent.Value, bool) {
|
||||
switch name {
|
||||
case channelmonitordailyrollup.FieldDeletedAt:
|
||||
return m.DeletedAt()
|
||||
case channelmonitordailyrollup.FieldMonitorID:
|
||||
return m.MonitorID()
|
||||
case channelmonitordailyrollup.FieldModel:
|
||||
@@ -11059,8 +11004,6 @@ func (m *ChannelMonitorDailyRollupMutation) Field(name string) (ent.Value, bool)
|
||||
// database failed.
|
||||
func (m *ChannelMonitorDailyRollupMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
||||
switch name {
|
||||
case channelmonitordailyrollup.FieldDeletedAt:
|
||||
return m.OldDeletedAt(ctx)
|
||||
case channelmonitordailyrollup.FieldMonitorID:
|
||||
return m.OldMonitorID(ctx)
|
||||
case channelmonitordailyrollup.FieldModel:
|
||||
@@ -11098,13 +11041,6 @@ func (m *ChannelMonitorDailyRollupMutation) OldField(ctx context.Context, name s
|
||||
// type.
|
||||
func (m *ChannelMonitorDailyRollupMutation) SetField(name string, value ent.Value) error {
|
||||
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:
|
||||
v, ok := value.(int64)
|
||||
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
|
||||
// mutation.
|
||||
func (m *ChannelMonitorDailyRollupMutation) ClearedFields() []string {
|
||||
var fields []string
|
||||
if m.FieldCleared(channelmonitordailyrollup.FieldDeletedAt) {
|
||||
fields = append(fields, channelmonitordailyrollup.FieldDeletedAt)
|
||||
}
|
||||
return fields
|
||||
return nil
|
||||
}
|
||||
|
||||
// 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
|
||||
// error if the field is not defined in the schema.
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -11384,9 +11311,6 @@ func (m *ChannelMonitorDailyRollupMutation) ClearField(name string) error {
|
||||
// It returns an error if the field is not defined in the schema.
|
||||
func (m *ChannelMonitorDailyRollupMutation) ResetField(name string) error {
|
||||
switch name {
|
||||
case channelmonitordailyrollup.FieldDeletedAt:
|
||||
m.ResetDeletedAt()
|
||||
return nil
|
||||
case channelmonitordailyrollup.FieldMonitorID:
|
||||
m.ResetMonitorID()
|
||||
return nil
|
||||
@@ -11513,7 +11437,6 @@ type ChannelMonitorHistoryMutation struct {
|
||||
op Op
|
||||
typ string
|
||||
id *int64
|
||||
deleted_at *time.Time
|
||||
model *string
|
||||
status *channelmonitorhistory.Status
|
||||
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.
|
||||
func (m *ChannelMonitorHistoryMutation) SetMonitorID(i int64) {
|
||||
m.monitor = &i
|
||||
@@ -12071,10 +11945,7 @@ func (m *ChannelMonitorHistoryMutation) Type() string {
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *ChannelMonitorHistoryMutation) Fields() []string {
|
||||
fields := make([]string, 0, 8)
|
||||
if m.deleted_at != nil {
|
||||
fields = append(fields, channelmonitorhistory.FieldDeletedAt)
|
||||
}
|
||||
fields := make([]string, 0, 7)
|
||||
if m.monitor != nil {
|
||||
fields = append(fields, channelmonitorhistory.FieldMonitorID)
|
||||
}
|
||||
@@ -12104,8 +11975,6 @@ func (m *ChannelMonitorHistoryMutation) Fields() []string {
|
||||
// schema.
|
||||
func (m *ChannelMonitorHistoryMutation) Field(name string) (ent.Value, bool) {
|
||||
switch name {
|
||||
case channelmonitorhistory.FieldDeletedAt:
|
||||
return m.DeletedAt()
|
||||
case channelmonitorhistory.FieldMonitorID:
|
||||
return m.MonitorID()
|
||||
case channelmonitorhistory.FieldModel:
|
||||
@@ -12129,8 +11998,6 @@ func (m *ChannelMonitorHistoryMutation) Field(name string) (ent.Value, bool) {
|
||||
// database failed.
|
||||
func (m *ChannelMonitorHistoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
||||
switch name {
|
||||
case channelmonitorhistory.FieldDeletedAt:
|
||||
return m.OldDeletedAt(ctx)
|
||||
case channelmonitorhistory.FieldMonitorID:
|
||||
return m.OldMonitorID(ctx)
|
||||
case channelmonitorhistory.FieldModel:
|
||||
@@ -12154,13 +12021,6 @@ func (m *ChannelMonitorHistoryMutation) OldField(ctx context.Context, name strin
|
||||
// type.
|
||||
func (m *ChannelMonitorHistoryMutation) SetField(name string, value ent.Value) error {
|
||||
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:
|
||||
v, ok := value.(int64)
|
||||
if !ok {
|
||||
@@ -12267,9 +12127,6 @@ func (m *ChannelMonitorHistoryMutation) AddField(name string, value ent.Value) e
|
||||
// mutation.
|
||||
func (m *ChannelMonitorHistoryMutation) ClearedFields() []string {
|
||||
var fields []string
|
||||
if m.FieldCleared(channelmonitorhistory.FieldDeletedAt) {
|
||||
fields = append(fields, channelmonitorhistory.FieldDeletedAt)
|
||||
}
|
||||
if m.FieldCleared(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.
|
||||
func (m *ChannelMonitorHistoryMutation) ClearField(name string) error {
|
||||
switch name {
|
||||
case channelmonitorhistory.FieldDeletedAt:
|
||||
m.ClearDeletedAt()
|
||||
return nil
|
||||
case channelmonitorhistory.FieldLatencyMs:
|
||||
m.ClearLatencyMs()
|
||||
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.
|
||||
func (m *ChannelMonitorHistoryMutation) ResetField(name string) error {
|
||||
switch name {
|
||||
case channelmonitorhistory.FieldDeletedAt:
|
||||
m.ResetDeletedAt()
|
||||
return nil
|
||||
case channelmonitorhistory.FieldMonitorID:
|
||||
m.ResetMonitorID()
|
||||
return nil
|
||||
|
||||
@@ -521,11 +521,6 @@ func init() {
|
||||
channelmonitorDescIntervalSeconds := channelmonitorFields[8].Descriptor()
|
||||
// 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)
|
||||
channelmonitordailyrollupMixin := schema.ChannelMonitorDailyRollup{}.Mixin()
|
||||
channelmonitordailyrollupMixinHooks0 := channelmonitordailyrollupMixin[0].Hooks()
|
||||
channelmonitordailyrollup.Hooks[0] = channelmonitordailyrollupMixinHooks0[0]
|
||||
channelmonitordailyrollupMixinInters0 := channelmonitordailyrollupMixin[0].Interceptors()
|
||||
channelmonitordailyrollup.Interceptors[0] = channelmonitordailyrollupMixinInters0[0]
|
||||
channelmonitordailyrollupFields := schema.ChannelMonitorDailyRollup{}.Fields()
|
||||
_ = channelmonitordailyrollupFields
|
||||
// channelmonitordailyrollupDescModel is the schema descriptor for model field.
|
||||
@@ -592,11 +587,6 @@ func init() {
|
||||
channelmonitordailyrollup.DefaultComputedAt = channelmonitordailyrollupDescComputedAt.Default.(func() time.Time)
|
||||
// channelmonitordailyrollup.UpdateDefaultComputedAt holds the default value on update for the computed_at field.
|
||||
channelmonitordailyrollup.UpdateDefaultComputedAt = channelmonitordailyrollupDescComputedAt.UpdateDefault.(func() time.Time)
|
||||
channelmonitorhistoryMixin := schema.ChannelMonitorHistory{}.Mixin()
|
||||
channelmonitorhistoryMixinHooks0 := channelmonitorhistoryMixin[0].Hooks()
|
||||
channelmonitorhistory.Hooks[0] = channelmonitorhistoryMixinHooks0[0]
|
||||
channelmonitorhistoryMixinInters0 := channelmonitorhistoryMixin[0].Interceptors()
|
||||
channelmonitorhistory.Interceptors[0] = channelmonitorhistoryMixinInters0[0]
|
||||
channelmonitorhistoryFields := schema.ChannelMonitorHistory{}.Fields()
|
||||
_ = channelmonitorhistoryFields
|
||||
// channelmonitorhistoryDescModel is the schema descriptor for model field.
|
||||
|
||||
@@ -10,13 +10,12 @@ import (
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
|
||||
"github.com/Wei-Shaw/sub2api/ent/schema/mixins"
|
||||
)
|
||||
|
||||
// ChannelMonitorDailyRollup 按 (monitor_id, model, bucket_date) 维度聚合的渠道监控日统计。
|
||||
// 每天的明细被收敛为一行(保留 status 分布 + 延迟和),用于 7d/15d/30d 窗口的可用率
|
||||
// 加权计算(avg_latency = sum_latency_ms / count_latency;availability = ok_count / total_checks)。
|
||||
// 超过保留期由每日维护任务分批物理删(不用软删除,理由同 channel_monitor_history)。
|
||||
type ChannelMonitorDailyRollup struct {
|
||||
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 {
|
||||
return []ent.Field{
|
||||
field.Int64("monitor_id"),
|
||||
|
||||
@@ -9,13 +9,12 @@ import (
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
|
||||
"github.com/Wei-Shaw/sub2api/ent/schema/mixins"
|
||||
)
|
||||
|
||||
// ChannelMonitorHistory holds the schema definition for the ChannelMonitorHistory entity.
|
||||
// 渠道监控历史:每次检测每个模型一行记录。明细只保留 1 天,超过 1 天的数据被聚合到
|
||||
// channel_monitor_daily_rollups 后软删(deleted_at),由后续懒清理任务物理移除。
|
||||
// 渠道监控历史:每次检测每个模型一行记录。明细只保留 1 天,超过 1 天由每日维护任务
|
||||
// 先聚合到 channel_monitor_daily_rollups,再分批物理删(不用软删除:日志类表无恢复
|
||||
// 需求,软删会让行和索引只增不减,徒增磁盘和查询开销)。
|
||||
type ChannelMonitorHistory struct {
|
||||
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 {
|
||||
return []ent.Field{
|
||||
field.Int64("monitor_id"),
|
||||
|
||||
Reference in New Issue
Block a user