mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Filter in prepare
This commit is contained in:
@@ -8,7 +8,7 @@ use Utopia\Queue\Publisher;
|
||||
class StatsUsage extends Event
|
||||
{
|
||||
protected array $metrics = [];
|
||||
protected array $reduce = [];
|
||||
protected array $reduce = [];
|
||||
protected array $disabled = [];
|
||||
|
||||
public function __construct(protected Publisher $publisher)
|
||||
@@ -42,10 +42,6 @@ class StatsUsage extends Event
|
||||
*/
|
||||
public function addMetric(string $key, int $value): self
|
||||
{
|
||||
if ($this->disabled[$key]) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->metrics[] = [
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
@@ -62,7 +58,7 @@ class StatsUsage extends Event
|
||||
*/
|
||||
public function disableMetric(string $key): self
|
||||
{
|
||||
$this->disabled[$key] = true;
|
||||
$this->disabled[] = $key;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -76,8 +72,15 @@ class StatsUsage extends Event
|
||||
{
|
||||
return [
|
||||
'project' => $this->getProject(),
|
||||
'reduce' => $this->reduce,
|
||||
'metrics' => $this->metrics,
|
||||
'reduce' => $this->reduce,
|
||||
'metrics' => \array_filter($this->metrics, function ($metric) {
|
||||
foreach (array_keys($this->disabled) as $disabledMetric) {
|
||||
if (\str_ends_with($metric['key'], $disabledMetric)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user