diff --git a/src/Storage/DatabaseStorage.php b/src/Storage/DatabaseStorage.php index d3d15480..17e489f2 100644 --- a/src/Storage/DatabaseStorage.php +++ b/src/Storage/DatabaseStorage.php @@ -124,15 +124,16 @@ public function store(Collection $items): void public function trim(): void { $now = CarbonImmutable::now(); + $keep = $this->config->get('pulse.ingest.trim.keep'); $this->connection() ->table('pulse_values') - ->where('timestamp', '<=', $now->subWeek()->getTimestamp()) + ->where('timestamp', '<=', $now->subMilliseconds((int) CarbonInterval::fromString($keep)->totalMilliseconds)->getTimestamp()) ->delete(); $this->connection() ->table('pulse_entries') - ->where('timestamp', '<=', $now->subWeek()->getTimestamp()) + ->where('timestamp', '<=', $now->subMilliseconds((int) CarbonInterval::fromString($keep)->totalMilliseconds)->getTimestamp()) ->delete(); $this->connection()