// Code generated by ent, DO NOT EDIT. package ent import ( "fmt" "strings" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/Wei-Shaw/sub2api/ent/channelmonitor" "github.com/Wei-Shaw/sub2api/ent/channelmonitordailyrollup" ) // ChannelMonitorDailyRollup is the model entity for the ChannelMonitorDailyRollup schema. type ChannelMonitorDailyRollup struct { config `json:"-"` // ID of the ent. ID int64 `json:"id,omitempty"` // MonitorID holds the value of the "monitor_id" field. MonitorID int64 `json:"monitor_id,omitempty"` // Model holds the value of the "model" field. Model string `json:"model,omitempty"` // BucketDate holds the value of the "bucket_date" field. BucketDate time.Time `json:"bucket_date,omitempty"` // TotalChecks holds the value of the "total_checks" field. TotalChecks int `json:"total_checks,omitempty"` // OkCount holds the value of the "ok_count" field. OkCount int `json:"ok_count,omitempty"` // OperationalCount holds the value of the "operational_count" field. OperationalCount int `json:"operational_count,omitempty"` // DegradedCount holds the value of the "degraded_count" field. DegradedCount int `json:"degraded_count,omitempty"` // FailedCount holds the value of the "failed_count" field. FailedCount int `json:"failed_count,omitempty"` // ErrorCount holds the value of the "error_count" field. ErrorCount int `json:"error_count,omitempty"` // SumLatencyMs holds the value of the "sum_latency_ms" field. SumLatencyMs int64 `json:"sum_latency_ms,omitempty"` // CountLatency holds the value of the "count_latency" field. CountLatency int `json:"count_latency,omitempty"` // SumPingLatencyMs holds the value of the "sum_ping_latency_ms" field. SumPingLatencyMs int64 `json:"sum_ping_latency_ms,omitempty"` // CountPingLatency holds the value of the "count_ping_latency" field. CountPingLatency int `json:"count_ping_latency,omitempty"` // ComputedAt holds the value of the "computed_at" field. ComputedAt time.Time `json:"computed_at,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the ChannelMonitorDailyRollupQuery when eager-loading is set. Edges ChannelMonitorDailyRollupEdges `json:"edges"` selectValues sql.SelectValues } // ChannelMonitorDailyRollupEdges holds the relations/edges for other nodes in the graph. type ChannelMonitorDailyRollupEdges struct { // Monitor holds the value of the monitor edge. Monitor *ChannelMonitor `json:"monitor,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [1]bool } // MonitorOrErr returns the Monitor value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e ChannelMonitorDailyRollupEdges) MonitorOrErr() (*ChannelMonitor, error) { if e.Monitor != nil { return e.Monitor, nil } else if e.loadedTypes[0] { return nil, &NotFoundError{label: channelmonitor.Label} } return nil, &NotLoadedError{edge: "monitor"} } // scanValues returns the types for scanning values from sql.Rows. func (*ChannelMonitorDailyRollup) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case channelmonitordailyrollup.FieldID, channelmonitordailyrollup.FieldMonitorID, channelmonitordailyrollup.FieldTotalChecks, channelmonitordailyrollup.FieldOkCount, channelmonitordailyrollup.FieldOperationalCount, channelmonitordailyrollup.FieldDegradedCount, channelmonitordailyrollup.FieldFailedCount, channelmonitordailyrollup.FieldErrorCount, channelmonitordailyrollup.FieldSumLatencyMs, channelmonitordailyrollup.FieldCountLatency, channelmonitordailyrollup.FieldSumPingLatencyMs, channelmonitordailyrollup.FieldCountPingLatency: values[i] = new(sql.NullInt64) case channelmonitordailyrollup.FieldModel: values[i] = new(sql.NullString) case channelmonitordailyrollup.FieldBucketDate, channelmonitordailyrollup.FieldComputedAt: values[i] = new(sql.NullTime) default: values[i] = new(sql.UnknownType) } } return values, nil } // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the ChannelMonitorDailyRollup fields. func (_m *ChannelMonitorDailyRollup) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } for i := range columns { switch columns[i] { case channelmonitordailyrollup.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } _m.ID = int64(value.Int64) case channelmonitordailyrollup.FieldMonitorID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field monitor_id", values[i]) } else if value.Valid { _m.MonitorID = value.Int64 } case channelmonitordailyrollup.FieldModel: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field model", values[i]) } else if value.Valid { _m.Model = value.String } case channelmonitordailyrollup.FieldBucketDate: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field bucket_date", values[i]) } else if value.Valid { _m.BucketDate = value.Time } case channelmonitordailyrollup.FieldTotalChecks: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field total_checks", values[i]) } else if value.Valid { _m.TotalChecks = int(value.Int64) } case channelmonitordailyrollup.FieldOkCount: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field ok_count", values[i]) } else if value.Valid { _m.OkCount = int(value.Int64) } case channelmonitordailyrollup.FieldOperationalCount: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field operational_count", values[i]) } else if value.Valid { _m.OperationalCount = int(value.Int64) } case channelmonitordailyrollup.FieldDegradedCount: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field degraded_count", values[i]) } else if value.Valid { _m.DegradedCount = int(value.Int64) } case channelmonitordailyrollup.FieldFailedCount: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field failed_count", values[i]) } else if value.Valid { _m.FailedCount = int(value.Int64) } case channelmonitordailyrollup.FieldErrorCount: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field error_count", values[i]) } else if value.Valid { _m.ErrorCount = int(value.Int64) } case channelmonitordailyrollup.FieldSumLatencyMs: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field sum_latency_ms", values[i]) } else if value.Valid { _m.SumLatencyMs = value.Int64 } case channelmonitordailyrollup.FieldCountLatency: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field count_latency", values[i]) } else if value.Valid { _m.CountLatency = int(value.Int64) } case channelmonitordailyrollup.FieldSumPingLatencyMs: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field sum_ping_latency_ms", values[i]) } else if value.Valid { _m.SumPingLatencyMs = value.Int64 } case channelmonitordailyrollup.FieldCountPingLatency: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field count_ping_latency", values[i]) } else if value.Valid { _m.CountPingLatency = int(value.Int64) } case channelmonitordailyrollup.FieldComputedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field computed_at", values[i]) } else if value.Valid { _m.ComputedAt = value.Time } default: _m.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the ChannelMonitorDailyRollup. // This includes values selected through modifiers, order, etc. func (_m *ChannelMonitorDailyRollup) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } // QueryMonitor queries the "monitor" edge of the ChannelMonitorDailyRollup entity. func (_m *ChannelMonitorDailyRollup) QueryMonitor() *ChannelMonitorQuery { return NewChannelMonitorDailyRollupClient(_m.config).QueryMonitor(_m) } // Update returns a builder for updating this ChannelMonitorDailyRollup. // Note that you need to call ChannelMonitorDailyRollup.Unwrap() before calling this method if this ChannelMonitorDailyRollup // was returned from a transaction, and the transaction was committed or rolled back. func (_m *ChannelMonitorDailyRollup) Update() *ChannelMonitorDailyRollupUpdateOne { return NewChannelMonitorDailyRollupClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the ChannelMonitorDailyRollup entity that was returned from a transaction after it was closed, // so that all future queries will be executed through the driver which created the transaction. func (_m *ChannelMonitorDailyRollup) Unwrap() *ChannelMonitorDailyRollup { _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: ChannelMonitorDailyRollup is not a transactional entity") } _m.config.driver = _tx.drv return _m } // String implements the fmt.Stringer. func (_m *ChannelMonitorDailyRollup) String() string { var builder strings.Builder builder.WriteString("ChannelMonitorDailyRollup(") builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("monitor_id=") builder.WriteString(fmt.Sprintf("%v", _m.MonitorID)) builder.WriteString(", ") builder.WriteString("model=") builder.WriteString(_m.Model) builder.WriteString(", ") builder.WriteString("bucket_date=") builder.WriteString(_m.BucketDate.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("total_checks=") builder.WriteString(fmt.Sprintf("%v", _m.TotalChecks)) builder.WriteString(", ") builder.WriteString("ok_count=") builder.WriteString(fmt.Sprintf("%v", _m.OkCount)) builder.WriteString(", ") builder.WriteString("operational_count=") builder.WriteString(fmt.Sprintf("%v", _m.OperationalCount)) builder.WriteString(", ") builder.WriteString("degraded_count=") builder.WriteString(fmt.Sprintf("%v", _m.DegradedCount)) builder.WriteString(", ") builder.WriteString("failed_count=") builder.WriteString(fmt.Sprintf("%v", _m.FailedCount)) builder.WriteString(", ") builder.WriteString("error_count=") builder.WriteString(fmt.Sprintf("%v", _m.ErrorCount)) builder.WriteString(", ") builder.WriteString("sum_latency_ms=") builder.WriteString(fmt.Sprintf("%v", _m.SumLatencyMs)) builder.WriteString(", ") builder.WriteString("count_latency=") builder.WriteString(fmt.Sprintf("%v", _m.CountLatency)) builder.WriteString(", ") builder.WriteString("sum_ping_latency_ms=") builder.WriteString(fmt.Sprintf("%v", _m.SumPingLatencyMs)) builder.WriteString(", ") builder.WriteString("count_ping_latency=") builder.WriteString(fmt.Sprintf("%v", _m.CountPingLatency)) builder.WriteString(", ") builder.WriteString("computed_at=") builder.WriteString(_m.ComputedAt.Format(time.ANSIC)) builder.WriteByte(')') return builder.String() } // ChannelMonitorDailyRollups is a parsable slice of ChannelMonitorDailyRollup. type ChannelMonitorDailyRollups []*ChannelMonitorDailyRollup