diff --git a/.editorconfig b/.editorconfig index 8f0de65c..dd9a2b51 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,6 +13,3 @@ trim_trailing_whitespace = false [*.{yml,yaml}] indent_size = 2 - -[docker-compose.yml] -indent_size = 4 diff --git a/app/Services/Nominatim.php b/app/Services/Nominatim.php index 2e8ce714..b50e1276 100644 --- a/app/Services/Nominatim.php +++ b/app/Services/Nominatim.php @@ -21,6 +21,8 @@ public static function search(string $query, int $limit = 5): Collection ->query($query) ->limit($limit); - return collect($nominatim->find($request)); + return collect( + rescue(fn () => $nominatim->find($request)) + ); } } diff --git a/composer.json b/composer.json index c9ce58ea..76be55a4 100644 --- a/composer.json +++ b/composer.json @@ -25,6 +25,7 @@ "laravel/tinker": "^2.8", "league/flysystem-aws-s3-v3": "^3.28", "matanyadaev/laravel-eloquent-spatial": "^4.2", + "meilisearch/meilisearch-php": "^1.9", "phpoffice/phpspreadsheet": "^1.29", "pxlrbt/filament-excel": "^2.1", "spatie/laravel-permission": "^5.11", diff --git a/composer.lock b/composer.lock index 1277d4b7..73cb9dc4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "46aba2ce59d39fad54c5fd09b82e426b", + "content-hash": "2f8f496314db6899bd0478ea6c2539e3", "packages": [ { "name": "anourvalar/eloquent-serialize", @@ -4444,6 +4444,73 @@ }, "time": "2024-04-02T18:42:41+00:00" }, + { + "name": "meilisearch/meilisearch-php", + "version": "v1.9.1", + "source": { + "type": "git", + "url": "https://github.com/meilisearch/meilisearch-php.git", + "reference": "c4eb8ecd08799abd65d00dc74f4372b61af1fc37" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/meilisearch/meilisearch-php/zipball/c4eb8ecd08799abd65d00dc74f4372b61af1fc37", + "reference": "c4eb8ecd08799abd65d00dc74f4372b61af1fc37", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": "^7.4 || ^8.0", + "php-http/discovery": "^1.7", + "psr/http-client": "^1.0" + }, + "require-dev": { + "guzzlehttp/guzzle": "^7.8.1", + "http-interop/http-factory-guzzle": "^1.2.0", + "php-cs-fixer/shim": "^3.59.3", + "phpstan/extension-installer": "^1.4.1", + "phpstan/phpstan": "^1.11.5", + "phpstan/phpstan-deprecation-rules": "^1.2.0", + "phpstan/phpstan-phpunit": "^1.4.0", + "phpstan/phpstan-strict-rules": "^1.6.0", + "phpunit/phpunit": "^9.5 || ^10.5" + }, + "suggest": { + "guzzlehttp/guzzle": "Use Guzzle ^7 as HTTP client", + "http-interop/http-factory-guzzle": "Factory for guzzlehttp/guzzle" + }, + "type": "library", + "autoload": { + "psr-4": { + "MeiliSearch\\": "src/", + "Meilisearch\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Clementine", + "email": "clementine@meilisearch.com" + } + ], + "description": "PHP wrapper for the Meilisearch API", + "keywords": [ + "api", + "client", + "instant", + "meilisearch", + "php", + "search" + ], + "support": { + "issues": "https://github.com/meilisearch/meilisearch-php/issues", + "source": "https://github.com/meilisearch/meilisearch-php/tree/v1.9.1" + }, + "time": "2024-07-25T15:54:07+00:00" + }, { "name": "monolog/monolog", "version": "3.6.0", @@ -5143,6 +5210,85 @@ }, "time": "2014-12-02T06:11:22+00:00" }, + { + "name": "php-http/discovery", + "version": "1.19.4", + "source": { + "type": "git", + "url": "https://github.com/php-http/discovery.git", + "reference": "0700efda8d7526335132360167315fdab3aeb599" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/discovery/zipball/0700efda8d7526335132360167315fdab3aeb599", + "reference": "0700efda8d7526335132360167315fdab3aeb599", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0|^2.0", + "php": "^7.1 || ^8.0" + }, + "conflict": { + "nyholm/psr7": "<1.0", + "zendframework/zend-diactoros": "*" + }, + "provide": { + "php-http/async-client-implementation": "*", + "php-http/client-implementation": "*", + "psr/http-client-implementation": "*", + "psr/http-factory-implementation": "*", + "psr/http-message-implementation": "*" + }, + "require-dev": { + "composer/composer": "^1.0.2|^2.0", + "graham-campbell/phpspec-skip-example-extension": "^5.0", + "php-http/httplug": "^1.0 || ^2.0", + "php-http/message-factory": "^1.0", + "phpspec/phpspec": "^5.1 || ^6.1 || ^7.3", + "sebastian/comparator": "^3.0.5 || ^4.0.8", + "symfony/phpunit-bridge": "^6.4.4 || ^7.0.1" + }, + "type": "composer-plugin", + "extra": { + "class": "Http\\Discovery\\Composer\\Plugin", + "plugin-optional": true + }, + "autoload": { + "psr-4": { + "Http\\Discovery\\": "src/" + }, + "exclude-from-classmap": [ + "src/Composer/Plugin.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations", + "homepage": "http://php-http.org", + "keywords": [ + "adapter", + "client", + "discovery", + "factory", + "http", + "message", + "psr17", + "psr7" + ], + "support": { + "issues": "https://github.com/php-http/discovery/issues", + "source": "https://github.com/php-http/discovery/tree/1.19.4" + }, + "time": "2024-03-29T13:00:05+00:00" + }, { "name": "phpoffice/phpspreadsheet", "version": "1.29.0", diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index c4c24801..e013a987 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -10,6 +10,7 @@ use App\Models\ServiceType; use App\Models\User; use Illuminate\Database\Seeder; +use Illuminate\Support\Facades\Artisan; class DatabaseSeeder extends Seeder { @@ -80,5 +81,7 @@ public function run(): void $issue->issueTypes()->attach($issueType->id, ['value' => ['test' => 'test']]); } } + + Artisan::call('scout:import', ['model' => Point::class]); } } diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..bb7597cf --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,47 @@ +services: + meilisearch: + image: 'getmeili/meilisearch:latest' + ports: + - '${FORWARD_MEILISEARCH_PORT:-7700}:7700' + environment: + MEILI_NO_ANALYTICS: '${MEILISEARCH_NO_ANALYTICS:-false}' + volumes: + - 'sail-meilisearch:/meili_data' + healthcheck: + test: + - CMD + - wget + - '--no-verbose' + - '--spider' + - 'http://127.0.0.1:7700/health' + retries: 3 + timeout: 5s + + nominatim: + image: mediagis/nominatim:4.4 + ports: + - '${FORWARD_NOMINATIM_PORT:-8080}:8080' + environment: + PBF_URL: 'https://download.geofabrik.de/europe/romania-latest.osm.pbf' + REPLICATION_URL: 'https://download.geofabrik.de/europe/romania-updates' + REPLICATION_UPDATE_INTERVAL: 86400 + REPLICATION_RECHECK_INTERVAL: 900 + UPDATE_MODE: catch-up + + POSTGRES_SHARED_BUFFERS: '2GB' + POSTGRES_MAINTAINENCE_WORK_MEM: '10GB' + POSTGRES_AUTOVACUUM_WORK_MEM: '2GB' + POSTGRES_WORK_MEM: '50MB' + POSTGRES_EFFECTIVE_CACHE_SIZE: '24GB' + POSTGRES_SYNCHRONOUS_COMMIT: 'off' + POSTGRES_MAX_WAL_SIZE: '1GB' + POSTGRES_CHECKPOINT_TIMEOUT: '10min' + POSTGRES_CHECKPOINT_COMPLETITION_TARGET: '0.9' + volumes: + - 'sail-nominatim:/var/lib/postgresql/14/main' + +volumes: + sail-meilisearch: + driver: local + sail-nominatim: + driver: local