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
1e12b5b1
Commit
1e12b5b1
authored
May 01, 2020
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no schedule on sub processes
parent
d0ba2f73
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
63 deletions
+66
-63
routes/api.js
routes/api.js
+66
-63
No files found.
routes/api.js
View file @
1e12b5b1
...
...
@@ -96,79 +96,82 @@ pool.on('error', function (err, client) {
└───────────────────────── second (0 - 59, OPTIONAL)
*/
var
schedule
=
require
(
'
node-schedule
'
);
// 每月的1日0点30分30秒触发 :'30 30 0 1 * *'
var
j
=
schedule
.
scheduleJob
(
'
0 0 0 1 * *
'
,
function
()
{
console
.
log
(
'
The scheduleJob run on first day of every month!
'
,
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 = (pt - (pt - 1000) * 0.5 )
where pt > 1000`
;
// Monthly pt reduce will be done in function monthly_user_historical_record()
//client.query(sql, function (err, result) {
// done();
// if (err) {
// return console.error('error running monthly scheduleJob', err);
// }
// console.log(result)
//});
})
let
time
=
moment
().
subtract
(
1
,
'
month
'
);
let
season
=
time
.
format
(
'
YYYY-MM
'
);
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
base
=
1000
;
pool
.
query
(
'
select monthly_user_historical_record($1::text, $2, $3::boolean, true)
'
,
[
season
,
base
,
false
],
(
err
,
result
)
=>
{
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
);
});
if
(
!
process
.
env
.
NO_SCHEDULE
)
{
// 每月的1日0点30分30秒触发 :'30 30 0 1 * *'
var
j
=
schedule
.
scheduleJob
(
'
0 0 0 1 * *
'
,
function
()
{
console
.
log
(
'
The scheduleJob run on first day of every month!
'
,
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 = (pt - (pt - 1000) * 0.5 )
where pt > 1000`
;
// Monthly pt reduce will be done in function monthly_user_historical_record()
//client.query(sql, function (err, result) {
// done();
// if (err) {
// return console.error('error running monthly scheduleJob', err);
// }
// console.log(result)
//});
})
let
time
=
moment
().
subtract
(
1
,
'
month
'
);
let
season
=
time
.
format
(
'
YYYY-MM
'
);
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
base
=
1000
;
pool
.
query
(
'
select monthly_user_historical_record($1::text, $2, $3::boolean, true)
'
,
[
season
,
base
,
false
],
(
err
,
result
)
=>
{
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
);
});
});
});
});
// cron job
/**
* * * * * *
┬ ┬ ┬ ┬ ┬ ┬
│ │ │ │ │ |
│ │ │ │ │ └ day of week (0 - 7) (0 or 7 is Sun)
│ │ │ │ └───── month (1 - 12)
│ │ │ └────────── day of month (1 - 31)
│ │ └─────────────── hour (0 - 23)
│ └──────────────────── minute (0 - 59)
└───────────────────────── second (0 - 59, OPTIONAL)
*/
schedule
.
scheduleJob
(
'
1 1 0 1 1 *
'
,
function
()
{
console
.
log
(
'
The scheduleJob run on 1 Jan !
'
,
moment
().
format
(
'
YYYY-MM-DD HH:mm
'
));
// cron job
pool
.
connect
(
function
(
err
,
client
,
done
)
{
if
(
err
)
{
return
console
.
error
(
'
error fetching client from pool
'
,
err
);
}
/**
* * * * * *
┬ ┬ ┬ ┬ ┬ ┬
│ │ │ │ │ |
│ │ │ │ │ └ day of week (0 - 7) (0 or 7 is Sun)
│ │ │ │ └───── month (1 - 12)
│ │ │ └────────── day of month (1 - 31)
│ │ └─────────────── hour (0 - 23)
│ └──────────────────── minute (0 - 59)
└───────────────────────── second (0 - 59, OPTIONAL)
*/
schedule
.
scheduleJob
(
'
1 1 0 1 1 *
'
,
function
()
{
let
sql
=
`update user_info set pt = 1000`
;
console
.
log
(
'
The scheduleJob run on 1 Jan !
'
,
moment
().
format
(
'
YYYY-MM-DD HH:mm
'
))
;
client
.
query
(
sql
,
function
(
err
,
result
)
{
done
();
pool
.
connect
(
function
(
err
,
client
,
done
)
{
if
(
err
)
{
return
console
.
error
(
'
error
running monthly scheduleJob
'
,
err
);
return
console
.
error
(
'
error
fetching client from pool
'
,
err
);
}
console
.
log
(
result
)
});
})
});
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
);
}
console
.
log
(
result
)
});
})
});
}
var
Filter
=
require
(
'
bad-words-chinese
'
);
var
dirtyWords
=
require
(
'
../dirtyWordsChinese.json
'
);
...
...
@@ -2689,4 +2692,4 @@ var getStringValueByMysticalNumber = function (lang, offset, number) {
return
""
}
module
.
exports
=
router
\ No newline at end of file
module
.
exports
=
router
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