function rec_transfer_upload in Recommender API 7.4
Same name and namespace in other branches
- 6.3 rec_transfer/rec_transfer.module \rec_transfer_upload()
- 7.5 rec_transfer/rec_transfer.module \rec_transfer_upload()
1 call to rec_transfer_upload()
- rec_transfer_handle_commands in rec_transfer/
rec_transfer.module
2 string references to 'rec_transfer_upload'
- rec_transfer_cron_queue_info in rec_transfer/
rec_transfer.module - Implements hook_cron_queue_info().
- rec_transfer_handle_commands in rec_transfer/
rec_transfer.module
File
- rec_transfer/
rec_transfer.module, line 142 - This is the module file for Recommender Data Transfer
Code
function rec_transfer_upload($command) {
$command_id = $command['command_id'];
$recommender_id = $command['recommender_id'];
// this could get executed from cron, where command_id and recommender_id are not valid
// attention: perhaps need to check recommender_id too if the recommender_app is disabled where upload is still in process.
$num = async_command_update_command($command_id, array(
"control" => 'REMT',
'status' => 'PEND',
'start' => time(),
));
if ($num != 1) {
return;
}
// check whether the service is available or not.
$ready_check = rec_transfer_check_service('ready');
if (!$ready_check['success']) {
async_command_update_command($command_id, array(
'status' => 'FAIL',
'message' => 'Remote service is not ready. Additional message: ' . $ready_check['message'],
'end' => time(),
));
return;
}
$pref_filename = rec_transfer_output_preference($command_id, $recommender_id);
$rec_params = db_query('SELECT params FROM {recommender_app} WHERE id = :id', array(
':id' => $recommender_id,
))
->fetchField();
$upload_success = rec_transfer_upload_preference($pref_filename, array(
'recommender_params' => $rec_params,
));
//db_query("UPDATE {async_command} SET control='REMT', status='PEND' WHERE id=:id", array(':id' => $row->id));
if ($upload_success) {
// attention: still remains 'PENDING'?
//async_command_update_command($command_id, array('status' => 'RUNN')) ;
}
}