-
Notifications
You must be signed in to change notification settings - Fork 66
/
summary.go
101 lines (84 loc) · 3.46 KB
/
summary.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package service
import (
v1 "github.com/aaronchen2k/deeptest/cmd/server/v1/domain"
"github.com/aaronchen2k/deeptest/internal/pkg/consts"
"strconv"
"time"
)
type SummaryService struct {
SummaryDetailsService *SummaryDetailsService `inject:""`
SummaryBugsService *SummaryBugsService `inject:""`
SummaryProjectUserRankingService *SummaryProjectUserRankingService `inject:""`
}
func (s *SummaryService) Bugs(tenantId consts.TenantId, projectId int64) (res v1.ResSummaryBugs, err error) {
res, err = s.SummaryBugsService.Bugs(tenantId, projectId)
return
}
func (s *SummaryService) Details(tenantId consts.TenantId, userId int64, engineering string) (res v1.ResSummaryDetail, err error) {
//改为项目数据实时,但统计数据非实时
res, err = s.SummaryDetailsService.Details(tenantId, userId, engineering)
return
}
func (s *SummaryService) ProjectUserRanking(tenantId consts.TenantId, cycle int64, projectId int64) (res v1.ResRankingList, err error) {
res, err = s.SummaryProjectUserRankingService.ProjectUserRanking(tenantId, cycle, projectId)
return
}
func (s *SummaryService) Card(tenantId consts.TenantId, projectId int64) (res v1.ResSummaryCard, err error) {
res, err = s.SummaryDetailsService.Card(tenantId, projectId)
return
}
func (s *SummaryService) Collection(tenantId consts.TenantId) (err error) {
err = s.CollectionDetails(tenantId)
err = s.CollectionBugs(tenantId)
err = s.CollectionRanking(tenantId)
return
}
func (s *SummaryService) CollectionRanking(tenantId consts.TenantId) (err error) {
s.SummaryProjectUserRankingService.SaveRanking(tenantId)
return
}
func (s *SummaryService) CollectionBugs(tenantId consts.TenantId) (err error) {
//配置地址
//请求对应系统,获取bug信息
//bug转化,配置字段映射关系
//调用存储
//s.SummaryBugsService.CreateBug(bugs)
return
}
func (s *SummaryService) CollectionDetails(tenantId consts.TenantId) (err error) {
err = s.SummaryDetailsService.SaveDetails(tenantId)
return
}
func DecimalHB(newValue float64, oldValue float64) float64 {
var value float64
if newValue != 0 {
value = newValue / oldValue
value = value - 1
} else {
value = 1 - oldValue
}
return value * 100
}
func GetTodayStartAndEndTime() (startTime string, endTime string) {
today := time.Now().AddDate(0, 0, 0)
year, month, day := today.Date()
startTime = strconv.Itoa(year) + "-" + strconv.Itoa(int(month)) + "-" + strconv.Itoa(day) + " 00:00:00"
endTime = strconv.Itoa(year) + "-" + strconv.Itoa(int(month)) + "-" + strconv.Itoa(day) + " 23:59:59"
return
}
func GetEarlierDateStartAndEndTime(earlier int64) (startTime string, endTime string) {
earlierDate := time.Now().AddDate(0, 0, int(earlier))
year, month, day := earlierDate.Date()
startTime = strconv.Itoa(year) + "-" + strconv.Itoa(int(month)) + "-" + strconv.Itoa(day) + " 00:00:00"
endTime = strconv.Itoa(year) + "-" + strconv.Itoa(int(month)) + "-" + strconv.Itoa(day) + " 23:59:59"
return
}
func GetEarlierDateUntilTodayStartAndEndTime(earlier int64) (startTime string, endTime string) {
earlierDate := time.Now().AddDate(0, 0, int(earlier))
today := time.Now().AddDate(0, 0, 0)
earlierYear, earlierMonth, earlierDay := earlierDate.Date()
year, month, day := today.Date()
startTime = strconv.Itoa(earlierYear) + "-" + strconv.Itoa(int(earlierMonth)) + "-" + strconv.Itoa(earlierDay) + " 00:00:00"
endTime = strconv.Itoa(year) + "-" + strconv.Itoa(int(month)) + "-" + strconv.Itoa(day) + " 23:59:59"
return
}