statistics.go 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. package model
  2. // ExpiredOneDay ...
  3. const ExpiredOneDay = 86400
  4. // Status ...
  5. const (
  6. StatusCancel = "cancel"
  7. StatusMerged = "merged"
  8. StatusClosed = "closed"
  9. )
  10. // number per year.
  11. const (
  12. MonthNumPerYear = 12
  13. DayNumPerYear = 365
  14. DayNumPerWeek = 7
  15. DayNumPerMonth = 30
  16. )
  17. // query type.
  18. const (
  19. LastYearPerMonth = iota
  20. LastMonthPerDay
  21. LastYearPerDay
  22. LastWeekPerDay
  23. )
  24. // query type note.
  25. const (
  26. LastYearPerMonthNote = "最近一年每月数量"
  27. LastMonthPerDayNote = "上一月每天数量"
  28. LastYearPerDayNote = "最近一年每天数量"
  29. )
  30. // query object type.
  31. const (
  32. ObjectMR = "mr"
  33. ObjectCommit = "commit"
  34. ObjectSaga = "saga"
  35. ObjectRunner = "runner"
  36. )
  37. // KeyTypeConst ...
  38. var KeyTypeConst = map[int]string{
  39. 0: "LastYearPerMonth",
  40. 1: "LastMonthPerDay",
  41. 2: "LastYearPerDay",
  42. 3: "LastWeekPerDay",
  43. }
  44. // CommitRequest ...
  45. type CommitRequest struct {
  46. TeamParam
  47. Since string `form:"since"`
  48. Until string `form:"until"`
  49. Username string `form:"username"`
  50. }
  51. // ProjectCommit ...
  52. type ProjectCommit struct {
  53. ProjectID int `json:"project_id"`
  54. Name string `json:"name"`
  55. CommitNum int `json:"commit_num"`
  56. }
  57. // CommitResp ...
  58. type CommitResp struct {
  59. Total int `json:"total"`
  60. ProjectCommit []*ProjectCommit `json:"commit_per_project"`
  61. }
  62. // ProjectDataReq ...
  63. type ProjectDataReq struct {
  64. ProjectID int `form:"project_id" validate:"required"`
  65. ProjectName string `form:"project_name"`
  66. QueryType int `form:"query_type"`
  67. Username string `form:"username"`
  68. }
  69. // ProjectDataResp ...
  70. type ProjectDataResp struct {
  71. ProjectName string `json:"project_name"`
  72. QueryDes string `json:"query_description"`
  73. Total int `json:"total"`
  74. Data []*DataWithTime `json:"data_info"`
  75. }
  76. // TeamDataRequest ...
  77. type TeamDataRequest struct {
  78. TeamParam
  79. QueryType int `form:"query_type"`
  80. Username string `form:"username"`
  81. }
  82. // TeamDataResp ...
  83. type TeamDataResp struct {
  84. Department string `json:"department"`
  85. Business string `json:"business"`
  86. QueryDes string `json:"query_description"`
  87. Total int `json:"total"`
  88. Data []*DataWithTime `json:"data_info"`
  89. }
  90. // DataWithTime ...
  91. type DataWithTime struct {
  92. TotalItem int `json:"total_item"`
  93. StartTime string `json:"start_time"`
  94. EndTime string `json:"end_time"`
  95. }
  96. // PipelineDataTime ...
  97. type PipelineDataTime struct {
  98. TotalItem int `json:"total_item"`
  99. SuccessItem int `json:"success_item"`
  100. StartTime string `json:"start_time"`
  101. EndTime string `json:"end_time"`
  102. }
  103. // PipelineDataResp ...
  104. type PipelineDataResp struct {
  105. Department string `json:"department"`
  106. Business string `json:"business"`
  107. QueryDes string `json:"query_description"`
  108. Total int `json:"total"`
  109. SuccessNum int `json:"success_num"`
  110. SuccessScale int `json:"success_scale"`
  111. Data []*PipelineDataTime `json:"data_info"`
  112. }
  113. // PipelineDataReq ...
  114. type PipelineDataReq struct {
  115. ProjectID int `form:"project_id" validate:"required"`
  116. ProjectName string `form:"project_name"`
  117. Branch string `form:"branch"`
  118. State string `form:"state"`
  119. User string `form:"user"`
  120. Type int `form:"query_type"` //0 最近一年每月数量;1 上一月每天数量;2 最近一年每天数量
  121. StatisticsType int `form:"statistics_type"`
  122. Username string `form:"username"`
  123. }
  124. // PipelineDataAvgResp ...
  125. type PipelineDataAvgResp struct {
  126. ProjectName string `json:"project_name"`
  127. QueryDes string `json:"query_description"`
  128. Status string `json:"status"`
  129. Total int `json:"total"`
  130. TotalStatus int `json:"total_status"`
  131. AvgDurationTime float64 `json:"avg_duration_time"`
  132. AvgPendingTime float64 `json:"avg_pending_time"`
  133. AvgRunningTime float64 `json:"avg_running_time"`
  134. Data []*PipelineDataAvg `json:"data_info"`
  135. }
  136. // PipelineDataAvg ...
  137. type PipelineDataAvg struct {
  138. TotalItem int `json:"total_item"`
  139. TotalStatusItem int `json:"total_status_item"`
  140. AvgDurationTime float64 `json:"avg_total_time"`
  141. MaxDurationTime float64 `json:"max_duration_time"`
  142. MinDurationTime float64 `json:"min_duration_time"`
  143. AvgPendingTime float64 `json:"avg_pending_time"`
  144. MaxPendingTime float64 `json:"max_pending_time"`
  145. MinPendingTime float64 `json:"min_pending_time"`
  146. AvgRunningTime float64 `json:"avg_running_time"`
  147. MaxRunningTime float64 `json:"max_running_time"`
  148. MinRunningTime float64 `json:"min_running_time"`
  149. StartTime string `json:"start_time"`
  150. EndTime string `json:"end_time"`
  151. }
  152. // PipelineTime ...
  153. type PipelineTime struct {
  154. PendingMax float64
  155. PendingMin float64
  156. RunningMax float64
  157. RunningMin float64
  158. DurationMax float64
  159. DurationMin float64
  160. PendingList []float64
  161. RunningList []float64
  162. DurationList []float64
  163. }
  164. // AlertPipeline ...
  165. type AlertPipeline struct {
  166. ProjectName string
  167. ProjectID int
  168. RunningTimeout int
  169. RunningRate int
  170. RunningThreshold int
  171. PendingTimeout int
  172. PendingThreshold int
  173. }