-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path\
More file actions
138 lines (123 loc) · 4.03 KB
/
Copy path\
File metadata and controls
138 lines (123 loc) · 4.03 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import request from "./request";
import { getUserInfo } from "./utils";
import dayjs from "dayjs";
// 获取当前周有变动需求
export const getCurrentRequirements = async () => {
const id = getUserInfo();
return await request(
"https://aone.alibaba-inc.com/v2/api/workitem/adapter/workitem/list?_input_charset=utf-8",
{
method: "POST",
contentType: "application/json",
headers: {
accept: "application/json, text/plain, */*",
},
dataType: "json",
data: JSON.stringify({
spaceType: "User",
spaceIdentifier: id,
category: "",
toPage: 1,
pageSize: 500,
conditions: `{"conditionGroups":[[{"fieldIdentifier":"assignedTo","operator":"CONTAINS","value":["${id}"],"toValue":null,"className":"user","format":"list"}]]}`,
searchType: "LIST",
groupCondition:
'{"fieldIdentifier":"category","className":"category","format":"list","value":["Req"],"operator":"EQUALS"}',
scope: "personal",
}),
}
);
};
// 上月代码页面统计
export const getLastMonthCodeStat = async () => {
let addLine = 0;
let delLine = 0;
// @ts-ignore
const lastMonthStart = dayjs()
.startOf("month")
.subtract(1, "month")
.format("YYYY-MM-DD");
const lastMonthEnd = dayjs()
.endOf("month")
.subtract(1, "month")
.format("YYYY-MM-DD");
// .format("YYYY-MM");
console.log("123--->", lastMonthStart);
console.log("123--->", lastMonthEnd);
const commitList = await request(
// @ts-ignore
`https://ati-app.alibaba-inc.com/open/personal/activities?startDate=${lastMonthStart}+00:00:00&endDate=${lastMonthEnd}+00:00:00&empId=${getUserInfo()}`
);
console.log("123---->", commitList);
if (commitList?.repoSummaries) {
if (commitList?.repoSummaries) {
commitList?.repoSummaries.forEach((i) => {
i?.reviews.forEach((j) => {
addLine += j.addLineCount;
delLine += j.delLineCount;
});
});
}
}
console.log("123", addLine);
return { addLine, delLine };
};
// 本月代码页面统计
export const getCurrentMonthCodeStat = async () => {
let addLine = 0;
let delLine = 0;
// @ts-ignore
const lastMonthStart = dayjs()
.startOf("month")
.subtract(1, "month")
.format("YYYY-MM-DD");
const lastMonthEnd = dayjs()
.endOf("month")
.subtract(1, "month")
.format("YYYY-MM-DD");
const commitList = await request(
// @ts-ignore
`https://ati-app.alibaba-inc.com/open/personal/activities?startDate=${monthStart}+00:00:00&endDate=${monthEnd}+00:00:00&empId=${getUserInfo()}`
);
if (commitList?.repoSummaries) {
if (commitList?.repoSummaries) {
commitList?.repoSummaries.forEach((i) => {
i?.reviews.forEach((j) => {
addLine += j.addLineCount;
delLine += j.delLineCount;
});
});
}
}
return { addLine, delLine };
};
// 代码页面统计
// export const getCodeStat = async () => {
// const currentMonthStart = dayjs().startOf("month").format("YYYYMMDD");
// const currentMonthEnd = dayjs().endOf("month").format("YYYYMMDD");
// // 获取token
// const token = await request(
// "https://code.alibaba-inc.com/api/v3/internal/exchange",
// {
// code: true,
// }
// );
// // 储存隐私token
// window.localStorage.setItem("privateToken", token.privateToken);
// const commitList = await request(
// `https://code.aone.alibaba-inc.com/api/v3/projects/393249/reports/total_commit?_input_charset=utf-8&start_date=${currentMonthStart}&end_date=${currentMonthEnd}&private_token=${token.privateToken}`,
// {
// code: true,
// headers: {
// Accept: "application/json, text/javascript",
// "Content-Type": "application/x-www-form-urlencoded",
// Host: "code.aone.alibaba-inc.com",
// Referer: "https://code.aone.alibaba-inc.com",
// "Sec-Fetch-Mode": "cors",
// "Sec-Fetch-Site": "same-origin",
// Cookie: document.cookie,
// },
// }
// );
// console.log("123", commitList);
// };