Optimize queries for statistics.

This commit is contained in:
James Cole
2025-09-26 06:05:37 +02:00
parent 08879d31ba
commit 4ec2fcdb8a
92 changed files with 6499 additions and 6514 deletions

View File

@@ -27,7 +27,6 @@ use Carbon\Carbon;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
use JsonException;
use function Safe\json_encode;
/**
@@ -78,20 +77,6 @@ class CacheProperties
return Cache::has($this->hash);
}
private function hash(): void
{
$content = '';
foreach ($this->properties as $property) {
try {
$content = sprintf('%s%s', $content, json_encode($property, JSON_THROW_ON_ERROR));
} catch (JsonException) {
// @ignoreException
$content = sprintf('%s%s', $content, hash('sha256', (string) Carbon::now()->getTimestamp()));
}
}
$this->hash = substr(hash('sha256', $content), 0, 16);
}
/**
* @param mixed $data
*/
@@ -99,4 +84,18 @@ class CacheProperties
{
Cache::forever($this->hash, $data);
}
private function hash(): void
{
$content = '';
foreach ($this->properties as $property) {
try {
$content = sprintf('%s%s', $content, json_encode($property, JSON_THROW_ON_ERROR));
} catch (JsonException) {
// @ignoreException
$content = sprintf('%s%s', $content, hash('sha256', (string)Carbon::now()->getTimestamp()));
}
}
$this->hash = substr(hash('sha256', $content), 0, 16);
}
}