Bug fixes

This commit is contained in:
Deon George 2020-01-06 20:01:04 +11:00
parent 948e8ce9fc
commit 7bd4bad941
8 changed files with 26 additions and 19 deletions

View File

@ -2,13 +2,10 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Jobs\PhotoMove;
use App\Jobs\VideoMove;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
use App\Jobs\PhotoDelete; use App\Jobs\{PhotoDelete,VideoDelete};
use App\Models\Photo;
use App\Traits\Type; use App\Traits\Type;
class CatalogAutoDelete extends Command class CatalogAutoDelete extends Command

View File

@ -36,7 +36,7 @@ class VideoController extends Controller
return view('catalog.deletereview',[ return view('catalog.deletereview',[
'catalog'=>is_null($id) ? Video::where('remove',1)->with(['software.model.make'])->paginate($this->list_deletes) : Video::where('id',$id)->paginate(1), 'catalog'=>is_null($id) ? Video::where('remove',1)->with(['software.model.make'])->paginate($this->list_deletes) : Video::where('id',$id)->paginate(1),
'return'=>url('v/deletes'), 'return'=>url('v/deletes'),
'type'=>'photo', 'type'=>'video',
]); ]);
} }
@ -45,7 +45,7 @@ class VideoController extends Controller
return view('catalog.duplicatereview',[ return view('catalog.duplicatereview',[
'catalog'=>is_null($id) ? Video::duplicates()->with(['software.model.make'])->paginate($this->list_duplicates) : Video::where('id',$id)->paginate(1), 'catalog'=>is_null($id) ? Video::duplicates()->with(['software.model.make'])->paginate($this->list_duplicates) : Video::where('id',$id)->paginate(1),
'return'=>url('v/duplicates'), 'return'=>url('v/duplicates'),
'type'=>'photo', 'type'=>'video',
]); ]);
} }

View File

@ -132,7 +132,11 @@ abstract class Catalog extends Model
return $query->where(function($query) return $query->where(function($query)
{ {
$query->where('duplicate','<>',TRUE) $query->where('duplicate','<>',TRUE)
->orWhere('duplicate','=',NULL); ->orWhere('duplicate','=',NULL)
->orWhere(function($q) {
$q->where('duplicate','=',TRUE)
->where('ignore_duplicate','=',TRUE);
});
}); });
} }
@ -490,7 +494,7 @@ abstract class Catalog extends Model
public function setDateCreated() public function setDateCreated()
{ {
$this->created = $this->property('creationdate'); $this->created = $this->property('creationdate') ?: NULL;
} }
public function setHeightWidth() public function setHeightWidth()

View File

@ -126,7 +126,7 @@ class Video extends Abstracted\Catalog
public function setDateCreated() public function setDateCreated()
{ {
$this->created = strtotime($this->property('creationdate')); $this->created = $this->property('creationdate') ? strtotime($this->property('creationdate')) : NULL;
} }
public function setLocation() public function setLocation()

View File

@ -2,6 +2,7 @@
namespace App\Traits; namespace App\Traits;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
@ -20,7 +21,7 @@ trait Multimedia
{ {
switch (strtolower($type)) { switch (strtolower($type)) {
case 'photo': return 'PhotoController'; case 'photo': return 'PhotoController';
case 'video': return 'Videoontroller'; case 'video': return 'VideoController';
default: abort(500,'Type not handled?'); default: abort(500,'Type not handled?');
} }
} }
@ -50,7 +51,14 @@ trait Multimedia
private function updatePostItems(Request $request,string $class,bool $delete=FALSE) private function updatePostItems(Request $request,string $class,bool $delete=FALSE)
{ {
foreach ($request->input('items') as $id) { foreach ($request->input('items') as $id) {
$o = $class::findOrFail($id); try {
$o = $class::findOrFail($id);
} catch (ModelNotFoundException $e) {
Log::alert('Object not found: '.$id);
continue;
} catch (\Exception $e) {
dd($e);
}
// Set if duplicate // Set if duplicate
$o->duplicate = $request->input('duplicate.'.$id) ? 1 : NULL; $o->duplicate = $request->input('duplicate.'.$id) ? 1 : NULL;
@ -63,9 +71,7 @@ trait Multimedia
// Set if delete // Set if delete
if ($delete AND $o->remove AND ($request->input('remove.'.$id) ? 1 : NULL)) { if ($delete AND $o->remove AND ($request->input('remove.'.$id) ? 1 : NULL)) {
Log::info(sprintf('Dispatching delete for [%s]',$o->id)); switch (strtolower($request->input('type'))) {
switch ($class) {
case 'photo': case 'photo':
$this->dispatch((new PhotoDelete($o))->onQueue('delete')); $this->dispatch((new PhotoDelete($o))->onQueue('delete'));
Log::info(sprintf('Dispatching delete for [%s]',$o->id)); Log::info(sprintf('Dispatching delete for [%s]',$o->id));
@ -77,7 +83,7 @@ trait Multimedia
break; break;
default: default:
Log::info(sprintf('Ignoring delete for [%s] - not configured.',$o->id)); Log::info(sprintf('Ignoring delete for [%s] - not configured (%s).',$o->id,$class));
} }
} else { } else {

View File

@ -20,7 +20,7 @@
@section('main-content') @section('main-content')
<div class="row"> <div class="row">
<div class="col-4"> <div class="col-4">
<a href="{{ url('p/view',$o->id) }}">{!! $o->getHtmlImageURL() !!}</a> <a href="{{ url('v/view',$o->id) }}">{!! $o->getHtmlImageURL() !!}</a>
<span class="pagination justify-content-center"> <span class="pagination justify-content-center">
<nav> <nav>

View File

@ -29,7 +29,7 @@
<!-- /.card-body --> <!-- /.card-body -->
<div class="card-body"> <div class="card-body">
<a href="{{ url('v/view',$o->id) }}" target="{{ $o->id }}">{!! $o->getHtmlImageURL() !!}</a> {!! $o->getHtmlImageURL() !!}
</div> </div>
<!-- /.card-body --> <!-- /.card-body -->

View File

@ -11,7 +11,7 @@
<span class="progress-description"> <span class="progress-description">
<table class="table table-borderless table-sm small"> <table class="table table-borderless table-sm small">
<tr><td>To Scan</td><td>{{ \App\Models\Photo::NotScanned()->count() }}</td></tr> <tr><td>To Scan</td><td>{{ \App\Models\Photo::NotScanned()->count() }}</td></tr>
<tr><td>Duplicate</td><td>{{ \App\Models\Photo::where('duplicate',TRUE)->count() }}</td></tr> <tr><td>Duplicate</td><td>{{ \App\Models\Photo::Duplicates()->count() }}</td></tr>
<tr><td>To Delete</td><td>{{ \App\Models\Photo::where('remove',TRUE)->count() }}</td></tr> <tr><td>To Delete</td><td>{{ \App\Models\Photo::where('remove',TRUE)->count() }}</td></tr>
</table> </table>
</span> </span>
@ -34,7 +34,7 @@
<span class="progress-description"> <span class="progress-description">
<table class="table table-borderless table-sm small"> <table class="table table-borderless table-sm small">
<tr><td>To Scan</td><td>{{ \App\Models\Video::NotScanned()->count() }}</td></tr> <tr><td>To Scan</td><td>{{ \App\Models\Video::NotScanned()->count() }}</td></tr>
<tr><td>Duplicate</td><td>{{ \App\Models\Video::where('duplicate',TRUE)->count() }}</td></tr> <tr><td>Duplicate</td><td>{{ \App\Models\Video::Duplicates()->count() }}</td></tr>
<tr><td>To Delete</td><td>{{ \App\Models\Video::where('remove',TRUE)->count() }}</td></tr> <tr><td>To Delete</td><td>{{ \App\Models\Video::where('remove',TRUE)->count() }}</td></tr>
</table> </table>
</span> </span>