Revert "New optimization attempt."

This reverts commit 0f1cd79625.
This commit is contained in:
sergiotarxz 2023-05-02 21:50:50 +02:00
parent 0f1cd79625
commit c50df91a5a
1 changed files with 13 additions and 10 deletions

View File

@ -104,17 +104,20 @@ EOF
my $dbh = BurguillosInfo::DB->connect($app);
my $data = $dbh->selectall_arrayref(<<"EOF", {Slice => {}});
SELECT paths.path,
COUNT(DISTINCT(requests_day.remote_address, requests_day.user_agent)) as unique_ips_last_24_hours,
COUNT(DISTINCT(requests_week.remote_address, requests_week.user_agent)) as unique_ips_last_week,
COUNT(DISTINCT(requests_month.remote_address, requests_month.user_agent)) as unique_ips_last_month
(
$SELECT_GLOBAL
where requests.path = paths.path and date > NOW() - interval '1 day'
) as unique_ips_last_24_hours,
(
$SELECT_GLOBAL
where requests.path = paths.path and date > NOW() - interval '1 week'
) as unique_ips_last_week,
(
$SELECT_GLOBAL
where requests.path = paths.path and date > NOW() - interval '1 month'
) as unique_ips_last_month
FROM paths
LEFT join requests requests_day ON paths.path=requests_day.path
LEFT join requests requests_month ON paths.path=requests_month.path
LEFT join requests requests_week ON paths.path=requests_week.path
WHERE paths.last_seen > NOW() - INTERVAL '1 month' AND
requests_day.date > NOW() - interval '1 day' AND
requests_week.date > NOW() - interval '1 week'
GROUP BY paths.path
WHERE paths.last_seen > NOW() - INTERVAL '1 month';
EOF
return $data;
}