Example #1
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $reader = Reader::createFromPath($this->path);
     $read = 0;
     $saved = 0;
     foreach ($reader->fetchAssoc() as $row) {
         $read++;
         $object_number = $row['object_number'];
         unset($row['object_number']);
         foreach ($row as $key => $value) {
             $document = Document::firstOrNew(['url' => $value]);
             $document->object_number = $object_number;
             $document->url = $value;
             if ($key == "data") {
                 $document->type = "data";
                 $document->order = "";
             } else {
                 list($type, $order) = explode("_", $key);
                 $document->type = $type;
                 $document->order = isset($order) ? $order : "";
             }
             if ($document->save()) {
                 $saved++;
             }
         }
     }
     $report = ['event' => 'documents.imported', 'data' => ['read' => $read, 'saved' => $saved]];
     $message = json_encode($report);
     $context = new \ZMQContext();
     $socket = $context->getSocket(\ZMQ::SOCKET_PUSH, 'my pusher');
     $socket->connect("tcp://localhost:5555");
     $socket->send($message);
 }
Example #2
0
 public function index()
 {
     // @todo
     //  * Use managers/repositories instead of fat models.
     //  * Add the id as parameter to merge/latest
     $params = ['count_objects' => Object::count(), 'count_objects_no_work_pid' => Object::countHasNoWorkPid(), 'count_objects_has_work_pid' => Object::countHasWorkPid(), 'count_documents' => Document::count(), 'count_mergable_documents' => Document::countMergableDocuments(), 'count_orphan_documents' => Document::countOrphanDocuments(), 'count_artists' => $this->artistManager->count(), 'mergers' => $this->mergeManager->fetchLatestMergers(5)];
     return view('index', $params);
 }
Example #3
0
 public static function countOrphanDocuments()
 {
     return Document::doesntHave('object')->count();
 }
Example #4
0
 public function __construct()
 {
     $this->baseQuery = Document::whereHas('object', function ($query) {
         $query->where('work_pid', '<>', '');
     })->with('object');
 }
Example #5
0
 public function orphans()
 {
     $documents = Document::doesntHave('object')->simplePaginate(50);
     return view('document.orphans', ['documents' => $documents]);
 }