-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnight.gs
More file actions
74 lines (63 loc) · 1.88 KB
/
night.gs
File metadata and controls
74 lines (63 loc) · 1.88 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
const CATEGORY = 'カテゴリ';
const NOTIFICATION = 'バグ報告';
function payLoadTemplateNight(){
let data = getData();
let counts = [
{ count: 0, name: 'アカウントについて'},
{ count: 0, name: 'バグ報告' },
{ count: 0, name: '新機能提案'},
{ count: 0, name: 'その他'}
];
console.log(data);
/**
* =====================================================
*
* init variable start
*/
/*ex)現在8:33の時8:00を取得*/
let justTime = new Date();
justTime.setMinutes(0);
justTime.setSeconds(0);
/*ex)現在8:33の時00:00を取得*/
let beforeTime = new Date();
beforeTime.setMinutes(0);
beforeTime.setSeconds(0);
beforeTime.setHours(beforeTime.getHours() - 8);
/* init variable finish */
/*新規オブジェクト取り出し(8時間以内)*/
data = data.filter(function(obj){
const timestamp = obj.タイムスタンプ.getTime()
const diff = justTime.getTime() - timestamp
return 0 < diff && diff <= 28800000;
});
/*バグ報告のオブジェクトを取りだし*/
const bugObj = data.filter(function(obj) {
return obj[CATEGORY] === NOTIFICATION;
});
/*件数取得*/
for(let d of data){
for (let c of counts) {
if (d[CATEGORY] === c.name) {
c.count++;
break;
}
}
}
/*slackに流す文章*/
let strBody = formatDate(new Date(), 'MM/dd HH:mm') + "\n";
strBody += formatDate(beforeTime, 'HH:mm') + "~" + formatDate(justTime, 'HH:mm') + "\n";
for (let c of counts) {
if (c.count > 0) {
strBody += c.name + ": "+ c.count + "件\n";
}
}
strBody += "\n";
for(let i = 1; i <= bugObj.length; i++){
strBody += NOTIFICATION + "の内容 " + i + "\n";
strBody += bugObj[i-1].お問い合わせ内容_件名 + "\n";
}
return strBody;
}
function formatDate(date, format) {
return Utilities.formatDate(date, 'Asia/Tokyo', format)
}