sync.go 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. package model
  2. import (
  3. "time"
  4. "github.com/xanzy/go-gitlab"
  5. )
  6. // DatabaseErrorText ...
  7. const (
  8. DatabaseErrorText = "Incorrect string value"
  9. DatabaseMaxLenthErrorText = "Data too long for column"
  10. MessageMaxLen = 2048
  11. JsonMarshalErrorText = "XXXXX"
  12. )
  13. // DataType ...
  14. const (
  15. DataTypePipeline = "pipeline"
  16. DataTypeJob = "job"
  17. DataTypeCommit = "commit"
  18. DataTypeMR = "MR"
  19. DataTypeBranch = "Branch"
  20. )
  21. // FailData ...
  22. type FailData struct {
  23. ChildID int
  24. ChildIDStr string
  25. SunID int
  26. }
  27. // SyncResult ...
  28. type SyncResult struct {
  29. TotalPage int
  30. TotalNum int
  31. FailData []*FailData
  32. }
  33. // StatisticsCommits ...
  34. type StatisticsCommits struct {
  35. ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
  36. CommitID string `json:"commit_id"`
  37. ProjectID int `json:"project_id" gorm:"column:project_id"`
  38. ProjectName string `json:"project_name"`
  39. ShortID string `json:"short_id"`
  40. Title string `json:"title"`
  41. AuthorName string `json:"author_name"`
  42. AuthoredDate *time.Time `json:"authored_date"`
  43. CommitterName string `json:"committer_name"`
  44. CommittedDate *time.Time `json:"committed_date"`
  45. CreatedAt *time.Time `json:"created_at"`
  46. Message string `json:"message"`
  47. ParentIDs string `json:"parent_ids"`
  48. StatsAdditions int `json:"stats_additions"`
  49. StatsDeletions int `json:"stats_deletions"`
  50. Status string `json:"status" default:""`
  51. }
  52. // StatisticsIssues ...
  53. type StatisticsIssues struct {
  54. ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
  55. ProjectID int `json:"project_id"`
  56. IssueID int `json:"issue_id"`
  57. IssueIID int `json:"issue_iid" gorm:"column:issue_iid"`
  58. MilestoneID int `json:"milestone_id"`
  59. AuthorID int `json:"author_id"`
  60. AuthorName string `json:"author_name"`
  61. Description string `json:"description"`
  62. State string `json:"state"`
  63. Assignees string `json:"assignees"`
  64. AssigneeID int `json:"assignee_id"`
  65. AssigneeName string `json:"assignee_name"`
  66. Upvotes int `json:"upvotes"`
  67. Downvotes int `json:"downvotes"`
  68. Labels string `json:"labels"`
  69. Title string `json:"title"`
  70. UpdatedAt *time.Time `json:"updated_at"`
  71. CreatedAt *time.Time `json:"created_at"`
  72. ClosedAt *time.Time `json:"closed_at"`
  73. Subscribed bool `json:"subscribed"`
  74. UserNotesCount int `json:"user_notes_count"`
  75. DueDate *gitlab.ISOTime `json:"due_date"`
  76. WebURL string `json:"web_url"`
  77. TimeStats string `json:"time_stats"`
  78. Confidential bool `json:"confidential"`
  79. Weight int `json:"weight"`
  80. DiscussionLocked bool `json:"discussion_locked"`
  81. IssueLinkID int `json:"issue_link_id"`
  82. }
  83. // StatisticsRunners ...
  84. type StatisticsRunners struct {
  85. ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
  86. ProjectID int `json:"project_id"`
  87. ProjectName string `json:"project_name"`
  88. RunnerID int `json:"runner_id"`
  89. Description string `json:"description"`
  90. Active bool `json:"active"`
  91. IsShared bool `json:"is_shared"`
  92. IPAddress string `json:"ip_address"`
  93. Name string `json:"name"`
  94. Online bool `json:"online"`
  95. Status string `json:"status"`
  96. Token string `json:"token"`
  97. }
  98. // StatisticsJobs ...
  99. type StatisticsJobs struct {
  100. ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
  101. ProjectID int `json:"project_id"`
  102. ProjectName string `json:"project_name"`
  103. CommitID string `json:"commit_id"`
  104. CreatedAt *time.Time `json:"created_at"`
  105. Coverage float64 `json:"coverage"`
  106. ArtifactsFile string `json:"artifacts_file"`
  107. FinishedAt *time.Time `json:"finished_at"`
  108. JobID int `json:"job_id"`
  109. Name string `json:"name"`
  110. Ref string `json:"ref"`
  111. RunnerID int `json:"runner_id"`
  112. RunnerDescription string `json:"runner_description"`
  113. Stage string `json:"stage"`
  114. StartedAt *time.Time `json:"started_at"`
  115. Status string `json:"status"`
  116. Tag bool `json:"tag"`
  117. UserID int `json:"user_id"`
  118. UserName string `json:"user_name"`
  119. WebURL string `json:"web_url"`
  120. }
  121. // StatisticsMrs ...
  122. type StatisticsMrs struct {
  123. ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
  124. MRID int `json:"mr_id"`
  125. MRIID int `json:"mr_iid" gorm:"column:mr_iid"`
  126. TargetBranch string `json:"target_branch"`
  127. SourceBranch string `json:"source_branch"`
  128. ProjectID int `json:"project_id"`
  129. ProjectName string `json:"project_name"`
  130. Title string `json:"title"`
  131. State string `json:"state"`
  132. CreatedAt *time.Time `json:"created_at"`
  133. UpdatedAt *time.Time `json:"updated_at"`
  134. Upvotes int `json:"upvotes"`
  135. Downvotes int `json:"downvotes"`
  136. AuthorID int `json:"author_id"`
  137. AuthorName string `json:"author_name"`
  138. AssigneeID int `json:"assignee_id"`
  139. AssigneeName string `json:"assignee_name"`
  140. SourceProjectID int `json:"source_project_id"`
  141. TargetProjectID int `json:"target_project_id"`
  142. Labels string `json:"labels"`
  143. Description string `json:"description"`
  144. WorkInProgress bool `json:"work_in_progress"`
  145. MilestoneID int `json:"milestone_id"`
  146. MergeWhenPipelineSucceeds bool `json:"merge_when_pipeline_succeeds"`
  147. MergeStatus string `json:"merge_status"`
  148. MergedByID int `json:"merged_by_id"`
  149. MergedByName string `json:"merged_by_name"`
  150. MergedAt *time.Time `json:"merged_at"`
  151. ClosedByID int `json:"closed_by_id"`
  152. ClosedAt *time.Time `json:"closed_at"`
  153. Subscribed bool `json:"subscribed"`
  154. SHA string `json:"sha"`
  155. MergeCommitSHA string `json:"merge_commit_sha"`
  156. UserNotesCount int `json:"user_notes_count"`
  157. ChangesCount string `json:"changes_count"`
  158. ShouldRemoveSourceBranch bool `json:"should_remove_source_branch"`
  159. ForceRemoveSourceBranch bool `json:"force_remove_source_branch"`
  160. WebURL string `json:"web_url"`
  161. DiscussionLocked bool `json:"discussion_locked"`
  162. Changes string `json:"changes"`
  163. TimeStatsHumanTimeEstimate string `json:"time_stats_human_time_estimate"`
  164. TimeStatsHumanTotalTimeSpent string `json:"time_stats_human_total_time_spent"`
  165. TimeStatsTimeEstimate int `json:"time_stats_time_estimate"`
  166. TimeStatsTotalTimeSpent int `json:"time_stats_total_time_spent"`
  167. Squash bool `json:"squash"`
  168. PipelineID int `json:"pipeline_id"`
  169. ChangeAdd int `json:"change_add"`
  170. ChangeDel int `json:"change_del"`
  171. TotalDiscussion int `json:"total_discussion"`
  172. SolvedDiscussion int `json:"solved_discussion"`
  173. }
  174. // AggregateMrReviewer ...
  175. type AggregateMrReviewer struct {
  176. ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
  177. ProjectID int `json:"project_id"`
  178. ProjectName string `json:"project_name"`
  179. MrIID int `json:"mr_iid" gorm:"column:mr_iid"`
  180. Title string `json:"title"`
  181. WebUrl string `json:"web_url"`
  182. AuthorName string `json:"author_name"`
  183. ReviewerID int `json:"reviewer_id"`
  184. ReviewerName string `json:"reviewer_name"`
  185. ReviewType string `json:"review_type"`
  186. ReviewID int `json:"review_id"`
  187. ReviewCommand string `json:"review_command"`
  188. CreatedAt *time.Time `json:"created_at"`
  189. UserType string `json:"type"`
  190. ApproveTime int `json:"approve_time"` // SpentTime 其实是反应时间+review时间
  191. MergeTime int `json:"merge_time"`
  192. }
  193. // StatisticsPipeline ...
  194. type StatisticsPipeline struct {
  195. ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
  196. PipelineID int `json:"pipeline_id" gorm:"column:pipeline_id"`
  197. ProjectName string `json:"project_name"`
  198. ProjectID int `json:"project_id" gorm:"column:project_id"`
  199. Status string `json:"status" gorm:"column:status" default:""`
  200. Ref string `json:"ref" gorm:"column:ref"`
  201. Tag bool `json:"tag" gorm:"column:tag"`
  202. User string `json:"user" gorm:"column:user"`
  203. UpdatedAt *time.Time `json:"updated_at" gorm:"column:updated_at"`
  204. CreatedAt *time.Time `json:"created_at" gorm:"column:created_at"`
  205. StartedAt *time.Time `json:"started_at" gorm:"column:started_at"`
  206. FinishedAt *time.Time `json:"finished_at" gorm:"column:finished_at"`
  207. CommittedAt *time.Time `json:"committed_at" gorm:"column:committed_at"`
  208. Duration int `json:"duration" gorm:"column:duration"`
  209. Coverage string `json:"coverage" gorm:"column:coverage"`
  210. DurationTime int `json:"duration_time"`
  211. }
  212. // StatisticsNotes ...
  213. type StatisticsNotes struct {
  214. ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
  215. ProjectID int `json:"project_id"`
  216. ProjectName string `json:"project_name"`
  217. MrIID int `json:"mr_iid" gorm:"column:mr_iid"`
  218. IssueIID int `json:"issue_iid" gorm:"column:issue_iid"`
  219. NoteID int `json:"note_id"`
  220. Body string `json:"body"`
  221. Attachment string `json:"attachment"`
  222. Title string `json:"title"`
  223. FileName string `json:"file_name"`
  224. AuthorID int `json:"author_id"`
  225. AuthorName string `json:"author_name"`
  226. System bool `json:"system"`
  227. ExpiresAt *time.Time `json:"expires_at"`
  228. UpdatedAt *time.Time `json:"updated_at"`
  229. CreatedAt *time.Time `json:"created_at"`
  230. NoteableID int `json:"noteable_id"`
  231. NoteableType string `json:"noteable_type"`
  232. Position string `json:"position"`
  233. Resolvable bool `json:"resolvable"`
  234. Resolved bool `json:"resolved"`
  235. ResolvedByID int `json:"resolved_by_id"`
  236. ResolvedByName string `json:"resolved_by_name"`
  237. NoteableIID int `json:"noteable_iid" gorm:"column:noteable_iid"`
  238. }
  239. // StatisticsMembers ...
  240. type StatisticsMembers struct {
  241. ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
  242. ProjectID int `json:"project_id"`
  243. ProjectName string `json:"project_name"`
  244. MemberID int `json:"member_id"`
  245. Username string `json:"username"`
  246. Email string `json:"email"`
  247. Name string `json:"name"`
  248. State string `json:"state"`
  249. CreatedAt *time.Time `json:"created_at"`
  250. AccessLevel int `json:"access_level"`
  251. }
  252. // StatisticsMRAwardEmojis ...
  253. type StatisticsMRAwardEmojis struct {
  254. ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
  255. ProjectID int `json:"project_id"`
  256. ProjectName string `json:"project_name"`
  257. MrIID int `json:"mr_iid" gorm:"column:mr_iid"`
  258. AwardEmojiID int `json:"award_emoji_id"`
  259. Name string `json:"name"`
  260. UserID int `json:"user_id"`
  261. UserName string `json:"user_name"`
  262. CreatedAt *time.Time `json:"created_at"`
  263. UpdatedAt *time.Time `json:"updated_at"`
  264. AwardableID int `json:"awardable_id"`
  265. AwardableType string `json:"awardable_type"`
  266. }
  267. // StatisticsDiscussions ...
  268. type StatisticsDiscussions struct {
  269. ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
  270. ProjectID int `json:"project_id"`
  271. ProjectName string `json:"project_name"`
  272. MrIID int `json:"mr_iid" gorm:"column:mr_iid"`
  273. DiscussionID string `json:"discussion_id"`
  274. IndividualNote bool `json:"individual_note"`
  275. Notes string `json:"notes"`
  276. }