-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to cleanup old runs from database.
- Loading branch information
Ritvars Zvejnieks
committed
May 30, 2023
1 parent
b83a4ef
commit ed59ded
Showing
4 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
namespace Ritvarsz\LaravelXhgui\Actions; | ||
|
||
use Illuminate\Support\Facades\Date; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
class ExpireRuns | ||
{ | ||
public function handle() { | ||
$config = config('xhgui.database'); | ||
$connection = $config['connection'] ?? null; | ||
$tableResults = $config['table_results'] ?? null; | ||
$expireAfterDays = $config['expire_after_days'] ?? 0; | ||
|
||
if ($expireAfterDays === 0 || $connection === null) { | ||
return; | ||
} | ||
|
||
$expireDate = Date::today()->subDays($expireAfterDays)->toDateTimeString(); | ||
|
||
DB::connection($connection)->table($tableResults)->where('request_date', '<', $expireDate)->delete(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters