@@ -24,15 +24,15 @@ |
||
24 | 24 | protected function schedule(Schedule $schedule) |
25 | 25 | { |
26 | 26 | $schedule->command('colligator:harvest-oaipmh samling42 --daily') |
27 | - ->dailyAt('02:00'); |
|
27 | + ->dailyAt('02:00'); |
|
28 | 28 | |
29 | 29 | // Bring subject heading usage counts up-to-date |
30 | 30 | $schedule->command('colligator:reindex') |
31 | - ->weekly()->sundays()->at('04:00'); |
|
31 | + ->weekly()->sundays()->at('04:00'); |
|
32 | 32 | |
33 | 33 | // Check new documents for xisbn |
34 | 34 | $schedule->command('colligator:harvest-xisbn') |
35 | - ->weekly()->saturdays()->at('04:00'); |
|
35 | + ->weekly()->saturdays()->at('04:00'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -9,7 +9,7 @@ |
||
9 | 9 | |
10 | 10 | class CoverCacheServiceProvider extends ServiceProvider |
11 | 11 | { |
12 | - /** |
|
12 | + /** |
|
13 | 13 | * Indicates if loading of the provider is deferred. |
14 | 14 | * |
15 | 15 | * @var bool |
@@ -23,12 +23,12 @@ |
||
23 | 23 | */ |
24 | 24 | public function register() |
25 | 25 | { |
26 | - $this->app->singleton(CoverCache::class, function ($app) { |
|
26 | + $this->app->singleton(CoverCache::class, function($app) { |
|
27 | 27 | $fs = \Storage::disk('s3')->getAdapter(); |
28 | 28 | $im = $this->app->make(ImageManager::class); |
29 | 29 | $conf = new FlysystemConfig([ |
30 | 30 | // Default: 30 days |
31 | - 'CacheControl' => 'max-age=' . env('IMAGE_CACHE_TIME', 3153600) . ', public', |
|
31 | + 'CacheControl' => 'max-age='.env('IMAGE_CACHE_TIME', 3153600).', public', |
|
32 | 32 | ]); |
33 | 33 | return new CoverCache($fs, $im, $conf); |
34 | 34 | }); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | if (is_null($data)) { |
86 | 86 | $data = $this->download($sourceUrl); |
87 | 87 | if (!$data) { |
88 | - throw new \ErrorException('[CoverCache] Failed to download ' . $sourceUrl); |
|
88 | + throw new \ErrorException('[CoverCache] Failed to download '.$sourceUrl); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | $img = $this->imageManager->make($data); |
95 | 95 | if ($maxHeight && $img->height() > $maxHeight) { |
96 | - \Log::debug('[CachedImage] Resizing from ' . $img->height() . ' to ' . $maxHeight); |
|
96 | + \Log::debug('[CachedImage] Resizing from '.$img->height().' to '.$maxHeight); |
|
97 | 97 | $img->heighten($maxHeight); |
98 | 98 | $data = strval($img->encode('jpg')); |
99 | 99 | } |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | } |
104 | 104 | |
105 | 105 | |
106 | - \Log::debug('[CachedImage] Storing image as ' . $img->width() . ' x ' . $img->height() . ', ' . strlen($data) . ' bytes'); |
|
106 | + \Log::debug('[CachedImage] Storing image as '.$img->width().' x '.$img->height().', '.strlen($data).' bytes'); |
|
107 | 107 | if (!$this->filesystem->write($cacheKey, $data, $this->fsConfig)) { |
108 | 108 | throw new \ErrorException('[CoverCache] Failed to upload thumb to S3'); |
109 | 109 | } |
110 | 110 | |
111 | - \Log::debug('[CachedImage] Wrote cached version as ' . $cacheKey); |
|
111 | + \Log::debug('[CachedImage] Wrote cached version as '.$cacheKey); |
|
112 | 112 | |
113 | 113 | return new CachedImage($this, $cacheKey); |
114 | 114 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | { |
140 | 140 | $data = $this->filesystem->read($cacheKey); |
141 | 141 | $blob = strval($data['contents']); |
142 | - \Log::debug('[CachedImage] Read ' .$cacheKey . ': ' . strlen($blob) . ' bytes'); |
|
142 | + \Log::debug('[CachedImage] Read '.$cacheKey.': '.strlen($blob).' bytes'); |
|
143 | 143 | |
144 | 144 | return $this->putBlob($blob, $maxHeight); |
145 | 145 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | public function sanitizeForQuery($value) |
101 | 101 | { |
102 | 102 | $chars = preg_quote('\\+-&|!(){}[]^~*?:'); |
103 | - $value = preg_replace('/([' . $chars . '])/', '\\\\\1', $value); |
|
103 | + $value = preg_replace('/(['.$chars.'])/', '\\\\\1', $value); |
|
104 | 104 | |
105 | 105 | return $value; |
106 | 106 | // |
@@ -132,20 +132,20 @@ discard block |
||
132 | 132 | } |
133 | 133 | if ($request->has('collection')) { |
134 | 134 | $col = Collection::findOrFail($request->collection); |
135 | - $query[] = 'collections:"' . $this->sanitizeForQuery($col->name) . '"'; |
|
135 | + $query[] = 'collections:"'.$this->sanitizeForQuery($col->name).'"'; |
|
136 | 136 | } |
137 | 137 | if ($request->has('subject')) { |
138 | - $query[] = '(subjects.noubomn.prefLabel:"' . $this->sanitizeForQuery($request->subject) . '"' . |
|
139 | - ' OR subjects.bare.prefLabel:"' . $this->sanitizeForQuery($request->subject) . '"' . |
|
140 | - ' OR genres.noubomn.prefLabel:"' . $this->sanitizeForQuery($request->subject) . '")'; |
|
138 | + $query[] = '(subjects.noubomn.prefLabel:"'.$this->sanitizeForQuery($request->subject).'"'. |
|
139 | + ' OR subjects.bare.prefLabel:"'.$this->sanitizeForQuery($request->subject).'"'. |
|
140 | + ' OR genres.noubomn.prefLabel:"'.$this->sanitizeForQuery($request->subject).'")'; |
|
141 | 141 | // TODO: Vi bør vel antakelig skille mellom X som emne og X som form/sjanger ? |
142 | 142 | // Men da må frontend si fra hva den ønsker, noe den ikke gjør enda. |
143 | 143 | } |
144 | 144 | if ($request->has('language')) { |
145 | - $query[] = 'language:"' . $this->sanitizeForQuery($request->language) . '"' ; |
|
145 | + $query[] = 'language:"'.$this->sanitizeForQuery($request->language).'"'; |
|
146 | 146 | } |
147 | 147 | if ($request->has('genre')) { |
148 | - $query[] = 'genres.noubomn.prefLabel:"' . $this->sanitizeForQuery($request->genre) . '"'; |
|
148 | + $query[] = 'genres.noubomn.prefLabel:"'.$this->sanitizeForQuery($request->genre).'"'; |
|
149 | 149 | } |
150 | 150 | if ($request->has('real')) { |
151 | 151 | dd('`real` is (very) deprecated, please use `subject` instead.'); |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | public function getUsageCount($id, $type) |
184 | 184 | { |
185 | 185 | $this->getFullType($type); |
186 | - $arg = $type . '.' . $id; |
|
186 | + $arg = $type.'.'.$id; |
|
187 | 187 | if (is_null(array_get($this->usage, $arg))) { |
188 | 188 | $this->addToUsageCache($id, $type); |
189 | 189 | } |
@@ -212,11 +212,11 @@ discard block |
||
212 | 212 | ->get(); |
213 | 213 | |
214 | 214 | foreach ($entity_ids as $sid) { |
215 | - array_set($this->usage, $type . '.' . $sid, 0); |
|
215 | + array_set($this->usage, $type.'.'.$sid, 0); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | foreach ($res as $row) { |
219 | - array_set($this->usage, $type . '.' . $row->entity_id, intval($row->doc_count)); |
|
219 | + array_set($this->usage, $type.'.'.$row->entity_id, intval($row->doc_count)); |
|
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
@@ -226,10 +226,10 @@ discard block |
||
226 | 226 | $query = \DB::table('entities') |
227 | 227 | ->select(['entity_id', 'entity_type', \DB::raw('count(document_id) as doc_count')]) |
228 | 228 | ->groupBy('entity_id', 'entity_type'); |
229 | - $query->orderBy('entity_id')->orderBy('entity_type')->chunk(5000, function ($rows) use ($typemap) { |
|
229 | + $query->orderBy('entity_id')->orderBy('entity_type')->chunk(5000, function($rows) use ($typemap) { |
|
230 | 230 | foreach ($rows as $row) { |
231 | 231 | $type = $typemap[$row->entity_type]; |
232 | - array_set($this->usage, $type . '.' . $row->entity_id, intval($row->doc_count)); |
|
232 | + array_set($this->usage, $type.'.'.$row->entity_id, intval($row->doc_count)); |
|
233 | 233 | } |
234 | 234 | }); |
235 | 235 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | { |
247 | 247 | $payload = $this->basePayload(); |
248 | 248 | if (!is_null($indexVersion)) { |
249 | - $payload['index'] = $this->esIndex . '_v' . $indexVersion; |
|
249 | + $payload['index'] = $this->esIndex.'_v'.$indexVersion; |
|
250 | 250 | } |
251 | 251 | $payload['id'] = $doc->id; |
252 | 252 | |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | try { |
257 | 257 | $this->client->index($payload); |
258 | 258 | } catch (BadRequest400Exception $e) { |
259 | - \Log::error('ElasticSearch returned error: ' . $e->getMessage() . '. Our request: ' . var_export($payload, true)); |
|
260 | - throw new \ErrorException('ElasticSearch failed to index the document ' . $doc->id . '. Please see the log for payload and full error response. Error message: ' . $e->getMessage()); |
|
259 | + \Log::error('ElasticSearch returned error: '.$e->getMessage().'. Our request: '.var_export($payload, true)); |
|
260 | + throw new \ErrorException('ElasticSearch failed to index the document '.$doc->id.'. Please see the log for payload and full error response. Error message: '.$e->getMessage()); |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | if (is_null($version)) { |
279 | 279 | $version = $this->getCurrentVersion() + 1; |
280 | 280 | } |
281 | - $indexParams = ['index' => $this->esIndex . '_v' . $version]; |
|
281 | + $indexParams = ['index' => $this->esIndex.'_v'.$version]; |
|
282 | 282 | $indexParams['body']['settings']['analysis']['char_filter']['isbn_filter'] = [ |
283 | 283 | 'type' => 'pattern_replace', |
284 | 284 | 'pattern' => '-', |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | { |
327 | 327 | try { |
328 | 328 | $this->client->indices()->delete([ |
329 | - 'index' => $this->esIndex . '_v' . $version, |
|
329 | + 'index' => $this->esIndex.'_v'.$version, |
|
330 | 330 | ]); |
331 | 331 | } catch (Missing404Exception $e) { |
332 | 332 | # Didn't exist in the beginning, that's ok. |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | public function addAction(&$actions, $action, $version) |
337 | 337 | { |
338 | 338 | if ($version) { |
339 | - $actions[] = [$action => ['index' => $this->esIndex . '_v' . $version, 'alias' => $this->esIndex]]; |
|
339 | + $actions[] = [$action => ['index' => $this->esIndex.'_v'.$version, 'alias' => $this->esIndex]]; |
|
340 | 340 | } |
341 | 341 | } |
342 | 342 | |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | |
354 | 354 | public function versionExists($version) |
355 | 355 | { |
356 | - return $this->client->indices()->exists(['index' => $this->esIndex . '_v' . $version]); |
|
356 | + return $this->client->indices()->exists(['index' => $this->esIndex.'_v'.$version]); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | public function getCurrentVersion() |