ut.go 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. package ut
  2. import (
  3. "go-common/library/time"
  4. )
  5. // TableName .
  6. func (*Merge) TableName() string {
  7. return "ut_merge"
  8. }
  9. // TableName .
  10. func (*Commit) TableName() string {
  11. return "ut_commit"
  12. }
  13. // TableName .
  14. func (*PkgAnls) TableName() string {
  15. return "ut_pkganls"
  16. }
  17. // TableName .
  18. func (*File) TableName() string {
  19. return "ut_file"
  20. }
  21. // Merge ut_merge table from db.
  22. type Merge struct {
  23. ID int64 `gorm:"column:id" json:"id"`
  24. MergeID int64 `gorm:"column:merge_id" json:"merge_id"`
  25. IsMerged int8 `gorm:"column:is_merged" json:"is_merged"`
  26. UserName string `gorm:"column:username" json:"username"`
  27. Commit *Commit `gorm:"-" json:"commit"`
  28. NoteID int `gorm:"column:note_id"`
  29. CTime time.Time `gorm:"column:ctime" json:"ctime"`
  30. MTime time.Time `gorm:"column:mtime" json:"mtime"`
  31. }
  32. // Commit ut_commit table from db.
  33. type Commit struct {
  34. ID int64 `gorm:"column:id" json:"id"`
  35. MergeID int64 `gorm:"column:merge_id" json:"merge_id"`
  36. CommitID string `gorm:"column:commit_id" json:"commit_id"`
  37. UserName string `gorm:"column:username" json:"username"`
  38. PkgAnls []*PkgAnls `gorm:"-" json:"pkganls"`
  39. CTime time.Time `gorm:"column:ctime" json:"ctime"`
  40. MTime time.Time `gorm:"column:mtime" json:"mtime"`
  41. }
  42. // PkgAnls ut_pkganls table from db.
  43. type PkgAnls struct {
  44. ID int64 `gorm:"column:id" json:"id"`
  45. MergeID int64 `gorm:"column:merge_id" json:"merge_id"`
  46. CommitID string `gorm:"column:commit_id" json:"commit_id"`
  47. PKG string `gorm:"column:pkg" json:"pkg"`
  48. Assertions int64 `gorm:"column:assertions" json:"assertions"`
  49. Passed int64 `gorm:"column:passed" json:"passed"`
  50. Skipped int64 `gorm:"column:skipped" json:"skipped"`
  51. Failures int64 `gorm:"column:failures" json:"failures"`
  52. Panics int64 `gorm:"column:panics" json:"panics"`
  53. Coverage float64 `gorm:"column:coverage" json:"coverage"`
  54. Coverages string `gorm:"-" json:"coverages"`
  55. CovChange float64 `gorm:"-" json:"cov_change"`
  56. PassRate float64 `gorm:"-" json:"pass_rate"`
  57. PassRates string `gorm:"-" json:"pass_rates"`
  58. Score float64 `gorm:"-" json:"score"`
  59. HTMLURL string `gorm:"column:html_url" json:"html_url"`
  60. ReportURL string `gorm:"column:report_url" json:"report_url"`
  61. DataURL string `gorm:"column:data_url" json:"data_url"`
  62. Files []*File `gorm:"-" json:"files"`
  63. CTime time.Time `gorm:"column:ctime" json:"ctime"`
  64. MTime time.Time `gorm:"column:mtime" json:"mtime"`
  65. Cids string `gorm:"-" json:"-"`
  66. }
  67. // MergeReq merge list req struct.
  68. type MergeReq struct {
  69. MergeID int64 `form:"merge_id" default:"0"`
  70. UserName string `form:"username" default:""`
  71. IsMerged int8 `form:"is_merged"`
  72. Pn int `form:"pn" default:"1"`
  73. Ps int `form:"ps" default:"20"`
  74. }
  75. // DetailReq .
  76. type DetailReq struct {
  77. CommitID string `form:"commit_id"`
  78. PKG string `form:"pkg"`
  79. }
  80. //HistoryCommitReq struct
  81. type HistoryCommitReq struct {
  82. MergeID int64 `form:"merge_id" validate:"required"`
  83. //CommitID string `form:"commit_id"`
  84. Pn int `form:"pn" default:"1"`
  85. Ps int `form:"ps" default:"20"`
  86. }
  87. // Tyrant .
  88. type Tyrant struct {
  89. Package string `json:"package"`
  90. Coverage float64 `json:"coverage"`
  91. PassRate float64 `json:"pass_rate"`
  92. Increase float64 `json:"increase"`
  93. LastCID string `json:"last_cid"`
  94. Standard int `json:"standard"`
  95. Tyrant bool `json:"tyrant"`
  96. }
  97. // UploadRes .
  98. type UploadRes struct {
  99. MergeID int64 `form:"merge_id" validate:"required"`
  100. CommitID string `form:"commit_id" validate:"required"`
  101. UserName string `form:"username" validate:"required"`
  102. Author string `form:"author"`
  103. PKG string `form:"pkg" validate:"required"`
  104. }
  105. // SAGAResponse .
  106. type SAGAResponse struct {
  107. Coverage float64 `json:"coverage"`
  108. PKG string `json:"pkg"`
  109. }
  110. //QATrendReq is
  111. type QATrendReq struct {
  112. User string `form:"user"`
  113. Period string `form:"period" default:"day"`
  114. LastTime int `form:"last_time" default:"30"`
  115. StartTime int64 `form:"start_time"`
  116. EndTime int64 `form:"end_time"`
  117. }
  118. //QATrendResp is
  119. type QATrendResp struct {
  120. Dates []string `json:"dates"`
  121. CommitIDs []string `json:"commit_ids"`
  122. Coverages []float64 `json:"coverages"`
  123. PassRates []float64 `json:"pass_rates"`
  124. Scores []float64 `json:"scores"`
  125. BaseLine int `json:"baseline"`
  126. }
  127. //CommitInfo is
  128. type CommitInfo struct {
  129. MergeID int64 `gorm:"column:merge_id" json:"merge_id"`
  130. CommitID string `gorm:"column:commit_id" json:"-"`
  131. MTime time.Time `gorm:"column:mtime" json:"mtime"`
  132. Coverage float64 `gorm:"-" json:"coverage"`
  133. PassRate float64 `gorm:"-" json:"pass_rate"`
  134. GitlabCommit *GitlabCommit `gorm:"-" json:"gitlab_commit"`
  135. }
  136. //GitlabCommit is
  137. type GitlabCommit struct {
  138. ID string `json:"id"`
  139. ShortID string `json:"short_id"`
  140. Title string `json:"title"`
  141. AuthorName string `json:"author_name"`
  142. Status string `json:"status"`
  143. ProjectID int64 `json:"project_id"`
  144. }
  145. // WechatUsersMsg is used for sending wechat msg for users
  146. type WechatUsersMsg struct {
  147. ToUser []string `json:"touser"`
  148. Content string `json:"content"`
  149. }
  150. // WechatGroupMsg is used for sending wechat msg for group
  151. type WechatGroupMsg struct {
  152. ChatID string `json:"chatid"`
  153. MsgType string `json:"msgtype"`
  154. Text *TextContent `json:"text"`
  155. Safe int `json:"safe"`
  156. }
  157. // TextContent textContent
  158. type TextContent struct {
  159. Content string `json:"content"`
  160. }
  161. // File file
  162. type File struct {
  163. ID int64 `gorm:"column:id"`
  164. CommitID string `gorm:"column:commit_id"`
  165. PKG string `gorm:"column:pkg"`
  166. Name string `gorm:"column:name"`
  167. Statements int64 `gorm:"colum:statements"`
  168. CoveredStatements int64 `gorm:"column:covered_statements"`
  169. Coverage float64 `gorm:"-"`
  170. CTime time.Time `gorm:"column:ctime"`
  171. MTime time.Time `gorm:"column:mtime"`
  172. }
  173. // Block block
  174. type Block struct {
  175. Start int
  176. End int
  177. Statements int
  178. Count int
  179. }