@ambaum2/aao-cron-tasks

0.1.8 • Public • Published

simple module that creates a database model to keep track of sync tasks by batch id

try to use your module's name for the batch id to ensure it is unique

currently the main methods that get exposed are

Resync the dbs - ensures your db has model defined

``` tasks.syncTasks().then(() => { console.log('sync done') }) ```

getLatestTask and checkEndOfTasks

getLatestTask gets the batchSize and pageNumber of the last task it is a promise
checkEndOfTasks checks if all tasks are finished and if so adds a task with pageNumber 0 (@todo you actually need to add this so it creates that page 0 task) so that the crons will start from the beginning

Example - cron job every 5 seconds

``` new CronJob('*/5 * * * * *', function() { tasks.getLatestTask(batchCode, defaultTask).then(function(r) { users.batchAddUserProfiles(r.batchSize, r.pageNumber + 1, 'aao') .done(function(res) { console.log('finished sync') tasks.checkEndOfTasks(batchCode) }) }) }, null, true, 'America/Los_Angeles');

<h2>Environment Variables</h2>
the following env variables must be set. for a connection string for dbhost value use everything after the @ and before the : and port

dbhost dbname dbuser dbpassword dbport

Readme

Keywords

none

Package Sidebar

Install

npm i @ambaum2/aao-cron-tasks

Weekly Downloads

3

Version

0.1.8

License

ISC

Last publish

Collaborators

  • ambaum2