Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
AppMonitorSubscriber
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nongyingchen
AppMonitorSubscriber
Commits
f72ce486
Commit
f72ce486
authored
Jun 27, 2019
by
trace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
限制 top 数量, 缩短循环间隔, 无关 APP 不再邮件通知
parent
0375f405
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
22 deletions
+26
-22
play.js
+26
-22
No files found.
play.js
View file @
f72ce486
let
version
=
'1.
1
'
let
version
=
'1.
2
'
let
release
=
`<div><br/>
<br/>1. <br/>
加入邮件通知外部人员功能<br/>
配置文件添加新字段, 用于指名哪个客户, 以及其通知邮件(多个)<br/>
"outsideNotifier" {<br/>
"2060": { "emails": ["developer@xxxxx.com", "xxxxxx"] },<br/>
"2001": { "emails": ["developer@xxxxx.com", "xxxxx"] },<br/>
}<br/>
具体格式可以查看 config 文件中 "outsideNotifier" 字段.<br/>
添加新监控 APP 时只要像原来一样保持 "客户ID空格XXXXX" 的格式即可, 如: "2060 XXXXXX"<br/>
<br/>2. <br/>
贷超通知更改, 贷超有产品下架才通知贷超人员
添加单独贷超 email 变量: "daichaoNotifyEmail": []
限制排名获取的监控数量, 减少监控总数量, 加快循环时间<br/>
从 Top 表单里获取的 APP 不在累积监控名单, 只监控获取当次的 APP. <br/>
监控数量控制在: (贷超 APP 数) + (OurApp 数) + Top表单(国家 * 类型 * Top获取数量[如获取 Top100, 就是100]) <br/>
<div/>
<br/>
<br/>
...
...
@@ -22,6 +13,7 @@ let release = `<div><br/>
// 依赖
var
gplay
=
require
(
'google-play-scraper'
)
var
nodemailer
=
require
(
'nodemailer'
)
// var moment = require('moment')
let
developer
=
[
'yingchen.nong@starwin.com'
]
let
notifyEmail
=
developer
...
...
@@ -72,6 +64,7 @@ let monitorType = { 'FINANCE': '财务' }
let
statusFile
=
`
${
process
.
cwd
()}
/status.json`
let
monitorApps
=
`
${
process
.
cwd
()}
/google-play-monitor-apps.json`
let
base_gp_url
=
'https://play.google.com/store/apps/details?id='
let
moniteDuration
=
"moniteDuration"
let
daichaoApps
=
[]
...
...
@@ -81,6 +74,7 @@ let ourApps = {}
let
hitDaichao
=
isTest
()
?
1
:
0
let
hitOurs
=
isTest
()
?
1
:
0
// 返回需要监控的自有 app
let
isTimeToAppendOurApp
=
(
apps
)
=>
{
...
...
@@ -386,7 +380,8 @@ async function getTop100() {
for
(
let
i
in
regions
)
{
let
region
=
regions
[
i
]
log
(
`地区:
${
region
}
`
)
names
=
monitorNames
[
region
]
||
[]
let
names
=
[]
// names = monitorNames[region] || [] 每次添加新的, 不再去重
newForRegion
=
[]
for
(
let
t
in
types
)
{
let
type
=
types
[
t
]
...
...
@@ -426,9 +421,10 @@ async function getTop100() {
status
[
app
.
appId
].
category
=
type
if
(
!
names
.
includes
(
app
.
appId
))
{
// 限制每个区域的监控 APP 数量, 不再添加
names
.
push
(
app
.
appId
)
newForRegion
.
push
({
id
:
app
.
appId
,
name
:
app
.
title
,
region
:
monitorRegion
[
region
],
category
:
type
})
log
(
`
新加
入<
${
monitorRegion
[
region
]}
>[
${
monitorType
[
type
]}
]监控:
${
app
.
appId
}
`
)
log
(
`
本次
入<
${
monitorRegion
[
region
]}
>[
${
monitorType
[
type
]}
]监控:
${
app
.
appId
}
`
)
}
})
}
...
...
@@ -454,6 +450,7 @@ async function sleepForInterVal(val) {
async
function
monitorIfOnline
(
names
)
{
log
(
`获取数量:
${
names
.
length
}
`
)
status
[
moniteDuration
]
=
Date
()
for
(
let
i
in
names
)
{
let
name
=
names
[
i
]
if
(
name
.
includes
(
'://'
))
{
...
...
@@ -531,7 +528,8 @@ function genMail() {
let
today
=
new
Date
()
let
needSendList
=
(
theDaySendList
.
includes
(
today
.
getDay
()))
&&
(
lastSendListDate
.
toLocaleDateString
()
!=
today
.
toLocaleDateString
())
let
nowGenerate
=
`<br/><br/>邮件生成时间: <br/>
${
new
Date
().
toLocaleString
()}
`
let
moniteStartTime
=
new
Date
(
status
[
moniteDuration
]).
toLocaleString
()
let
nowGenerate
=
`<br/>本轮监控开始时间:
${
moniteStartTime
}
<br/>邮件生成时间: <br/>
${
new
Date
().
toLocaleString
()}
`
let
lastLoopDate
=
status
[
'lastLoopDate'
]
&&
new
Date
(
status
[
'lastLoopDate'
])
||
new
Date
()
let
loopInterval
=
(
new
Date
()).
getHours
()
-
lastLoopDate
.
getHours
()
let
lastGenerate
=
`<br/><br/><br/>上次循环时间
${
lastLoopDate
.
toLocaleString
()}
, 间隔:
${
loopInterval
}
小时`
...
...
@@ -590,12 +588,13 @@ function genMail() {
// 判断每个国家新增里自己的 app, 累加
ourTop
=
[...
ourTop
,
...
ourAppIds
.
filter
(
val
=>
names
.
includes
(
val
))]
daichaoTop
=
[...
daichaoTop
,
...
daichaoApps
.
filter
(
val
=>
names
.
includes
(
val
))]
emailContent
+=
wrapSummary
(
`本次
从<
${
monitorRegion
[
key
]}
>top
${
requestTopAppNum
}
新增监控
:
${
names
.
length
}
个`
,
names
.
map
(
n
=>
`
${
link
(
n
.
id
,
true
)}
进top
100
`
))
emailContent
+=
wrapSummary
(
`本次
在<
${
monitorRegion
[
key
]}
>top
${
requestTopAppNum
}
监控列表
:
${
names
.
length
}
个`
,
names
.
map
(
n
=>
`
${
link
(
n
.
id
,
true
)}
进top
${
requestTopAppNum
}
`
))
}
})
emailContent
+=
`<br/>/>^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^<br/>`
}
// 自己 app
firstLine
=
`《
${
firstLine
}${
ourUp
.
length
>
0
?
`上
${
ourUp
.
length
}
`
:
''
}
`
firstLine
=
`
${
firstLine
}${
ourDown
.
length
>
0
?
`下
${
ourDown
.
length
}
`
:
''
}
`
...
...
@@ -609,6 +608,13 @@ function genMail() {
hitOurs
=
ourUp
.
length
+
ourDown
.
length
+
ourTop
.
length
hitDaichao
=
daichaoUp
.
length
+
daichaoDown
.
length
+
daichaoTop
.
length
// 如果当轮监控, 没有设计我们的 APP 或者错误, 就不生成邮件内容
if
(
hitOurs
==
0
&&
hitDaichao
==
0
&&
errorLog
.
length
==
0
)
{
return
null
}
if
(
newOffline
.
length
==
0
)
{
emailContent
+=
'<div>没有登记中的产品被新下架</div>'
}
else
{
...
...
@@ -656,13 +662,10 @@ function genMail() {
let
countrys
=
Object
.
keys
(
monitorRegion
)
monitorRegion
emailContent
+=
`<div>下面是监控列表<br/>当前监控
${
countrys
.
length
}
个国家</div>`
let
total
=
0
Object
.
keys
(
monitorNames
).
forEach
(
val
=>
{
let
num
=
monitorNames
[
val
].
length
total
+=
num
emailContent
+=
wrapSummary
(
`
${
monitorRegion
[
val
]
||
val
}
(
${
num
}
个)`
,
monitorNames
[
val
].
map
(
id
=>
link
(
id
,
false
)))
})
emailContent
+=
`<div>监控总数量:
${
total
}
</div>`
status
.
sendListDate
=
today
.
toString
()
}
...
...
@@ -672,6 +675,7 @@ function genMail() {
emailContent
+=
generateDailyOnlineReport
()
emailContent
+=
nowGenerate
emailContent
+=
`<div>监控总数量:
${(
allNames
(
monitorNames
)
||
[]).
length
}
</div>`
emailContent
+=
lastGenerate
log
(
`生成邮件内容: \n
${
emailContent
}
`
)
...
...
@@ -858,7 +862,7 @@ function dingDing(content, toDing = debugDingding) {
msgtype
:
'text'
,
text
:
{
content
:
content
}
})
},
(
err
,
param
)
=>
param
.
statusCode
!=
200
&&
log
(
`Error:
${
err
}
\nParam:
${
JSON
.
stringify
(
param
)}
`
))
},
(
err
,
param
)
=>
param
&&
param
.
statusCode
!=
200
&&
log
(
`Error:
${
err
}
\nParam:
${
JSON
.
stringify
(
param
)}
`
))
}
function
sleep
(
ms
)
{
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment