Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
fengchao-admin
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tf-boys
fengchao-admin
Commits
8c59f7a9
Commit
8c59f7a9
authored
Aug 11, 2017
by
刘松
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
双容器加锁
parent
83939285
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
cron.js
lib/cron.js
+7
-3
No files found.
lib/cron.js
View file @
8c59f7a9
...
@@ -3,7 +3,7 @@ const UserAuth = require('../db/mongo/user-auto-auth');
...
@@ -3,7 +3,7 @@ const UserAuth = require('../db/mongo/user-auto-auth');
const
UserAuthLog
=
require
(
'../db/mongo/user-auto-used-log'
);
const
UserAuthLog
=
require
(
'../db/mongo/user-auto-used-log'
);
const
nodemailer
=
require
(
'nodemailer'
);
const
nodemailer
=
require
(
'nodemailer'
);
const
_
=
require
(
'lodash'
);
const
_
=
require
(
'lodash'
);
//
const moment = require('moment');
const
moment
=
require
(
'moment'
);
var
CronJob
=
cron
.
CronJob
;
var
CronJob
=
cron
.
CronJob
;
var
job
=
new
CronJob
({
var
job
=
new
CronJob
({
...
@@ -44,8 +44,12 @@ async function clearUserAuths () {
...
@@ -44,8 +44,12 @@ async function clearUserAuths () {
let
userAuths
=
await
UserAuth
.
find
({}).
limit
(
500
);
let
userAuths
=
await
UserAuth
.
find
({}).
limit
(
500
);
userAuths
.
forEach
(
async
item
=>
{
userAuths
.
forEach
(
async
item
=>
{
let
log
=
item
.
toJSON
();
let
log
=
item
.
toJSON
();
let
auth
=
new
UserAuthLog
(
_
.
omit
(
log
,
[
'_id'
,
'createdAt'
,
'updatedAt'
]));
if
(
moment
(
log
[
'updatedAt'
]).
format
(
'YYYYMMDD'
)
!==
moment
().
format
(
'YYYYMMDD'
)){
await
auth
.
save
();
let
auth
=
new
UserAuthLog
(
_
.
omit
(
log
,
[
'_id'
,
'createdAt'
,
'updatedAt'
]));
await
auth
.
save
();
}
else
{
console
.
log
(
'skip job'
);
}
});
});
let
data
=
{
let
data
=
{
...
...
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