- add SolrIndexBuilder artisan command
- Sitelinkcontroller: data filter via raw sql - primary key for HasValue model - config/solarium.php new config values - bug on migration fie for document_xml_cache
This commit is contained in:
parent
54edfb4617
commit
084a1a2b8c
7 changed files with 174 additions and 63 deletions
60
app/Console/Commands/SolrIndexBuilder.php
Normal file
60
app/Console/Commands/SolrIndexBuilder.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Dataset;
|
||||
// use Illuminate\Support\Facades\Log;
|
||||
// use App\Library\Search\SolariumAdapter;
|
||||
|
||||
class SolrIndexBuilder extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'index:dataset';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Indexes all datasets';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$datasets = Dataset::where('server_state', 'published')->get();
|
||||
|
||||
// update statistics table
|
||||
foreach ($datasets as $dataset) {
|
||||
$datasetId = $dataset->id;
|
||||
$time = new \Illuminate\Support\Carbon();
|
||||
$dataset->server_date_published = $time;
|
||||
$dataset->save();
|
||||
// try {
|
||||
// // Opus_Search_Service::selectIndexingService('onDocumentChange')
|
||||
// $service = new SolariumAdapter("solr", config('solarium'));
|
||||
// $service->addDatasetsToIndex($dataset);
|
||||
// } catch (Exception $e) {
|
||||
// Log::debug(__METHOD__ . ': ' . 'Indexing document ' . $datasetId . ' failed: ' . $e->getMessage());
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,7 +13,8 @@ class Kernel extends ConsoleKernel
|
|||
*/
|
||||
protected $commands = [
|
||||
'App\Console\Commands\Inspire',
|
||||
'App\Console\Commands\DatasetState'
|
||||
'App\Console\Commands\DatasetState',
|
||||
'App\Console\Commands\SolrIndexBuilder'
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,20 +16,21 @@ class SitelinkController extends Controller
|
|||
$select = DB::table('documents')
|
||||
->where('server_state', 'LIKE', "%" . $serverState . "%");
|
||||
|
||||
// $select
|
||||
// ->select(DB::raw('EXTRACT(YEAR FROM server_date_published) as published_date'))
|
||||
// // ->select(DB::raw("DATE_PART('year', server_date_published) as published_date"))
|
||||
// // ->select(DB::raw("YEAR(server_date_published) AS published_date"))
|
||||
// ->distinct(true);
|
||||
$select
|
||||
->select(DB::raw('EXTRACT(YEAR FROM server_date_published) as published_date'))
|
||||
// ->select(DB::raw("DATE_PART('year', server_date_published) as published_date"))
|
||||
// ->select(DB::raw("YEAR(server_date_published) AS published_date"))
|
||||
->distinct(true);
|
||||
$this->years = $select->pluck('published_date')->toArray();
|
||||
|
||||
$years = $select->pluck('server_date_published')->toArray();
|
||||
$this->years = array_map(function ($pdate) {
|
||||
$dateValue = strtotime($pdate);
|
||||
if ($dateValue != false) {
|
||||
$year = date("Y", $dateValue);
|
||||
return $year;
|
||||
}
|
||||
}, $years);
|
||||
// $years = $select->pluck('server_date_published')->toArray();
|
||||
// $this->years = array_map(function ($pdate) {
|
||||
// $dateValue = strtotime($pdate);
|
||||
// if ($dateValue != false) {
|
||||
// $year = date("Y", $dateValue);
|
||||
// return $year;
|
||||
// }
|
||||
// }, $years);
|
||||
$this->ids = array();
|
||||
return view('frontend.sitelink.index')->with(['years' => $this->years, 'documents' => $this->ids]);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@ class HashValue extends Model
|
|||
protected $table = 'file_hashvalues';
|
||||
public $timestamps = false;
|
||||
|
||||
protected $primaryKey = ['file_id', 'type'];
|
||||
public $incrementing = false;
|
||||
|
||||
public function file()
|
||||
{
|
||||
return $this->belongsTo(File::class, 'file_id', 'id');
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue