Skip to content

Instantly share code, notes, and snippets.

@xurizaemon
Last active June 5, 2017 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xurizaemon/e66ed3d0127907284728ef79be57363c to your computer and use it in GitHub Desktop.
Save xurizaemon/e66ed3d0127907284728ef79be57363c to your computer and use it in GitHub Desktop.
var cv = require('civicrm-cv')({mode: 'promise'}),
json2md = require('json2md');
cv('api job.get').then(function(result) {
output = [
{ h1: `Core jobs` },
{ p: `Below is a table of common jobs which might appear on a CiviCRM install. ` +
'Extensions can add their own jobs - jobs for your site are in CiviCRM under **Administer > System Settings > Scheduled Jobs**.'
}
];
var table = {
headers: [
'name',
'entity.action',
'run_frequency',
'description'
],
rows: []
};
for (var p in result.values) {
if (result.values.hasOwnProperty(p)) {
['name', 'api_entity', 'api_action', 'run_frequency', 'description'].forEach(function(k) {
if (typeof result.values[p][k] === 'undefined') {
result.values[p][k] = '';
}
})
table.rows.push([
result.values[p]['name'],
`${result.values[p]['api_entity']}.${result.values[p]['api_action']}`,
result.values[p]['run_frequency'],
result.values[p]['description']
]);
}
}
output.push({table: table});
console.log(json2md(output));
}, function(reason) {
console.log('Err: ', reason);
})
.catch(function (a) {
console.log(a, "Promise Rejected");
});;
{
"name": "generate-docs",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"civicrm-cv": "^0.1.2",
"json2md": "^1.5.6"
}
}
@xurizaemon
Copy link
Author

xurizaemon commented Jun 5, 2017

To use:

  • These two files can live in eg ~/Documents/civicrm-docs/scripts/scheduled-jobs
  • cd ~/Documents/civicrm-docs/scripts/scheduled-jobs && npm install (now the dependencies are installed)
  • cd ~/Sites/civicrm.dev (now you're in a working CiviCRM site)
  • node ~/Documents/civicrm-docs/scripts/scheduled-jobs/main.js (run main.js while you're in the site, so cv can bootstrap site for API)
  • Will output .md which you can use to update the page as shown in the PR

Paths above are not significant, except to demonstrate that the docs repo and the civi site used to generate are decoupled and you only need a cv-capable CiviCRM install to update the docs.

Output is as below.

@xurizaemon
Copy link
Author

xurizaemon commented Jun 5, 2017

Core jobs

Below is a table of common jobs which might appear on a CiviCRM install. Extensions can add their own jobs - jobs for your site are in CiviCRM under Administer > System Settings > Scheduled Jobs.

name entity.action run_frequency description
CiviCRM Update Check job.version_check Daily Checks for CiviCRM version updates. Important for keeping the database secure. Also sends anonymous usage statistics to civicrm.org to to assist in prioritizing ongoing development efforts.
Send Scheduled Mailings job.process_mailing Always Sends out scheduled CiviMail mailings
Fetch Bounces job.fetch_bounces Hourly Fetches bounces from mailings and writes them to mailing statistics
Process Inbound Emails job.fetch_activities Hourly Inserts activity for a contact or a case by retrieving inbound emails from a mail directory
Process Pledges job.process_pledge Daily Updates pledge records and sends out reminders
Geocode and Parse Addresses job.geocode Daily Retrieves geocodes (lat and long) and / or parses street addresses (populates street number, street name, etc.)
Update Greetings and Addressees job.update_greeting Daily Goes through contact records and updates email and postal greetings, or addressee value
Mail Reports job.mail_report Daily Generates and sends out reports via email
Send Scheduled Reminders job.send_reminder Daily Sends out scheduled reminders via email
Update Participant Statuses job.process_participant Always Updates pending event participant statuses based on time
Update Membership Statuses job.process_membership Daily Updates membership statuses. WARNING: Membership renewal reminders have been migrated to the Schedule Reminders functionality, which supports multiple renewal reminders.
Process Survey Respondents job.process_respondent Always Releases reserved survey respondents when they have been reserved for longer than the Release Frequency days specified for that survey.
Clean-up Temporary Data and Files job.cleanup Hourly Removes temporary data and files, and clears old data from cache tables. Recommend running this job every hour to help prevent database and file system bloat.
Send Scheduled SMS job.process_sms Always Sends out scheduled SMS
Rebuild Smart Group Cache job.group_rebuild Always Rebuilds the smart group cache.
Disable expired relationships job.disable_expired_relationships Daily Disables relationships that have expired (ie. those relationships whose end date is in the past).
Validate Email Address from Mailings. mailing.update_email_resetdate Daily Updates the reset_date on an email address to indicate that there was a valid delivery to this email address.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment