Batch-processes

From VPOIDS Documentation

Batch processes

Batch processes are processes that run periodically by a cron task, such as an email which is sent periodically on a regular schedule, or a process that generates a report.

Currently scheduled

All times Pacific. Server is on Central time, which is two hours later.

Note: The missions available list is a two-step process which doesn't fit into the batch process routine. The first script loads the queue, and the second step sends five emails at a time. This is necessary because of the amount of time required to send the emails. Otherwise, the process times out.

Angel Flight West

Process Description Schedule Status
missions_available_queue.php Populate the queue for the missions available mailing 9:45pm Mon & Tues Scheduled
missions.available.php Send the mission available email, 5 at a time From 10:00PM-2:00AM every minute, Tues and Fri Scheduled
mission_report_reminder Mission reports due, to pilots 16:05pm every Sunday Scheduled
report_landings_smo Landings at SMO for the previous week 10:25am every Mon Scheduled
update_pilot_stats Saves the pilot stats 3:00am every day Scheduled
update_passenger_stats Saves the passenger stats 3:10am every day Not yet scheduled
monthly_member_stats Saves the permanent stats of members for this month 11:00pm last day of the month Not yet scheduled
calendar_email Sends events calendar to those subscribed to the list 5:00am first day of the month Not yet scheduled
member_renewal_upcoming Renewal reminder to upcoming renewals 12:55pm first day of the month Scheduled
member_renewal_email_first First renewal notice 10:00am 15th day of the month Scheduled
member_renewal_email_second Second renewal notice 10:10am 15th day of the month Scheduled
member_renewal_email_third Third renewal notice 10:20am 15th day of the month Scheduled
member_renewal_email_fourth Fourth renewal notice 10:30am 15th day of the month Scheduled
deactivate_members Sets delinquent members to inactive 12:40am 15th day of the month Scheduled
first_mission Sends an email to wing leaders with a list of members who have completed their first flight within the period -25 to -10 days prior. 10:10pm 1st and 15th day of the month Scheduled

PALS

Process Description Schedule Status
missions_available_queue.php Populate the queue for the missions available mailing 1:55am CT Friday Scheduled
missions.available.php Send the mission available email, 5 at a time From 2AM-5AM every minute, Fri Scheduled
update_pilot_stats Saves the pilot stats 1:20am every day Scheduled

Types of batch processes supported

  1. Some processes perform a task on the database, such as executing a SQL command. An example of this is a monthly process that accumulates permanent member statistics. In this case, the process is executed and a notification email is sent to a recipient specified in the process definition.
  2. Some processes use a SQL command or procedure to create a list of recipients, and then send a standard (non-personalized) message to these recipients. If the personalized element is set to yes, then the body of the email is created for each recipient by creating an xml document and transforming it using the specified stylesheet.
  3. Some processes use a SQL command as above to create a list of recipients, but the message has information from the dataset merged into the body of the message.
  4. Some processes use a SQL command to generate a report which is sent to either a pre-defined list of recipients or a list of recipients generated by another SQL command.

Basic process for defining a batch process

  1. If the process has a dynamic list of recipients, create the SQL command that generates the list. If data will be merged into the body of the message, include that data in the same row as the recipient.
  1. Create a XSL stylesheet that defines the format of the message body.
  1. Add the process definition block to the process definition xml file.

Process definition

Command format

batch_process.php

  • bpDef, which is the name of the process definition xml file
  • processName, which is the name of the process, as defined in the process definition xml file

Global variables

Notify list

Test mode

If testing is set to true (1), then all emails go to the test email address. There is a global testing element, and an optional testing element in each process definition block. The testing element for the block overrides the value in the global element.

Personalized

The "personalized" element can be set to "yes," or "merge," or "no."

If an email is personalized, each email is sent to only one recipient.

Yes means that the stylesheet for the email body contains fields for values in the recipient list. In these cases, there is no dataset for the body content. A simple example of this is personalizing the email with the recipient's name. The recipient's name is included in the dataset for the recipient list, and the values are merged into the stylesheet.

Merge means that the body is created separately for each recipient. There is a separate dataset for the body content, and that dataset is merged into the row of the dataset for the recipient. (The arrays are literally merged.) The body dataset only needs to be generated once.

No means that the same body goes to all recipients, which means that one email can be sent with multiple addresses in the Bcc field.


Format of a process definition

	<process>
		<processName>missions_available</processName>
		<notes>Working... Need to figure out how to incorporate efficiency calculation</notes>
		<personalized>merge</personalized>
		<recipient_list source="sql_text">
			<command>SELECT p.email, p.first_name as firstName, p.last_name as lastName, m.wing_id as wingID, a.ident, a.latitude, a.longitude FROM email_list_person JOIN person p ON (email_list_person.person_id = p.id) JOIN member m ON (m.person_id = p.id) LEFT JOIN pilot pi ON (pi.member_id = m.id) LEFT JOIN airport a ON (pi.primary_airport_id = a.id) WHERE list_id = 1 AND p.email IS NOT NULL AND m.active = 1 ORDER BY p.last_name, p.first_name</command>
		</recipient_list>
		<email_contents source="sql_procedure">
			<command>bp_missions_available</command>
			<xsl_file root_directory="default">missionsAvailable.xsl</xsl_file>
		</email_contents>
		<subject>{organizationName} Missions Available</subject>
		<notify_to_name useDefault="no">{coordination}</notify_to_name>
		<notify_to_email useDefault="no">{mailCoordination}</notify_to_email>
		<notify_admin_name useDefault="yes"/>
		<notify_admin_email useDefault="yes"/>
	</process>