channelmonitordailyrollup.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "fmt"
  5. "strings"
  6. "time"
  7. "entgo.io/ent"
  8. "entgo.io/ent/dialect/sql"
  9. "github.com/Wei-Shaw/sub2api/ent/channelmonitor"
  10. "github.com/Wei-Shaw/sub2api/ent/channelmonitordailyrollup"
  11. )
  12. // ChannelMonitorDailyRollup is the model entity for the ChannelMonitorDailyRollup schema.
  13. type ChannelMonitorDailyRollup struct {
  14. config `json:"-"`
  15. // ID of the ent.
  16. ID int64 `json:"id,omitempty"`
  17. // MonitorID holds the value of the "monitor_id" field.
  18. MonitorID int64 `json:"monitor_id,omitempty"`
  19. // Model holds the value of the "model" field.
  20. Model string `json:"model,omitempty"`
  21. // BucketDate holds the value of the "bucket_date" field.
  22. BucketDate time.Time `json:"bucket_date,omitempty"`
  23. // TotalChecks holds the value of the "total_checks" field.
  24. TotalChecks int `json:"total_checks,omitempty"`
  25. // OkCount holds the value of the "ok_count" field.
  26. OkCount int `json:"ok_count,omitempty"`
  27. // OperationalCount holds the value of the "operational_count" field.
  28. OperationalCount int `json:"operational_count,omitempty"`
  29. // DegradedCount holds the value of the "degraded_count" field.
  30. DegradedCount int `json:"degraded_count,omitempty"`
  31. // FailedCount holds the value of the "failed_count" field.
  32. FailedCount int `json:"failed_count,omitempty"`
  33. // ErrorCount holds the value of the "error_count" field.
  34. ErrorCount int `json:"error_count,omitempty"`
  35. // SumLatencyMs holds the value of the "sum_latency_ms" field.
  36. SumLatencyMs int64 `json:"sum_latency_ms,omitempty"`
  37. // CountLatency holds the value of the "count_latency" field.
  38. CountLatency int `json:"count_latency,omitempty"`
  39. // SumPingLatencyMs holds the value of the "sum_ping_latency_ms" field.
  40. SumPingLatencyMs int64 `json:"sum_ping_latency_ms,omitempty"`
  41. // CountPingLatency holds the value of the "count_ping_latency" field.
  42. CountPingLatency int `json:"count_ping_latency,omitempty"`
  43. // ComputedAt holds the value of the "computed_at" field.
  44. ComputedAt time.Time `json:"computed_at,omitempty"`
  45. // Edges holds the relations/edges for other nodes in the graph.
  46. // The values are being populated by the ChannelMonitorDailyRollupQuery when eager-loading is set.
  47. Edges ChannelMonitorDailyRollupEdges `json:"edges"`
  48. selectValues sql.SelectValues
  49. }
  50. // ChannelMonitorDailyRollupEdges holds the relations/edges for other nodes in the graph.
  51. type ChannelMonitorDailyRollupEdges struct {
  52. // Monitor holds the value of the monitor edge.
  53. Monitor *ChannelMonitor `json:"monitor,omitempty"`
  54. // loadedTypes holds the information for reporting if a
  55. // type was loaded (or requested) in eager-loading or not.
  56. loadedTypes [1]bool
  57. }
  58. // MonitorOrErr returns the Monitor value or an error if the edge
  59. // was not loaded in eager-loading, or loaded but was not found.
  60. func (e ChannelMonitorDailyRollupEdges) MonitorOrErr() (*ChannelMonitor, error) {
  61. if e.Monitor != nil {
  62. return e.Monitor, nil
  63. } else if e.loadedTypes[0] {
  64. return nil, &NotFoundError{label: channelmonitor.Label}
  65. }
  66. return nil, &NotLoadedError{edge: "monitor"}
  67. }
  68. // scanValues returns the types for scanning values from sql.Rows.
  69. func (*ChannelMonitorDailyRollup) scanValues(columns []string) ([]any, error) {
  70. values := make([]any, len(columns))
  71. for i := range columns {
  72. switch columns[i] {
  73. 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:
  74. values[i] = new(sql.NullInt64)
  75. case channelmonitordailyrollup.FieldModel:
  76. values[i] = new(sql.NullString)
  77. case channelmonitordailyrollup.FieldBucketDate, channelmonitordailyrollup.FieldComputedAt:
  78. values[i] = new(sql.NullTime)
  79. default:
  80. values[i] = new(sql.UnknownType)
  81. }
  82. }
  83. return values, nil
  84. }
  85. // assignValues assigns the values that were returned from sql.Rows (after scanning)
  86. // to the ChannelMonitorDailyRollup fields.
  87. func (_m *ChannelMonitorDailyRollup) assignValues(columns []string, values []any) error {
  88. if m, n := len(values), len(columns); m < n {
  89. return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
  90. }
  91. for i := range columns {
  92. switch columns[i] {
  93. case channelmonitordailyrollup.FieldID:
  94. value, ok := values[i].(*sql.NullInt64)
  95. if !ok {
  96. return fmt.Errorf("unexpected type %T for field id", value)
  97. }
  98. _m.ID = int64(value.Int64)
  99. case channelmonitordailyrollup.FieldMonitorID:
  100. if value, ok := values[i].(*sql.NullInt64); !ok {
  101. return fmt.Errorf("unexpected type %T for field monitor_id", values[i])
  102. } else if value.Valid {
  103. _m.MonitorID = value.Int64
  104. }
  105. case channelmonitordailyrollup.FieldModel:
  106. if value, ok := values[i].(*sql.NullString); !ok {
  107. return fmt.Errorf("unexpected type %T for field model", values[i])
  108. } else if value.Valid {
  109. _m.Model = value.String
  110. }
  111. case channelmonitordailyrollup.FieldBucketDate:
  112. if value, ok := values[i].(*sql.NullTime); !ok {
  113. return fmt.Errorf("unexpected type %T for field bucket_date", values[i])
  114. } else if value.Valid {
  115. _m.BucketDate = value.Time
  116. }
  117. case channelmonitordailyrollup.FieldTotalChecks:
  118. if value, ok := values[i].(*sql.NullInt64); !ok {
  119. return fmt.Errorf("unexpected type %T for field total_checks", values[i])
  120. } else if value.Valid {
  121. _m.TotalChecks = int(value.Int64)
  122. }
  123. case channelmonitordailyrollup.FieldOkCount:
  124. if value, ok := values[i].(*sql.NullInt64); !ok {
  125. return fmt.Errorf("unexpected type %T for field ok_count", values[i])
  126. } else if value.Valid {
  127. _m.OkCount = int(value.Int64)
  128. }
  129. case channelmonitordailyrollup.FieldOperationalCount:
  130. if value, ok := values[i].(*sql.NullInt64); !ok {
  131. return fmt.Errorf("unexpected type %T for field operational_count", values[i])
  132. } else if value.Valid {
  133. _m.OperationalCount = int(value.Int64)
  134. }
  135. case channelmonitordailyrollup.FieldDegradedCount:
  136. if value, ok := values[i].(*sql.NullInt64); !ok {
  137. return fmt.Errorf("unexpected type %T for field degraded_count", values[i])
  138. } else if value.Valid {
  139. _m.DegradedCount = int(value.Int64)
  140. }
  141. case channelmonitordailyrollup.FieldFailedCount:
  142. if value, ok := values[i].(*sql.NullInt64); !ok {
  143. return fmt.Errorf("unexpected type %T for field failed_count", values[i])
  144. } else if value.Valid {
  145. _m.FailedCount = int(value.Int64)
  146. }
  147. case channelmonitordailyrollup.FieldErrorCount:
  148. if value, ok := values[i].(*sql.NullInt64); !ok {
  149. return fmt.Errorf("unexpected type %T for field error_count", values[i])
  150. } else if value.Valid {
  151. _m.ErrorCount = int(value.Int64)
  152. }
  153. case channelmonitordailyrollup.FieldSumLatencyMs:
  154. if value, ok := values[i].(*sql.NullInt64); !ok {
  155. return fmt.Errorf("unexpected type %T for field sum_latency_ms", values[i])
  156. } else if value.Valid {
  157. _m.SumLatencyMs = value.Int64
  158. }
  159. case channelmonitordailyrollup.FieldCountLatency:
  160. if value, ok := values[i].(*sql.NullInt64); !ok {
  161. return fmt.Errorf("unexpected type %T for field count_latency", values[i])
  162. } else if value.Valid {
  163. _m.CountLatency = int(value.Int64)
  164. }
  165. case channelmonitordailyrollup.FieldSumPingLatencyMs:
  166. if value, ok := values[i].(*sql.NullInt64); !ok {
  167. return fmt.Errorf("unexpected type %T for field sum_ping_latency_ms", values[i])
  168. } else if value.Valid {
  169. _m.SumPingLatencyMs = value.Int64
  170. }
  171. case channelmonitordailyrollup.FieldCountPingLatency:
  172. if value, ok := values[i].(*sql.NullInt64); !ok {
  173. return fmt.Errorf("unexpected type %T for field count_ping_latency", values[i])
  174. } else if value.Valid {
  175. _m.CountPingLatency = int(value.Int64)
  176. }
  177. case channelmonitordailyrollup.FieldComputedAt:
  178. if value, ok := values[i].(*sql.NullTime); !ok {
  179. return fmt.Errorf("unexpected type %T for field computed_at", values[i])
  180. } else if value.Valid {
  181. _m.ComputedAt = value.Time
  182. }
  183. default:
  184. _m.selectValues.Set(columns[i], values[i])
  185. }
  186. }
  187. return nil
  188. }
  189. // Value returns the ent.Value that was dynamically selected and assigned to the ChannelMonitorDailyRollup.
  190. // This includes values selected through modifiers, order, etc.
  191. func (_m *ChannelMonitorDailyRollup) Value(name string) (ent.Value, error) {
  192. return _m.selectValues.Get(name)
  193. }
  194. // QueryMonitor queries the "monitor" edge of the ChannelMonitorDailyRollup entity.
  195. func (_m *ChannelMonitorDailyRollup) QueryMonitor() *ChannelMonitorQuery {
  196. return NewChannelMonitorDailyRollupClient(_m.config).QueryMonitor(_m)
  197. }
  198. // Update returns a builder for updating this ChannelMonitorDailyRollup.
  199. // Note that you need to call ChannelMonitorDailyRollup.Unwrap() before calling this method if this ChannelMonitorDailyRollup
  200. // was returned from a transaction, and the transaction was committed or rolled back.
  201. func (_m *ChannelMonitorDailyRollup) Update() *ChannelMonitorDailyRollupUpdateOne {
  202. return NewChannelMonitorDailyRollupClient(_m.config).UpdateOne(_m)
  203. }
  204. // Unwrap unwraps the ChannelMonitorDailyRollup entity that was returned from a transaction after it was closed,
  205. // so that all future queries will be executed through the driver which created the transaction.
  206. func (_m *ChannelMonitorDailyRollup) Unwrap() *ChannelMonitorDailyRollup {
  207. _tx, ok := _m.config.driver.(*txDriver)
  208. if !ok {
  209. panic("ent: ChannelMonitorDailyRollup is not a transactional entity")
  210. }
  211. _m.config.driver = _tx.drv
  212. return _m
  213. }
  214. // String implements the fmt.Stringer.
  215. func (_m *ChannelMonitorDailyRollup) String() string {
  216. var builder strings.Builder
  217. builder.WriteString("ChannelMonitorDailyRollup(")
  218. builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
  219. builder.WriteString("monitor_id=")
  220. builder.WriteString(fmt.Sprintf("%v", _m.MonitorID))
  221. builder.WriteString(", ")
  222. builder.WriteString("model=")
  223. builder.WriteString(_m.Model)
  224. builder.WriteString(", ")
  225. builder.WriteString("bucket_date=")
  226. builder.WriteString(_m.BucketDate.Format(time.ANSIC))
  227. builder.WriteString(", ")
  228. builder.WriteString("total_checks=")
  229. builder.WriteString(fmt.Sprintf("%v", _m.TotalChecks))
  230. builder.WriteString(", ")
  231. builder.WriteString("ok_count=")
  232. builder.WriteString(fmt.Sprintf("%v", _m.OkCount))
  233. builder.WriteString(", ")
  234. builder.WriteString("operational_count=")
  235. builder.WriteString(fmt.Sprintf("%v", _m.OperationalCount))
  236. builder.WriteString(", ")
  237. builder.WriteString("degraded_count=")
  238. builder.WriteString(fmt.Sprintf("%v", _m.DegradedCount))
  239. builder.WriteString(", ")
  240. builder.WriteString("failed_count=")
  241. builder.WriteString(fmt.Sprintf("%v", _m.FailedCount))
  242. builder.WriteString(", ")
  243. builder.WriteString("error_count=")
  244. builder.WriteString(fmt.Sprintf("%v", _m.ErrorCount))
  245. builder.WriteString(", ")
  246. builder.WriteString("sum_latency_ms=")
  247. builder.WriteString(fmt.Sprintf("%v", _m.SumLatencyMs))
  248. builder.WriteString(", ")
  249. builder.WriteString("count_latency=")
  250. builder.WriteString(fmt.Sprintf("%v", _m.CountLatency))
  251. builder.WriteString(", ")
  252. builder.WriteString("sum_ping_latency_ms=")
  253. builder.WriteString(fmt.Sprintf("%v", _m.SumPingLatencyMs))
  254. builder.WriteString(", ")
  255. builder.WriteString("count_ping_latency=")
  256. builder.WriteString(fmt.Sprintf("%v", _m.CountPingLatency))
  257. builder.WriteString(", ")
  258. builder.WriteString("computed_at=")
  259. builder.WriteString(_m.ComputedAt.Format(time.ANSIC))
  260. builder.WriteByte(')')
  261. return builder.String()
  262. }
  263. // ChannelMonitorDailyRollups is a parsable slice of ChannelMonitorDailyRollup.
  264. type ChannelMonitorDailyRollups []*ChannelMonitorDailyRollup