Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(timeclock): refactor and add cron
- Loading branch information
1 parent
5fe5c91
commit 46c7faf
Showing
17 changed files
with
446 additions
and
160 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import * as dayjs from 'dayjs'; | ||
import { getEnv } from '@erxes/api-utils/src'; | ||
import { connectAndQueryFromMySql } from '../utils'; | ||
|
||
const connectAndImportFromMysql = async (subdomain: string) => { | ||
const MYSQL_TABLE = getEnv({ name: 'MYSQL_TABLE' }); | ||
|
||
// get time data from yesterday till now | ||
const format = 'YYYY-MM-DD HH:mm:ss'; | ||
const NOW = dayjs(Date.now()); | ||
const YESTERDAY = NOW.add(-1, 'day'); | ||
|
||
const query = | ||
'SELECT * FROM `' + | ||
MYSQL_TABLE + | ||
'` WHERE authDateTime >= "' + | ||
YESTERDAY.format(format) + | ||
'" AND authDateTime <= "' + | ||
NOW.format(format) + | ||
'" ORDER by ID, authDateTime'; | ||
|
||
return await connectAndQueryFromMySql(subdomain, query); | ||
}; | ||
|
||
export default { | ||
handleDailyJob: async ({ subdomain }) => { | ||
await connectAndImportFromMysql(subdomain); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.