Skip to content

Commit f225283

Browse files
committed
Refactor + fix bugs in new search
1 parent c14c549 commit f225283

12 files changed

+95
-246
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/storage/*.key
88
/storage
99
/vendor
10+
/.scannerwork
1011
/.idea
1112
/.vagrant
1213
Homestead.json

app/Console/Commands/GenerateCalendarEvents.php

-10
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ class GenerateCalendarEvents extends Command
2525
*/
2626
protected $description = 'Move the calendar events to entity events';
2727

28-
/**
29-
* Create a new command instance.
30-
*
31-
* @return void
32-
*/
33-
public function __construct()
34-
{
35-
parent::__construct();
36-
}
37-
3828
/**
3929
* Execute the console command.
4030
*/

app/Console/Commands/GenerateDescriptionMerge.php

-92
This file was deleted.

app/Console/Commands/GenerateEntityMentionMap.php

+10-9
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
class GenerateEntityMentionMap extends Command
1515
{
16+
const ENTRY_FIELD = 'entry';
17+
1618
/**
1719
* The name and signature of the console command.
1820
*
@@ -75,6 +77,8 @@ public function handle()
7577
];
7678
$this->entityMapping->verbose = true;
7779

80+
$tooltip = 'data-toggle="tooltip"';
81+
7882
// Cleanup any existing mentions
7983
EntityMention::truncate();
8084

@@ -85,13 +89,13 @@ public function handle()
8589
$model = new $entity;
8690
$model
8791
->with('entity')
88-
->where('entry', 'like', '%redirect?what=%')
89-
->chunk(1000, function ($models) use ($entity) {
92+
->where(self::ENTRY_FIELD, 'like', '%redirect?what=%')
93+
->chunk(1000, function ($models) {
9094
/** @var MiscModel $model */
9195
foreach ($models as $model) {
9296
$pattern = '<a href="([^"]*)">(.*?)&lt;(.*?)&gt;';
9397
$model->entry = preg_replace("`$pattern`i", '<a href="$1">$2</a>', $model->entry);
94-
if ($model->isDirty('entry')) {
98+
if ($model->isDirty(self::ENTRY_FIELD)) {
9599
$this->redirectFixed++;
96100
$model->timestamps = false;
97101
$model->save();
@@ -106,14 +110,13 @@ public function handle()
106110
$model = new $entity;
107111
$model
108112
->with('entity')
109-
->where('entry', 'like', '%data-toggle="tooltip"%')
113+
->where(self::ENTRY_FIELD, 'like', '%' . $tooltip . '%')
110114
->chunk(5000, function ($models) use ($entity) {
111115
$bar = $this->output->createProgressBar(count($models));
112116
$bar->start();
113117
foreach ($models as $model) {
114118
$this->entityCount++;
115119
/** @var MiscModel $model */
116-
//$this->info("Checking " . $model->getTable() . ":" . $model->id);
117120
$this->mapCount += $this->entityMapping->mapModel($model);
118121
$bar->advance();
119122
}
@@ -126,13 +129,12 @@ public function handle()
126129
// Entity Notes
127130
$this->info("Entity Notes");
128131
$this->mapCount = 0;
129-
EntityNote::where('entry', 'like', '%data-toggle="tooltip"%')->chunk(5000, function ($models) {
132+
EntityNote::where(self::ENTRY_FIELD, 'like', '%' . $tooltip . '%')->chunk(5000, function ($models) {
130133
$bar = $this->output->createProgressBar(count($models));
131134
$bar->start();
132135
foreach ($models as $model) {
133136
$this->entityCount++;
134137
/** @var EntityNote $model */
135-
//$this->info("Checking entity_note:" . $model->id);
136138
$this->mapCount += $this->entityMapping->mapEntityNote($model);
137139
$bar->advance();
138140
}
@@ -144,13 +146,12 @@ public function handle()
144146
// Campaigns
145147
$this->info("Campaigns");
146148
$this->mapCount = 0;
147-
Campaign::where('entry', 'like', '%data-toggle="tooltip"%')->chunk(5000, function ($models) {
149+
Campaign::where(self::ENTRY_FIELD, 'like', '%' . $tooltip . '%')->chunk(5000, function ($models) {
148150
$bar = $this->output->createProgressBar(count($models));
149151
$bar->start();
150152
foreach ($models as $model) {
151153
$this->entityCount++;
152154
/** @var Campaign $model */
153-
//$this->info("Checking campaign:" . $model->id);
154155
$this->mapCount += $this->entityMapping->mapCampaign($model);
155156
$bar->advance();
156157
}

app/Console/Commands/GenerateImageMove.php

+30-37
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,6 @@ class GenerateImageMove extends Command
3333
*/
3434
protected $description = 'Move local images to s3';
3535

36-
/**
37-
* Create a new command instance.
38-
*
39-
* @return void
40-
*/
41-
public function __construct()
42-
{
43-
parent::__construct();
44-
}
45-
4636
/**
4737
* Execute the console command.
4838
*
@@ -51,79 +41,81 @@ public function __construct()
5141
public function handle()
5242
{
5343
$count = 0;
44+
$imageField = 'image';
45+
$thumbName = '_thumb';
5446

55-
foreach (Calendar::whereNotNull('image')->get() as $model) {
47+
foreach (Calendar::whereNotNull($imageField)->get() as $model) {
5648
$count++;
5749
$this->move($model->image);
58-
$thumb = str_replace('.', '_thumb.', $model->image);
50+
$thumb = str_replace('.', $thumbName, $model->image);
5951
$this->move($thumb);
6052
}
61-
foreach (Campaign::whereNotNull('image')->get() as $model) {
53+
foreach (Campaign::whereNotNull($imageField)->get() as $model) {
6254
$count++;
6355
$this->move($model->image);
64-
$thumb = str_replace('.', '_thumb.', $model->image);
56+
$thumb = str_replace('.', $thumbName, $model->image);
6557
$this->move($thumb);
6658
}
67-
foreach (Character::whereNotNull('image')->get() as $model) {
59+
foreach (Character::whereNotNull($imageField)->get() as $model) {
6860
$count++;
6961
$this->move($model->image);
70-
$thumb = str_replace('.', '_thumb.', $model->image);
62+
$thumb = str_replace('.', $thumbName, $model->image);
7163
$this->move($thumb);
7264
}
73-
foreach (Event::whereNotNull('image')->get() as $model) {
65+
foreach (Event::whereNotNull($imageField)->get() as $model) {
7466
$count++;
7567
$this->move($model->image);
76-
$thumb = str_replace('.', '_thumb.', $model->image);
68+
$thumb = str_replace('.', $thumbName, $model->image);
7769
$this->move($thumb);
7870
}
79-
foreach (Family::whereNotNull('image')->get() as $model) {
71+
foreach (Family::whereNotNull($imageField)->get() as $model) {
8072
$count++;
8173
$this->move($model->image);
82-
$thumb = str_replace('.', '_thumb.', $model->image);
74+
$thumb = str_replace('.', $thumbName, $model->image);
8375
$this->move($thumb);
8476
}
85-
foreach (Item::whereNotNull('image')->get() as $model) {
77+
foreach (Item::whereNotNull($imageField)->get() as $model) {
8678
$count++;
8779
$this->move($model->image);
88-
$thumb = str_replace('.', '_thumb.', $model->image);
80+
$thumb = str_replace('.', $thumbName, $model->image);
8981
$this->move($thumb);
9082
}
91-
foreach (Journal::whereNotNull('image')->get() as $model) {
83+
foreach (Journal::whereNotNull($imageField)->get() as $model) {
9284
$count++;
9385
$this->move($model->image);
94-
$thumb = str_replace('.', '_thumb.', $model->image);
86+
$thumb = str_replace('.', $thumbName, $model->image);
9587
$this->move($thumb);
9688
}
97-
foreach (Location::whereNotNull('image')->get() as $model) {
89+
foreach (Location::whereNotNull($imageField)->get() as $model) {
9890
$count++;
9991
$this->move($model->image);
10092
$this->move($model->map);
10193

102-
$thumb = str_replace('.', '_thumb.', $model->image);
94+
$thumb = str_replace('.', $thumbName, $model->image);
10395
$this->move($thumb);
10496
}
105-
foreach (Note::whereNotNull('image')->get() as $model) {
97+
foreach (Note::whereNotNull($imageField)->get() as $model) {
10698
$count++;
10799
$this->move($model->image);
108-
$thumb = str_replace('.', '_thumb.', $model->image);
100+
$thumb = str_replace('.', $thumbName, $model->image);
109101
$this->move($thumb);
110102
}
111-
foreach (Organisation::whereNotNull('image')->get() as $model) {
103+
foreach (Organisation::whereNotNull($imageField)->get() as $model) {
112104
$count++;
113105
$this->move($model->image);
114-
$thumb = str_replace('.', '_thumb.', $model->image);
106+
$thumb = str_replace('.', $thumbName, $model->image);
115107
$this->move($thumb);
116108
}
117-
foreach (Quest::whereNotNull('image')->get() as $model) {
109+
foreach (Quest::whereNotNull($imageField)->get() as $model) {
118110
$count++;
119111
$this->move($model->image);
120-
$thumb = str_replace('.', '_thumb.', $model->image);
112+
$thumb = str_replace('.', $thumbName, $model->image);
121113
$this->move($thumb);
122114
}
123-
foreach (Tag::whereNotNull('image')->get() as $model) {
115+
foreach (Tag::whereNotNull($imageField)->get() as $model) {
124116
$count++;
125117
$this->move($model->image);
126-
$thumb = str_replace('.', '_thumb.', $model->image);
118+
$thumb = str_replace('.', $thumbName, $model->image);
127119
$this->move($thumb);
128120
}
129121

@@ -137,9 +129,10 @@ public function handle()
137129
*/
138130
protected function move($file)
139131
{
140-
if (Storage::disk('public')->exists($file)) {
141-
$content = Storage::disk('public')->get($file);
142-
Storage::disk('s3')->put($file, $content, 'public');
132+
$disk = 'public';
133+
if (Storage::disk($disk)->exists($file)) {
134+
$content = Storage::disk($disk)->get($file);
135+
Storage::disk('s3')->put($file, $content, $disk);
143136
unset($content);
144137
}
145138
}

app/Console/Commands/GenerateLocationPoint.php

-10
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,6 @@ class GenerateLocationPoint extends Command
2626

2727
protected $points = 0;
2828

29-
/**
30-
* Create a new command instance.
31-
*
32-
* @return void
33-
*/
34-
public function __construct()
35-
{
36-
parent::__construct();
37-
}
38-
3929
/**
4030
* Execute the console command.
4131
*/

0 commit comments

Comments
 (0)