明细只保留 1 天,超过 1 天聚合到新表 channel_monitor_daily_rollups(按 monitor_id/model/bucket_date 维度),聚合保留 30 天。两张表都用 SoftDeleteMixin 软删除(DELETE 自动改为 UPDATE deleted_at = NOW())。 聚合 + 清理任务由 OpsCleanupService 的 cron 统一调度,与运维监控的清理共享 schedule(默认 0 2 * * *)和 leader lock。ChannelMonitorRunner 的 cleanupLoop 被移除,只保留 dueCheckLoop。 读取路径 ComputeAvailability* 改为 UNION 明细(今天 deleted_at IS NULL)+ 聚合(过去 windowDays 天 deleted_at IS NULL),SUM(ok)/SUM(total) 自然加权 计算可用率,AVG latency 用 SUM(sum_latency_ms)/SUM(count_latency)。 watermark 表 channel_monitor_aggregation_watermark 单行(id=1),记录 last_aggregated_date,重启后从该日期 +1 继续聚合,首次为 nil 则从 today - 30d 开始回填,单次最多 35 天上限避免长事务。 raw SQL 的 ListLatestPerModel / ListLatestForMonitorIDs / ListRecentHistoryForMonitors 都补上 deleted_at IS NULL 过滤(SoftDeleteMixin interceptor 只对 ent query 生效)。 bump version to 0.1.114.28 GroupBadge 在 MonitorKeyPickerDialog 中复用平台主题色 + 倍率/专属倍率 (顺手优化)。
1026 lines
36 KiB
Go
1026 lines
36 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitor"
|
|
"github.com/Wei-Shaw/sub2api/ent/channelmonitordailyrollup"
|
|
"github.com/Wei-Shaw/sub2api/ent/predicate"
|
|
)
|
|
|
|
// ChannelMonitorDailyRollupUpdate is the builder for updating ChannelMonitorDailyRollup entities.
|
|
type ChannelMonitorDailyRollupUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *ChannelMonitorDailyRollupMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the ChannelMonitorDailyRollupUpdate builder.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) Where(ps ...predicate.ChannelMonitorDailyRollup) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.Where(ps...)
|
|
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)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMonitorID sets the "monitor_id" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetNillableMonitorID(v *int64) *ChannelMonitorDailyRollupUpdate {
|
|
if v != nil {
|
|
_u.SetMonitorID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetModel sets the "model" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetModel(v string) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.SetModel(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableModel sets the "model" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetNillableModel(v *string) *ChannelMonitorDailyRollupUpdate {
|
|
if v != nil {
|
|
_u.SetModel(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetBucketDate sets the "bucket_date" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetBucketDate(v time.Time) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.SetBucketDate(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableBucketDate sets the "bucket_date" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetNillableBucketDate(v *time.Time) *ChannelMonitorDailyRollupUpdate {
|
|
if v != nil {
|
|
_u.SetBucketDate(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetTotalChecks sets the "total_checks" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetTotalChecks(v int) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.ResetTotalChecks()
|
|
_u.mutation.SetTotalChecks(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTotalChecks sets the "total_checks" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetNillableTotalChecks(v *int) *ChannelMonitorDailyRollupUpdate {
|
|
if v != nil {
|
|
_u.SetTotalChecks(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddTotalChecks adds value to the "total_checks" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) AddTotalChecks(v int) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.AddTotalChecks(v)
|
|
return _u
|
|
}
|
|
|
|
// SetOkCount sets the "ok_count" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetOkCount(v int) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.ResetOkCount()
|
|
_u.mutation.SetOkCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOkCount sets the "ok_count" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetNillableOkCount(v *int) *ChannelMonitorDailyRollupUpdate {
|
|
if v != nil {
|
|
_u.SetOkCount(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddOkCount adds value to the "ok_count" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) AddOkCount(v int) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.AddOkCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetOperationalCount sets the "operational_count" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetOperationalCount(v int) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.ResetOperationalCount()
|
|
_u.mutation.SetOperationalCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOperationalCount sets the "operational_count" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetNillableOperationalCount(v *int) *ChannelMonitorDailyRollupUpdate {
|
|
if v != nil {
|
|
_u.SetOperationalCount(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddOperationalCount adds value to the "operational_count" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) AddOperationalCount(v int) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.AddOperationalCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetDegradedCount sets the "degraded_count" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetDegradedCount(v int) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.ResetDegradedCount()
|
|
_u.mutation.SetDegradedCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDegradedCount sets the "degraded_count" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetNillableDegradedCount(v *int) *ChannelMonitorDailyRollupUpdate {
|
|
if v != nil {
|
|
_u.SetDegradedCount(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddDegradedCount adds value to the "degraded_count" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) AddDegradedCount(v int) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.AddDegradedCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetFailedCount sets the "failed_count" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetFailedCount(v int) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.ResetFailedCount()
|
|
_u.mutation.SetFailedCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableFailedCount sets the "failed_count" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetNillableFailedCount(v *int) *ChannelMonitorDailyRollupUpdate {
|
|
if v != nil {
|
|
_u.SetFailedCount(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddFailedCount adds value to the "failed_count" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) AddFailedCount(v int) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.AddFailedCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetErrorCount sets the "error_count" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetErrorCount(v int) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.ResetErrorCount()
|
|
_u.mutation.SetErrorCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableErrorCount sets the "error_count" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetNillableErrorCount(v *int) *ChannelMonitorDailyRollupUpdate {
|
|
if v != nil {
|
|
_u.SetErrorCount(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddErrorCount adds value to the "error_count" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) AddErrorCount(v int) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.AddErrorCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSumLatencyMs sets the "sum_latency_ms" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetSumLatencyMs(v int64) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.ResetSumLatencyMs()
|
|
_u.mutation.SetSumLatencyMs(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSumLatencyMs sets the "sum_latency_ms" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetNillableSumLatencyMs(v *int64) *ChannelMonitorDailyRollupUpdate {
|
|
if v != nil {
|
|
_u.SetSumLatencyMs(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddSumLatencyMs adds value to the "sum_latency_ms" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) AddSumLatencyMs(v int64) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.AddSumLatencyMs(v)
|
|
return _u
|
|
}
|
|
|
|
// SetCountLatency sets the "count_latency" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetCountLatency(v int) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.ResetCountLatency()
|
|
_u.mutation.SetCountLatency(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCountLatency sets the "count_latency" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetNillableCountLatency(v *int) *ChannelMonitorDailyRollupUpdate {
|
|
if v != nil {
|
|
_u.SetCountLatency(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddCountLatency adds value to the "count_latency" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) AddCountLatency(v int) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.AddCountLatency(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSumPingLatencyMs sets the "sum_ping_latency_ms" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetSumPingLatencyMs(v int64) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.ResetSumPingLatencyMs()
|
|
_u.mutation.SetSumPingLatencyMs(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSumPingLatencyMs sets the "sum_ping_latency_ms" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetNillableSumPingLatencyMs(v *int64) *ChannelMonitorDailyRollupUpdate {
|
|
if v != nil {
|
|
_u.SetSumPingLatencyMs(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddSumPingLatencyMs adds value to the "sum_ping_latency_ms" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) AddSumPingLatencyMs(v int64) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.AddSumPingLatencyMs(v)
|
|
return _u
|
|
}
|
|
|
|
// SetCountPingLatency sets the "count_ping_latency" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetCountPingLatency(v int) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.ResetCountPingLatency()
|
|
_u.mutation.SetCountPingLatency(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCountPingLatency sets the "count_ping_latency" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetNillableCountPingLatency(v *int) *ChannelMonitorDailyRollupUpdate {
|
|
if v != nil {
|
|
_u.SetCountPingLatency(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddCountPingLatency adds value to the "count_ping_latency" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) AddCountPingLatency(v int) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.AddCountPingLatency(v)
|
|
return _u
|
|
}
|
|
|
|
// SetComputedAt sets the "computed_at" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetComputedAt(v time.Time) *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.SetComputedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetMonitor sets the "monitor" edge to the ChannelMonitor entity.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SetMonitor(v *ChannelMonitor) *ChannelMonitorDailyRollupUpdate {
|
|
return _u.SetMonitorID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the ChannelMonitorDailyRollupMutation object of the builder.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) Mutation() *ChannelMonitorDailyRollupMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearMonitor clears the "monitor" edge to the ChannelMonitor entity.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) ClearMonitor() *ChannelMonitorDailyRollupUpdate {
|
|
_u.mutation.ClearMonitor()
|
|
return _u
|
|
}
|
|
|
|
// 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
|
|
}
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) defaults() error {
|
|
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.
|
|
func (_u *ChannelMonitorDailyRollupUpdate) check() error {
|
|
if v, ok := _u.mutation.Model(); ok {
|
|
if err := channelmonitordailyrollup.ModelValidator(v); err != nil {
|
|
return &ValidationError{Name: "model", err: fmt.Errorf(`ent: validator failed for field "ChannelMonitorDailyRollup.model": %w`, err)}
|
|
}
|
|
}
|
|
if _u.mutation.MonitorCleared() && len(_u.mutation.MonitorIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "ChannelMonitorDailyRollup.monitor"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *ChannelMonitorDailyRollupUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(channelmonitordailyrollup.Table, channelmonitordailyrollup.Columns, sqlgraph.NewFieldSpec(channelmonitordailyrollup.FieldID, field.TypeInt64))
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
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)
|
|
}
|
|
if value, ok := _u.mutation.BucketDate(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldBucketDate, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.TotalChecks(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldTotalChecks, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedTotalChecks(); ok {
|
|
_spec.AddField(channelmonitordailyrollup.FieldTotalChecks, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.OkCount(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldOkCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedOkCount(); ok {
|
|
_spec.AddField(channelmonitordailyrollup.FieldOkCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.OperationalCount(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldOperationalCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedOperationalCount(); ok {
|
|
_spec.AddField(channelmonitordailyrollup.FieldOperationalCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.DegradedCount(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldDegradedCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedDegradedCount(); ok {
|
|
_spec.AddField(channelmonitordailyrollup.FieldDegradedCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.FailedCount(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldFailedCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedFailedCount(); ok {
|
|
_spec.AddField(channelmonitordailyrollup.FieldFailedCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.ErrorCount(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldErrorCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedErrorCount(); ok {
|
|
_spec.AddField(channelmonitordailyrollup.FieldErrorCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.SumLatencyMs(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldSumLatencyMs, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedSumLatencyMs(); ok {
|
|
_spec.AddField(channelmonitordailyrollup.FieldSumLatencyMs, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.CountLatency(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldCountLatency, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedCountLatency(); ok {
|
|
_spec.AddField(channelmonitordailyrollup.FieldCountLatency, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.SumPingLatencyMs(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldSumPingLatencyMs, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedSumPingLatencyMs(); ok {
|
|
_spec.AddField(channelmonitordailyrollup.FieldSumPingLatencyMs, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.CountPingLatency(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldCountPingLatency, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedCountPingLatency(); ok {
|
|
_spec.AddField(channelmonitordailyrollup.FieldCountPingLatency, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.ComputedAt(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldComputedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.MonitorCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: channelmonitordailyrollup.MonitorTable,
|
|
Columns: []string{channelmonitordailyrollup.MonitorColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(channelmonitor.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.MonitorIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: channelmonitordailyrollup.MonitorTable,
|
|
Columns: []string{channelmonitordailyrollup.MonitorColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(channelmonitor.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{channelmonitordailyrollup.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// ChannelMonitorDailyRollupUpdateOne is the builder for updating a single ChannelMonitorDailyRollup entity.
|
|
type ChannelMonitorDailyRollupUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
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)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMonitorID sets the "monitor_id" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetNillableMonitorID(v *int64) *ChannelMonitorDailyRollupUpdateOne {
|
|
if v != nil {
|
|
_u.SetMonitorID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetModel sets the "model" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetModel(v string) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.SetModel(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableModel sets the "model" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetNillableModel(v *string) *ChannelMonitorDailyRollupUpdateOne {
|
|
if v != nil {
|
|
_u.SetModel(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetBucketDate sets the "bucket_date" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetBucketDate(v time.Time) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.SetBucketDate(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableBucketDate sets the "bucket_date" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetNillableBucketDate(v *time.Time) *ChannelMonitorDailyRollupUpdateOne {
|
|
if v != nil {
|
|
_u.SetBucketDate(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetTotalChecks sets the "total_checks" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetTotalChecks(v int) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.ResetTotalChecks()
|
|
_u.mutation.SetTotalChecks(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTotalChecks sets the "total_checks" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetNillableTotalChecks(v *int) *ChannelMonitorDailyRollupUpdateOne {
|
|
if v != nil {
|
|
_u.SetTotalChecks(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddTotalChecks adds value to the "total_checks" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) AddTotalChecks(v int) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.AddTotalChecks(v)
|
|
return _u
|
|
}
|
|
|
|
// SetOkCount sets the "ok_count" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetOkCount(v int) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.ResetOkCount()
|
|
_u.mutation.SetOkCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOkCount sets the "ok_count" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetNillableOkCount(v *int) *ChannelMonitorDailyRollupUpdateOne {
|
|
if v != nil {
|
|
_u.SetOkCount(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddOkCount adds value to the "ok_count" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) AddOkCount(v int) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.AddOkCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetOperationalCount sets the "operational_count" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetOperationalCount(v int) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.ResetOperationalCount()
|
|
_u.mutation.SetOperationalCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOperationalCount sets the "operational_count" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetNillableOperationalCount(v *int) *ChannelMonitorDailyRollupUpdateOne {
|
|
if v != nil {
|
|
_u.SetOperationalCount(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddOperationalCount adds value to the "operational_count" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) AddOperationalCount(v int) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.AddOperationalCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetDegradedCount sets the "degraded_count" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetDegradedCount(v int) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.ResetDegradedCount()
|
|
_u.mutation.SetDegradedCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDegradedCount sets the "degraded_count" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetNillableDegradedCount(v *int) *ChannelMonitorDailyRollupUpdateOne {
|
|
if v != nil {
|
|
_u.SetDegradedCount(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddDegradedCount adds value to the "degraded_count" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) AddDegradedCount(v int) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.AddDegradedCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetFailedCount sets the "failed_count" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetFailedCount(v int) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.ResetFailedCount()
|
|
_u.mutation.SetFailedCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableFailedCount sets the "failed_count" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetNillableFailedCount(v *int) *ChannelMonitorDailyRollupUpdateOne {
|
|
if v != nil {
|
|
_u.SetFailedCount(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddFailedCount adds value to the "failed_count" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) AddFailedCount(v int) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.AddFailedCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetErrorCount sets the "error_count" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetErrorCount(v int) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.ResetErrorCount()
|
|
_u.mutation.SetErrorCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableErrorCount sets the "error_count" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetNillableErrorCount(v *int) *ChannelMonitorDailyRollupUpdateOne {
|
|
if v != nil {
|
|
_u.SetErrorCount(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddErrorCount adds value to the "error_count" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) AddErrorCount(v int) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.AddErrorCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSumLatencyMs sets the "sum_latency_ms" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetSumLatencyMs(v int64) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.ResetSumLatencyMs()
|
|
_u.mutation.SetSumLatencyMs(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSumLatencyMs sets the "sum_latency_ms" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetNillableSumLatencyMs(v *int64) *ChannelMonitorDailyRollupUpdateOne {
|
|
if v != nil {
|
|
_u.SetSumLatencyMs(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddSumLatencyMs adds value to the "sum_latency_ms" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) AddSumLatencyMs(v int64) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.AddSumLatencyMs(v)
|
|
return _u
|
|
}
|
|
|
|
// SetCountLatency sets the "count_latency" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetCountLatency(v int) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.ResetCountLatency()
|
|
_u.mutation.SetCountLatency(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCountLatency sets the "count_latency" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetNillableCountLatency(v *int) *ChannelMonitorDailyRollupUpdateOne {
|
|
if v != nil {
|
|
_u.SetCountLatency(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddCountLatency adds value to the "count_latency" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) AddCountLatency(v int) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.AddCountLatency(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSumPingLatencyMs sets the "sum_ping_latency_ms" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetSumPingLatencyMs(v int64) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.ResetSumPingLatencyMs()
|
|
_u.mutation.SetSumPingLatencyMs(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSumPingLatencyMs sets the "sum_ping_latency_ms" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetNillableSumPingLatencyMs(v *int64) *ChannelMonitorDailyRollupUpdateOne {
|
|
if v != nil {
|
|
_u.SetSumPingLatencyMs(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddSumPingLatencyMs adds value to the "sum_ping_latency_ms" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) AddSumPingLatencyMs(v int64) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.AddSumPingLatencyMs(v)
|
|
return _u
|
|
}
|
|
|
|
// SetCountPingLatency sets the "count_ping_latency" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetCountPingLatency(v int) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.ResetCountPingLatency()
|
|
_u.mutation.SetCountPingLatency(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCountPingLatency sets the "count_ping_latency" field if the given value is not nil.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetNillableCountPingLatency(v *int) *ChannelMonitorDailyRollupUpdateOne {
|
|
if v != nil {
|
|
_u.SetCountPingLatency(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddCountPingLatency adds value to the "count_ping_latency" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) AddCountPingLatency(v int) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.AddCountPingLatency(v)
|
|
return _u
|
|
}
|
|
|
|
// SetComputedAt sets the "computed_at" field.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetComputedAt(v time.Time) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.SetComputedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetMonitor sets the "monitor" edge to the ChannelMonitor entity.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SetMonitor(v *ChannelMonitor) *ChannelMonitorDailyRollupUpdateOne {
|
|
return _u.SetMonitorID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the ChannelMonitorDailyRollupMutation object of the builder.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) Mutation() *ChannelMonitorDailyRollupMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearMonitor clears the "monitor" edge to the ChannelMonitor entity.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) ClearMonitor() *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.ClearMonitor()
|
|
return _u
|
|
}
|
|
|
|
// Where appends a list predicates to the ChannelMonitorDailyRollupUpdate builder.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) Where(ps ...predicate.ChannelMonitorDailyRollup) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) Select(field string, fields ...string) *ChannelMonitorDailyRollupUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// 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
|
|
}
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) SaveX(ctx context.Context) *ChannelMonitorDailyRollup {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) defaults() error {
|
|
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.
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) check() error {
|
|
if v, ok := _u.mutation.Model(); ok {
|
|
if err := channelmonitordailyrollup.ModelValidator(v); err != nil {
|
|
return &ValidationError{Name: "model", err: fmt.Errorf(`ent: validator failed for field "ChannelMonitorDailyRollup.model": %w`, err)}
|
|
}
|
|
}
|
|
if _u.mutation.MonitorCleared() && len(_u.mutation.MonitorIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "ChannelMonitorDailyRollup.monitor"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *ChannelMonitorDailyRollupUpdateOne) sqlSave(ctx context.Context) (_node *ChannelMonitorDailyRollup, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(channelmonitordailyrollup.Table, channelmonitordailyrollup.Columns, sqlgraph.NewFieldSpec(channelmonitordailyrollup.FieldID, field.TypeInt64))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ChannelMonitorDailyRollup.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := _u.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, channelmonitordailyrollup.FieldID)
|
|
for _, f := range fields {
|
|
if !channelmonitordailyrollup.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != channelmonitordailyrollup.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
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)
|
|
}
|
|
if value, ok := _u.mutation.BucketDate(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldBucketDate, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.TotalChecks(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldTotalChecks, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedTotalChecks(); ok {
|
|
_spec.AddField(channelmonitordailyrollup.FieldTotalChecks, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.OkCount(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldOkCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedOkCount(); ok {
|
|
_spec.AddField(channelmonitordailyrollup.FieldOkCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.OperationalCount(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldOperationalCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedOperationalCount(); ok {
|
|
_spec.AddField(channelmonitordailyrollup.FieldOperationalCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.DegradedCount(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldDegradedCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedDegradedCount(); ok {
|
|
_spec.AddField(channelmonitordailyrollup.FieldDegradedCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.FailedCount(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldFailedCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedFailedCount(); ok {
|
|
_spec.AddField(channelmonitordailyrollup.FieldFailedCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.ErrorCount(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldErrorCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedErrorCount(); ok {
|
|
_spec.AddField(channelmonitordailyrollup.FieldErrorCount, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.SumLatencyMs(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldSumLatencyMs, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedSumLatencyMs(); ok {
|
|
_spec.AddField(channelmonitordailyrollup.FieldSumLatencyMs, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.CountLatency(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldCountLatency, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedCountLatency(); ok {
|
|
_spec.AddField(channelmonitordailyrollup.FieldCountLatency, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.SumPingLatencyMs(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldSumPingLatencyMs, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedSumPingLatencyMs(); ok {
|
|
_spec.AddField(channelmonitordailyrollup.FieldSumPingLatencyMs, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.CountPingLatency(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldCountPingLatency, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedCountPingLatency(); ok {
|
|
_spec.AddField(channelmonitordailyrollup.FieldCountPingLatency, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.ComputedAt(); ok {
|
|
_spec.SetField(channelmonitordailyrollup.FieldComputedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.MonitorCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: channelmonitordailyrollup.MonitorTable,
|
|
Columns: []string{channelmonitordailyrollup.MonitorColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(channelmonitor.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.MonitorIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: channelmonitordailyrollup.MonitorTable,
|
|
Columns: []string{channelmonitordailyrollup.MonitorColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(channelmonitor.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_node = &ChannelMonitorDailyRollup{config: _u.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{channelmonitordailyrollup.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|