Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
前端
/
sentry-robot
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 51d981b3
authored
Feb 17, 2023
by
zhangquan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修复bug,日报提醒两次的问题
1 parent
126dd612
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
13 deletions
app/schedule/tip.js
app/schedule/tip.js
View file @
51d981b
...
@@ -3,22 +3,45 @@ const { dateFormat } = require("../utils/utils");
...
@@ -3,22 +3,45 @@ const { dateFormat } = require("../utils/utils");
module
.
exports
=
{
module
.
exports
=
{
schedule
:
{
schedule
:
{
cron
:
"0 2 9,11 * * ?"
,
cron
:
"0 2 9,11 * * ?"
,
type
:
"
all
"
,
// 指定所有的 worker 都需要执行
type
:
"
worker
"
,
// 指定所有的 worker 都需要执行
},
},
async
task
(
ctx
)
{
async
task
(
ctx
)
{
const
reqRes
=
await
ctx
.
curl
(
const
reqRes
=
await
ctx
.
curl
(
"https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=test&env=llx"
,
"https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=test&env=llx"
,
{
dataType
:
'json'
}
{
dataType
:
"json"
}
);
);
let
{
includeList
,
excludeList
,
infoList
,
startDate
,
firstTipText
,
secondTipText
,
robotUrl
}
=
reqRes
.
data
.
data
let
{
let
idx
=
parseInt
((
new
Date
().
getTime
()
-
new
Date
(
startDate
).
getTime
())
/
(
86400000
*
7
))
%
infoList
.
length
;
includeList
,
excludeList
,
infoList
,
startDate
,
firstTipText
,
otherTipText
,
secondTipText
,
robotUrl
,
}
=
reqRes
.
data
.
data
;
let
idx
=
parseInt
(
(
new
Date
().
getTime
()
-
new
Date
(
startDate
).
getTime
())
/
(
86400000
*
7
)
)
%
infoList
.
length
;
let
curDay
=
dateFormat
(
new
Date
());
//今天
let
curDay
=
dateFormat
(
new
Date
());
//今天
let
isWeekend
=
new
Date
().
getDay
()
==
0
||
new
Date
().
getDay
()
==
6
;
//是否是周末
let
isWeekend
=
new
Date
().
getDay
()
==
0
||
new
Date
().
getDay
()
==
6
;
//是否是周末
if
(
includeList
.
includes
(
curDay
)
||
(
!
excludeList
.
includes
(
curDay
)
&&
isWeekend
))
return
;
//如果是节假日或者 不是调休日和周末 则不提醒
if
(
let
curPerson
=
`<@
${
infoList
[
idx
][
'id'
]}
>`
//当前日报的提醒人
includeList
.
includes
(
curDay
)
||
let
content
=
firstTipText
.
replace
(
/@xxx/g
,
curPerson
);
(
!
excludeList
.
includes
(
curDay
)
&&
isWeekend
)
if
(
new
Date
().
getDay
()
==
1
)
content
=
content
+
"并创建日报菜单"
;
)
{
if
(
new
Date
().
getHours
()
==
11
)
content
=
secondTipText
.
replace
(
/@xxx/g
,
curPerson
);
return
;
}
//如果是节假日或者 不是调休日和周末 则不提醒
let
curPerson
=
`<@
${
infoList
[
idx
][
"id"
]}
>`
;
//当前日报的提醒人
let
content
=
firstTipText
.
replace
(
/@xxx/g
,
curPerson
);
if
(
new
Date
().
getDay
()
==
1
&&
otherTipText
)
{
let
otherTip
=
otherTipText
.
replace
(
/@xxx/g
,
curPerson
);
content
=
content
+
otherTip
;
}
if
(
new
Date
().
getHours
()
==
11
)
{
content
=
secondTipText
.
replace
(
/@xxx/g
,
curPerson
);
}
const
ROBOT_DATA
=
{
const
ROBOT_DATA
=
{
msgtype
:
"markdown"
,
msgtype
:
"markdown"
,
markdown
:
{
markdown
:
{
...
@@ -26,15 +49,13 @@ module.exports = {
...
@@ -26,15 +49,13 @@ module.exports = {
},
},
};
};
const
result
=
await
ctx
.
curl
(
robotUrl
,
const
result
=
await
ctx
.
curl
(
robotUrl
,
{
{
method
:
"POST"
,
method
:
"POST"
,
headers
:
{
headers
:
{
"content-type"
:
"application/json"
,
"content-type"
:
"application/json"
,
},
},
data
:
JSON
.
stringify
(
ROBOT_DATA
),
data
:
JSON
.
stringify
(
ROBOT_DATA
),
}
});
);
ctx
.
app
.
cache
=
{
ctx
.
app
.
cache
=
{
code
:
"0"
,
code
:
"0"
,
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment