mirror of
https://github.com/appwrite/appwrite
synced 2026-05-21 07:58:55 +00:00
Filter in prepare
This commit is contained in:
parent
6dbc8c5464
commit
3fe1147194
1 changed files with 11 additions and 8 deletions
|
|
@ -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;
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue