]> _ Git - psq.git/commitdiff
regex ingest file
authorLouis Jeckel <louis.jeckel@outlook.cm>
Mon, 14 Sep 2020 09:52:15 +0000 (11:52 +0200)
committerLouis Jeckel <louis.jeckel@outlook.cm>
Mon, 14 Sep 2020 09:52:15 +0000 (11:52 +0200)
app/Console/Commands/IngestPdfFiles.php
app/PdfFile.php
config/horizon.php

index 987460ebccc9c2a3726e86f72ac15d90f8b2a630..316ddbae0c811e0abee09946411c75283ebfd2ee 100644 (file)
@@ -53,9 +53,16 @@ class IngestPdfFiles extends Command
 
             if($this->argument('mode') === 'fileName'){
                 $fileName = basename($path, '.pdf');
-                $ref = Str::after($fileName, 'PSQ ');
-                $date = \File::lastModified($path);
-                $date = Carbon::createFromFormat("U", $date);
+                $regex = "/PSQ (?<number>\d{4}) - (?<date>\d\d_\d\d_\d\d)/";
+                if(preg_match($regex, $fileName, $matches)) {
+                    $ref = $matches['number'];
+
+                } else {
+                    $this->error('Could not parse file name');
+                    continue;
+                }
+
+                $date = Carbon::createFromFormat("d_m_y", $matches['date']);
 
             } else {
                 $fileName = basename($path, '.pdf');
index 37938c69944d67b12ff638efd41d4e1d391e282f..369141248d5661f86c059a8795b02f8befc76b80 100644 (file)
@@ -573,7 +573,7 @@ class PdfFile extends TwillModel implements Sortable
      */
     public static function last(): Builder
     {
-        return self::query()->orderByDesc('id');
+        return self::query()->orderByDesc('created_at');
     }
 
     /**
index 3a7752c53ad3096d04fc4f447ac6dc508dea49fe..866e3e562151a68c61e5a55fea039c7d936dd197 100644 (file)
@@ -172,6 +172,7 @@ return [
                 'balance' => 'simple',
                 'processes' => 10,
                 'tries' => 1,
+                'timeout' => 300,
             ],
         ],