Delete entry from warranty_serial_queue when done processing. #708
This commit is contained in:
parent
c1ef75b8f5
commit
21231358d6
1 changed files with 10 additions and 15 deletions
|
|
@ -62,7 +62,7 @@ class LoadWarrantySerialCommand extends Command
|
|||
// get the filenames from the queue table with status pending
|
||||
$db = $em->getConnection();
|
||||
|
||||
$ws_query_sql = 'SELECT id, file_serial, file_id, api_user FROM warranty_serial_queue
|
||||
$ws_query_sql = 'SELECT id, file_serial, file_id, api_user, orig_file_serial FROM warranty_serial_queue
|
||||
WHERE status = :status';
|
||||
|
||||
$ws_query_stmt = $db->prepare($ws_query_sql);
|
||||
|
|
@ -77,8 +77,9 @@ class LoadWarrantySerialCommand extends Command
|
|||
$user_id = $row['api_user'];
|
||||
$id = $row['id'];
|
||||
$file_id = $row['file_id'];
|
||||
$orig_filename = $row['orig_file_serial'];
|
||||
|
||||
$output_info[] = $this->processWarrantySerialFile($filename, $user_id, $file_id);
|
||||
$output_info[] = $this->processWarrantySerialFile($filename, $user_id, $file_id, $orig_filename);
|
||||
|
||||
$this->updateWarrantySerialQueue($id);
|
||||
}
|
||||
|
|
@ -93,7 +94,7 @@ class LoadWarrantySerialCommand extends Command
|
|||
return 0;
|
||||
}
|
||||
|
||||
protected function processWarrantySerialFile($filename, $user_id, $file_id)
|
||||
protected function processWarrantySerialFile($filename, $user_id, $file_id, $orig_filename)
|
||||
{
|
||||
$csv_file = $this->project_dir . '/public/warranty_serial_uploads/' . $filename;
|
||||
|
||||
|
|
@ -114,7 +115,7 @@ class LoadWarrantySerialCommand extends Command
|
|||
];
|
||||
$this->upload_logger->logWarrantySerialUploadInfo($log_data);
|
||||
|
||||
$output_info = $this->setOutputInfo($filename, $file_id, true, $error, $data);
|
||||
$output_info = $this->setOutputInfo($filename, $file_id, true, $error, $data, $orig_filename);
|
||||
|
||||
return $output_info;
|
||||
}
|
||||
|
|
@ -200,7 +201,7 @@ class LoadWarrantySerialCommand extends Command
|
|||
}
|
||||
|
||||
// form what we output
|
||||
$output_info = $this->setOutputInfo($filename, $file_id, false, '', $data);
|
||||
$output_info = $this->setOutputInfo($filename, $file_id, false, '', $data, $orig_filename, $orig_filename);
|
||||
|
||||
return $output_info;
|
||||
}
|
||||
|
|
@ -391,25 +392,19 @@ class LoadWarrantySerialCommand extends Command
|
|||
{
|
||||
// prepared statement
|
||||
$db = $this->em->getConnection();
|
||||
$update_stmt = $db->prepare('UPDATE warranty_serial_queue SET status = :status
|
||||
$delete_stmt = $db->prepare('DELETE FROM warranty_serial_queue
|
||||
WHERE id = :id');
|
||||
|
||||
$res = $update_stmt->execute([
|
||||
':status' => 'done',
|
||||
$res = $delete_stmt->execute([
|
||||
':id' => $id,
|
||||
]);
|
||||
}
|
||||
|
||||
protected function setOutputInfo($filename, $file_id, $has_error, $error_message, $entries)
|
||||
protected function setOutputInfo($filename, $file_id, $has_error, $error_message, $entries, $orig_filename)
|
||||
{
|
||||
// need to get the original filename from warranty_serial_queue
|
||||
// use the uploaded_file_serial which has the saved csv file
|
||||
$upload_entry = $this->em->getRepository(WarrantySerialQueue::class)->findOneBy(['file_id' => $file_id]);
|
||||
$original_filename = $upload_entry->getOrigFileSerial();
|
||||
|
||||
$info = [
|
||||
'id' => $file_id,
|
||||
'filename' => $original_filename,
|
||||
'filename' => $orig_filename,
|
||||
'has_error' => $has_error,
|
||||
'error_message' => $error_message,
|
||||
'data' => $entries,
|
||||
|
|
|
|||
Loading…
Reference in a new issue