Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

Commit

Permalink
fix: fix setup and dummy in case meilisearch not activated
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin committed Aug 3, 2022
1 parent 73848ee commit ff8c819
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 22 deletions.
38 changes: 20 additions & 18 deletions app/Console/Commands/SetupApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,26 @@ public function handle(): void

$this->line('-> Creating indexes on Meilisearch. Make sure Meilisearch is running.');

$client = new Client(config('scout.meilisearch.host'), config('scout.meilisearch.key'));
$index = $client->index('contacts');
$index->updateFilterableAttributes([
'id',
'vault_id',
]);
$index = $client->index('notes');
$index->updateFilterableAttributes([
'id',
'vault_id',
'contact_id',
]);
$index = $client->index('groups');
$index->updateFilterableAttributes([
'id',
'vault_id',
]);
if (($host = config('scout.meilisearch.host')) !== '') {
$client = new Client($host, config('scout.meilisearch.key'));
$index = $client->index('contacts');
$index->updateFilterableAttributes([
'id',
'vault_id',
]);
$index = $client->index('notes');
$index->updateFilterableAttributes([
'id',
'vault_id',
'contact_id',
]);
$index = $client->index('groups');
$index->updateFilterableAttributes([
'id',
'vault_id',
]);

$this->line('✓ Indexes created');
$this->line('✓ Indexes created');
}
}
}
11 changes: 7 additions & 4 deletions app/Console/Commands/SetupDummyAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Carbon\Carbon;
use Faker\Factory as Faker;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http;

class SetupDummyAccount extends Command
{
Expand Down Expand Up @@ -81,9 +82,11 @@ private function start(): void

private function wipeAndMigrateDB(): void
{
shell_exec('curl -X DELETE "'.config('scout.meilisearch.host').'/indexes/notes"');
shell_exec('curl -X DELETE "'.config('scout.meilisearch.host').'/indexes/contacts"');
shell_exec('curl -X DELETE "'.config('scout.meilisearch.host').'/indexes/groups"');
if (($host = config('scout.meilisearch.host')) !== '') {
Http::delete("$host/indexes/notes");
Http::delete("$host/indexes/contacts");
Http::delete("$host/indexes/groups");
}
$this->artisan('☐ Reset search engine', 'monica:setup');
$this->artisan('☐ Migration of the database', 'migrate:fresh');
$this->artisan('☐ Symlink the storage folder', 'storage:link');
Expand Down Expand Up @@ -124,7 +127,7 @@ private function createFirstUsers(): void
]);
$this->firstUser->email_verified_at = Carbon::now();
$this->firstUser->save();
sleep(5);
// sleep(5);
}

private function createVaults(): void
Expand Down
1 change: 1 addition & 0 deletions lang/php_en.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lang/php_fr.json

Large diffs are not rendered by default.

0 comments on commit ff8c819

Please sign in to comment.