Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-arena-api
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
ygopro-arena-api
Commits
fa4fb674
Commit
fa4fb674
authored
Jun 30, 2019
by
Joe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update rule
parent
1cd4626e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
22 deletions
+46
-22
routes/api.js
routes/api.js
+46
-22
No files found.
routes/api.js
View file @
fa4fb674
...
@@ -100,13 +100,13 @@ var schedule = require('node-schedule');
...
@@ -100,13 +100,13 @@ var schedule = require('node-schedule');
var
j
=
schedule
.
scheduleJob
(
'
30 30 0 1 * *
'
,
function
()
{
var
j
=
schedule
.
scheduleJob
(
'
30 30 0 1 * *
'
,
function
()
{
console
.
log
(
'
The scheduleJob run on first day of every month!
'
,
moment
().
format
(
'
YYYY-MM-DD HH:mm
'
));
console
.
log
(
'
The scheduleJob run on first day of every month!
'
,
moment
().
format
(
'
YYYY-MM-DD HH:mm
'
));
/*
pool
.
connect
(
function
(
err
,
client
,
done
)
{
pool
.
connect
(
function
(
err
,
client
,
done
)
{
if
(
err
)
{
if
(
err
)
{
return
console
.
error
(
'
error fetching client from pool
'
,
err
);
return
console
.
error
(
'
error fetching client from pool
'
,
err
);
}
}
let sql = `update user_info set pt = (pt - (pt - 1000) * 0.
4
)
let
sql
=
`update user_info set pt = (pt - (pt - 1000) * 0.
5
)
where pt > 1000`
;
where pt > 1000`
;
client
.
query
(
sql
,
function
(
err
,
result
)
{
client
.
query
(
sql
,
function
(
err
,
result
)
{
...
@@ -117,22 +117,46 @@ var j = schedule.scheduleJob('30 30 0 1 * *', function () {
...
@@ -117,22 +117,46 @@ var j = schedule.scheduleJob('30 30 0 1 * *', function () {
console
.
log
(
result
)
console
.
log
(
result
)
});
});
})
})
*/
let
time
=
moment
().
subtract
(
1
,
'
month
'
);
// let time = moment().subtract(1, 'month');
let
season
=
time
.
format
(
'
YYYY-MM
'
);
// let season = time.format('YYYY-MM');
let
higher_limit
=
time
.
format
(
'
YYYY-MM-01 00:00:01
'
);
// let higher_limit = time.format('YYYY-MM-01 00:00:01');
let
lower_limit
=
moment
().
subtract
(
1
,
'
day
'
).
format
(
'
YYYY-MM-DD 23:59:59
'
);
// let lower_limit = moment().subtract(1, 'day').format('YYYY-MM-DD 23:59:59');
let
base
=
1000
;
// let base = 1000;
pool
.
query
(
'
select monthly_user_historical_record($1::text, $2, $3::boolean, true)
'
,
[
season
,
base
,
false
],
(
err
,
result
)
=>
{
// pool.query('select monthly_user_historical_record($1::text, $2, $3::boolean, true)', [season, base, false], (err, result) => {
if
(
err
)
// if (err)
// return console.error('error running monthly scheduleJob', err);
// else
// pool.query('select collect_win_lose_rate($1, $2)', [lower_limit, higher_limit], (err, result) => {
// if (err) console.error('error running monthly scheduleJob', err);
// });
// });
});
schedule
.
scheduleJob
(
'
0 0 0 1 7 *
'
,
function
()
{
console
.
log
(
'
The scheduleJob run on 1 July !
'
,
moment
().
format
(
'
YYYY-MM-DD HH:mm
'
));
pool
.
connect
(
function
(
err
,
client
,
done
)
{
if
(
err
)
{
return
console
.
error
(
'
error fetching client from pool
'
,
err
);
}
let
sql
=
`update user_info set pt = 1000`
;
client
.
query
(
sql
,
function
(
err
,
result
)
{
done
();
if
(
err
)
{
return
console
.
error
(
'
error running monthly scheduleJob
'
,
err
);
return
console
.
error
(
'
error running monthly scheduleJob
'
,
err
);
else
}
pool
.
query
(
'
select collect_win_lose_rate($1, $2)
'
,
[
lower_limit
,
higher_limit
],
(
err
,
result
)
=>
{
console
.
log
(
result
)
if
(
err
)
console
.
error
(
'
error running monthly scheduleJob
'
,
err
);
});
});
});
})
});
});
var
Filter
=
require
(
'
bad-words-chinese
'
);
var
Filter
=
require
(
'
bad-words-chinese
'
);
var
dirtyWords
=
require
(
'
../dirtyWordsChinese.json
'
);
var
dirtyWords
=
require
(
'
../dirtyWordsChinese.json
'
);
var
filter
=
new
Filter
({
chineseList
:
dirtyWords
.
words
});
var
filter
=
new
Filter
({
chineseList
:
dirtyWords
.
words
});
...
@@ -278,7 +302,7 @@ router.post('/score', function (req, res) {
...
@@ -278,7 +302,7 @@ router.post('/score', function (req, res) {
}
}
if
(
winner
===
usernameB
)
{
if
(
winner
===
usernameB
)
{
ptResult
.
ptA
=
userA
.
pt
-
1
6
ptResult
.
ptA
=
userA
.
pt
-
1
5
ptResult
.
ptB
=
userB
.
pt
+
16
ptResult
.
ptB
=
userB
.
pt
+
16
console
.
log
(
userA
.
pt
,
userB
.
pt
,
'
当局分差过大,低分赢高分
'
,
moment
(
start
).
format
(
'
YYYY-MM-DD HH:mm
'
))
console
.
log
(
userA
.
pt
,
userB
.
pt
,
'
当局分差过大,低分赢高分
'
,
moment
(
start
).
format
(
'
YYYY-MM-DD HH:mm
'
))
}
}
...
@@ -287,7 +311,7 @@ router.post('/score', function (req, res) {
...
@@ -287,7 +311,7 @@ router.post('/score', function (req, res) {
if
(
userB
.
pt
-
userA
.
pt
>
137
)
{
if
(
userB
.
pt
-
userA
.
pt
>
137
)
{
if
(
winner
===
usernameA
)
{
if
(
winner
===
usernameA
)
{
ptResult
.
ptA
=
userA
.
pt
+
16
ptResult
.
ptA
=
userA
.
pt
+
16
ptResult
.
ptB
=
userB
.
pt
-
1
6
ptResult
.
ptB
=
userB
.
pt
-
1
5
console
.
log
(
userA
.
pt
,
userB
.
pt
,
'
当局分差过大,低分赢高分
'
,
moment
(
start
).
format
(
'
YYYY-MM-DD HH:mm
'
))
console
.
log
(
userA
.
pt
,
userB
.
pt
,
'
当局分差过大,低分赢高分
'
,
moment
(
start
).
format
(
'
YYYY-MM-DD HH:mm
'
))
}
}
...
@@ -321,12 +345,12 @@ router.post('/score', function (req, res) {
...
@@ -321,12 +345,12 @@ router.post('/score', function (req, res) {
if
(
firstWin
)
{
if
(
firstWin
)
{
if
(
winner
===
usernameA
)
{
if
(
winner
===
usernameA
)
{
ptResult
.
ptA
+=
4
ptResult
.
ptA
+=
5
console
.
log
(
usernameA
,
'
首胜多加
4
DP
'
,
moment
(
start
).
format
(
'
YYYY-MM-DD HH:mm
'
))
console
.
log
(
usernameA
,
'
首胜多加
5
DP
'
,
moment
(
start
).
format
(
'
YYYY-MM-DD HH:mm
'
))
}
}
if
(
winner
===
usernameB
)
{
if
(
winner
===
usernameB
)
{
ptResult
.
ptB
+=
4
ptResult
.
ptB
+=
5
console
.
log
(
usernameB
,
'
首胜多加
4
DP
'
,
moment
(
start
).
format
(
'
YYYY-MM-DD HH:mm
'
))
console
.
log
(
usernameB
,
'
首胜多加
5
DP
'
,
moment
(
start
).
format
(
'
YYYY-MM-DD HH:mm
'
))
}
}
}
}
...
...
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