function tripal_bulk_loader_progress_file_track_job
2.x tripal_bulk_loader.loader.inc | tripal_bulk_loader_progress_file_track_job($job_id, $record_added, $line_complete = FALSE, $close = FALSE) |
3.x tripal_bulk_loader.loader.inc | tripal_bulk_loader_progress_file_track_job($job_id, $record_added, $line_complete = FALSE, $close = FALSE) |
1.x tripal_bulk_loader.loader.inc | tripal_bulk_loader_progress_file_track_job($job_id, $record_added, $line_complete = FALSE, $close = FALSE) |
Keep track of progress in file rather then database
This provides an alternative method to keep track of progress that doesn't require the database. It was needed because you can't switch databases within a transaction... Waiting until the end of a constant set is much too long to wait for any indication that things are working.
Each line represents a line processed in the loading file. Each period (.) represents a successfully inserted record.
Parameters
$job_id: The ID of the current tripal job
$record_added: A boolean indicated whether a record was added successfully
$line_complete: A boolean indicating whether the current line is finished
$close: A boolean indicating that the file should be closed
Related topics
1 call to tripal_bulk_loader_progress_file_track_job()
- tripal_bulk_loader_load_data in tripal_bulk_loader/
includes/ tripal_bulk_loader.loader.inc - Tripal Bulk Loader
File
- tripal_bulk_loader/
includes/ tripal_bulk_loader.loader.inc, line 1163 - Handles the actual loading of data.
Code
function tripal_bulk_loader_progress_file_track_job($job_id, $record_added, $line_complete = FALSE, $close = FALSE) {
// retrieve the file handle
$file_handle = variable_get('tripal_bulk_loader_progress_file_handle', NULL);
// open file for reading if not already
if (!$file_handle) {
$file_handle = fopen('/tmp/tripal_bulk_loader_progress-' . $job_id . '.out', 'w');
variable_set('tripal_bulk_loader_progress_file_handle', $file_handle);
}
if ($record_added) {
fwrite($file_handle, '.');
}
if ($line_complete) {
fwrite($file_handle, "\n");
}
// close the file if finished
if ($close) {
fclose($file_handle);
variable_set('tripal_bulk_loader_progress_file_handle', NULL);
}
}