@@ -13,6 +13,9 @@ discard block |
||
| 13 | 13 | public $maxHeight; |
| 14 | 14 | protected $_metadata; |
| 15 | 15 | |
| 16 | + /** |
|
| 17 | + * @param string $url |
|
| 18 | + */ |
|
| 16 | 19 | public function __construct($url, $maxHeight = 0, AdapterInterface $filesystem = null, ImageManager $imageManager = null) |
| 17 | 20 | { |
| 18 | 21 | $this->sourceUrl = $url; |
@@ -37,6 +40,9 @@ discard block |
||
| 37 | 40 | return $this->_metadata; |
| 38 | 41 | } |
| 39 | 42 | |
| 43 | + /** |
|
| 44 | + * @param string $file |
|
| 45 | + */ |
|
| 40 | 46 | protected function setMetadata($file, Image $img) |
| 41 | 47 | { |
| 42 | 48 | $this->_metadata = [ |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | /** |
| 38 | 38 | * The document the cover belongs to. |
| 39 | 39 | * |
| 40 | - * @return Document |
|
| 40 | + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
| 41 | 41 | */ |
| 42 | 42 | public function document() |
| 43 | 43 | { |
@@ -15,7 +15,6 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * Create a new scraper. |
| 17 | 17 | * |
| 18 | - * @param Client $client |
|
| 19 | 18 | */ |
| 20 | 19 | public function __construct() |
| 21 | 20 | { |
@@ -35,6 +34,11 @@ discard block |
||
| 35 | 34 | } |
| 36 | 35 | } |
| 37 | 36 | |
| 37 | + /** |
|
| 38 | + * @param string $msg |
|
| 39 | + * @param Document $doc |
|
| 40 | + * @param string[] $args |
|
| 41 | + */ |
|
| 38 | 42 | public function notify($msg, $doc, $args, $level = 'warning') |
| 39 | 43 | { |
| 40 | 44 | $msg = vsprintf($msg, $args); |
@@ -46,6 +50,9 @@ discard block |
||
| 46 | 50 | ])->send(); |
| 47 | 51 | } |
| 48 | 52 | |
| 53 | + /** |
|
| 54 | + * @param string $url |
|
| 55 | + */ |
|
| 49 | 56 | public function scrape($url) |
| 50 | 57 | { |
| 51 | 58 | foreach ($this->scrapers as $scraper) { |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | /** |
| 11 | 11 | * Display a listing of the resource. |
| 12 | 12 | * |
| 13 | - * @return Response |
|
| 13 | + * @return \Illuminate\Http\JsonResponse |
|
| 14 | 14 | */ |
| 15 | 15 | public function index() |
| 16 | 16 | { |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @param int $id |
| 26 | 26 | * |
| 27 | - * @return Response |
|
| 27 | + * @return \Illuminate\Http\JsonResponse |
|
| 28 | 28 | */ |
| 29 | 29 | public function show($id) |
| 30 | 30 | { |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * Display a listing of the resource. |
| 15 | 15 | * |
| 16 | - * @return Response |
|
| 16 | + * @return \Illuminate\Http\JsonResponse |
|
| 17 | 17 | */ |
| 18 | 18 | public function index(SearchDocumentsRequest $request, DocumentsIndex $se) |
| 19 | 19 | { |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @param DocumentsIndex $se |
| 66 | 66 | * @param int $id |
| 67 | 67 | * |
| 68 | - * @return Response |
|
| 68 | + * @return \Illuminate\Http\JsonResponse |
|
| 69 | 69 | */ |
| 70 | 70 | public function show(Request $request, DocumentsIndex $se, $id) |
| 71 | 71 | { |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | /** |
| 126 | 126 | * Show cover. |
| 127 | 127 | * |
| 128 | - * @return Response |
|
| 128 | + * @return \Illuminate\Http\JsonResponse |
|
| 129 | 129 | */ |
| 130 | 130 | public function cover($document_id) |
| 131 | 131 | { |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | /** |
| 140 | 140 | * Store cover. |
| 141 | 141 | * |
| 142 | - * @return Response |
|
| 142 | + * @return \Illuminate\Http\JsonResponse |
|
| 143 | 143 | */ |
| 144 | 144 | public function storeCover($document_id, Request $request, DocumentsIndex $se) |
| 145 | 145 | { |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | /** |
| 172 | 172 | * Store description. |
| 173 | 173 | * |
| 174 | - * @return Response |
|
| 174 | + * @return \Illuminate\Http\JsonResponse |
|
| 175 | 175 | */ |
| 176 | 176 | public function storeDescription($document_id, Request $request, DocumentsIndex $se) |
| 177 | 177 | { |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Colligator\Http\Controllers; |
| 4 | 4 | |
| 5 | -use Colligator\Cover; |
|
| 6 | 5 | use Colligator\Document; |
| 7 | 6 | use Colligator\Http\Requests\SearchDocumentsRequest; |
| 8 | 7 | use Colligator\Search\DocumentsIndex; |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | /** |
| 10 | 10 | * Display a listing of the resource. |
| 11 | 11 | * |
| 12 | - * @return Response |
|
| 12 | + * @return \Illuminate\Http\JsonResponse |
|
| 13 | 13 | */ |
| 14 | 14 | public function index() |
| 15 | 15 | { |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @param int $id |
| 23 | 23 | * |
| 24 | - * @return Response |
|
| 24 | + * @return \Illuminate\Http\JsonResponse |
|
| 25 | 25 | */ |
| 26 | 26 | public function show($id) |
| 27 | 27 | { |
@@ -168,6 +168,7 @@ discard block |
||
| 168 | 168 | * Returns the number of documents the subject is used on. |
| 169 | 169 | * |
| 170 | 170 | * @param int $id |
| 171 | + * @param string $type |
|
| 171 | 172 | * |
| 172 | 173 | * @return int |
| 173 | 174 | */ |
@@ -185,8 +186,8 @@ discard block |
||
| 185 | 186 | /** |
| 186 | 187 | * Build an array of document usage count per subject. |
| 187 | 188 | * |
| 188 | - * @param array|int $subject_ids |
|
| 189 | 189 | * |
| 190 | + * @param integer $entity_ids |
|
| 190 | 191 | * @return array |
| 191 | 192 | */ |
| 192 | 193 | public function addToUsageCache($entity_ids, $type) |
@@ -264,6 +265,9 @@ discard block |
||
| 264 | 265 | $this->index(Document::with('subjects', 'cover')->findOrFail($docId)); |
| 265 | 266 | } |
| 266 | 267 | |
| 268 | + /** |
|
| 269 | + * @param integer $version |
|
| 270 | + */ |
|
| 267 | 271 | public function createVersion($version = null) |
| 268 | 272 | { |
| 269 | 273 | if (is_null($version)) { |
@@ -307,6 +311,9 @@ discard block |
||
| 307 | 311 | return $version; |
| 308 | 312 | } |
| 309 | 313 | |
| 314 | + /** |
|
| 315 | + * @param integer $version |
|
| 316 | + */ |
|
| 310 | 317 | public function dropVersion($version) |
| 311 | 318 | { |
| 312 | 319 | try { |
@@ -318,6 +325,9 @@ discard block |
||
| 318 | 325 | } |
| 319 | 326 | } |
| 320 | 327 | |
| 328 | + /** |
|
| 329 | + * @param string $action |
|
| 330 | + */ |
|
| 321 | 331 | public function addAction(&$actions, $action, $version) |
| 322 | 332 | { |
| 323 | 333 | if ($version) { |
@@ -325,6 +335,9 @@ discard block |
||
| 325 | 335 | } |
| 326 | 336 | } |
| 327 | 337 | |
| 338 | + /** |
|
| 339 | + * @param integer $newVersion |
|
| 340 | + */ |
|
| 328 | 341 | public function activateVersion($newVersion) |
| 329 | 342 | { |
| 330 | 343 | $oldVersion = $this->getCurrentVersion(); |
@@ -336,6 +349,9 @@ discard block |
||
| 336 | 349 | } |
| 337 | 350 | } |
| 338 | 351 | |
| 352 | + /** |
|
| 353 | + * @param integer $version |
|
| 354 | + */ |
|
| 339 | 355 | public function versionExists($version) |
| 340 | 356 | { |
| 341 | 357 | return $this->client->indices()->exists(['index' => $this->esIndex . '_v' . $version]); |
@@ -217,7 +217,7 @@ |
||
| 217 | 217 | $query = \DB::table('entities') |
| 218 | 218 | ->select(['entity_id', 'entity_type', \DB::raw('count(document_id) as doc_count')]) |
| 219 | 219 | ->groupBy('entity_id', 'entity_type'); |
| 220 | - $query->chunk(5000, function ($rows) use ($typemap) { |
|
| 220 | + $query->chunk(5000, function($rows) use ($typemap) { |
|
| 221 | 221 | foreach ($rows as $row) { |
| 222 | 222 | $type = $typemap[$row->entity_type]; |
| 223 | 223 | array_set($this->usage, $type . '.' . $row->entity_id, intval($row->doc_count)); |
@@ -154,11 +154,11 @@ discard block |
||
| 154 | 154 | // For timing |
| 155 | 155 | $this->startTime = $this->batchTime = microtime(true) - 1; |
| 156 | 156 | |
| 157 | - \Event::listen('Colligator\Events\OaiPmhHarvestStatus', function ($event) { |
|
| 157 | + \Event::listen('Colligator\Events\OaiPmhHarvestStatus', function($event) { |
|
| 158 | 158 | $this->status($event->harvested, $event->position, $event->total); |
| 159 | 159 | }); |
| 160 | 160 | |
| 161 | - \Event::listen('Colligator\Events\OaiPmhHarvestComplete', function ($event) { |
|
| 161 | + \Event::listen('Colligator\Events\OaiPmhHarvestComplete', function($event) { |
|
| 162 | 162 | $this->info(sprintf('[%s] Harvest complete, got %d records in %d seconds', |
| 163 | 163 | strftime('%Y-%m-%d %H:%M:%S'), |
| 164 | 164 | $event->count, |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | )); |
| 167 | 167 | }); |
| 168 | 168 | |
| 169 | - \Event::listen('Colligator\Events\JobError', function ($event) { |
|
| 169 | + \Event::listen('Colligator\Events\JobError', function($event) { |
|
| 170 | 170 | \Log::error('[OaiPmhHarvest] ' . $event->msg); |
| 171 | 171 | $this->error($event->msg); |
| 172 | 172 | }); |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | $docCount = Document::count(); |
| 59 | 59 | $this->output->progressStart($docCount); |
| 60 | 60 | |
| 61 | - Document::with('subjects', 'genres', 'cover')->chunk(1000, function ($docs) use ($docIndex, $newVersion) { |
|
| 61 | + Document::with('subjects', 'genres', 'cover')->chunk(1000, function($docs) use ($docIndex, $newVersion) { |
|
| 62 | 62 | foreach ($docs as $doc) { |
| 63 | 63 | $docIndex->index($doc, $newVersion); |
| 64 | 64 | $this->output->progressAdvance(); |