Skip to content
Snippets Groups Projects
Verified Commit 85da8689 authored by Sofiane Lasri's avatar Sofiane Lasri
Browse files

feat: optimize IP address processing and update scheduled command frequency

- Simplified the HTTP request in `IpAddressMetadataResolverService.php` by removing unnecessary array wrapping.
- Updated the join in `HomeController.php` to include `ip_address_metadata` for more accurate data retrieval.
- Changed the frequency of the `process:ip-adresses` command in `console.php` to run every five minutes instead of hourly.
parent 6b1140b7
No related branches found
No related tags found
1 merge request!60feat: add IpAdressMetadata model and factory with migration
Pipeline #1057 passed
......@@ -25,13 +25,14 @@ public function index(): View
$visits = LoggedRequest::selectRaw('
logged_requests.url_id,
logged_requests.ip_address_id,
logged_requests.country_code,
ip_address_metadata.country_code,
logged_requests.created_at,
urls.url
')
->distinct('logged_requests.url_id', 'logged_requests.ip_address_id')
->join('urls', 'logged_requests.url_id', '=', 'urls.id')
->join('user_agent_metadata', 'logged_requests.user_agent_id', '=', 'user_agent_metadata.user_agent_id')
->join('ip_address_metadata', 'logged_requests.ip_address_id', '=', 'ip_address_metadata.ip_address_id')
->whereLike('urls.url', config('app.url').'%')
->whereNotIn('urls.url', $individualExcludedRoutes)
->where('user_agent_metadata.is_bot', false)
......
......@@ -41,9 +41,7 @@ public static function resolve(Collection $ipAddresses): array
$ipAddresses = $ipAddresses->take($maxIpPerCall);
}
$response = Http::post($url, [
'ip_addresses' => $ipAddresses->pluck('ip')->toArray(),
]);
$response = Http::post($url, $ipAddresses->pluck('ip')->toArray());
if ($response->failed()) {
$returnedError = [
......
......@@ -9,7 +9,7 @@
Schedule::command('save:requests')->everyMinute()->sentryMonitor();
Schedule::command('process:user-agents')->hourly()->sentryMonitor();
Schedule::command('process:ip-adresses')->hourly()->sentryMonitor();
Schedule::command('process:ip-adresses')->everyFiveMinutes()->sentryMonitor();
Schedule::command('flush:unused-uploaded-pictures')->daily()->sentryMonitor();
Schedule::command('backup:clean --disable-notifications')->daily()->at('01:00');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment