forked from deck9/input
-
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 privacy option to automatically delete submissions older than x d…
…ays (deck9#104) * switch to asdf * remove old unused test * add auto delete submissions command * add mariadb to github action * fix ci command * update phpunit config * fix nginx image * add scheduler to prod dockerfile * migrate phpunit config * update base nginx docker image * add settings for auto delete * center delete button in submissions view
- Loading branch information
1 parent
d8e3b6e
commit df9c4c5
Showing
18 changed files
with
383 additions
and
161 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nodejs 18.17.1 |
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,53 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\Form; | ||
use Illuminate\Console\Command; | ||
|
||
class AutoDeleteSubmissions extends Command | ||
{ | ||
/** | ||
* The number of submissions cleaned. | ||
* @var int | ||
*/ | ||
protected $cleaned = 0; | ||
|
||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'input:auto-delete-submissions'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'This command will delete old submissions if auto delete is enabled for the form using the retention days specified on the form.'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle(): void | ||
{ | ||
Form::has('formSessions')->lazyById()->each(function (Form $form) { | ||
if ($form->is_auto_delete_enabled === false) { | ||
return; | ||
} | ||
|
||
$form->formSessions()->lazyById()->each(function ($session) use ($form) { | ||
$retentionDays = $form->data_retention_days; | ||
|
||
if ($session->updated_at->diffInDays(now()) > $retentionDays) { | ||
$session->delete(); | ||
$this->cleaned++; | ||
} | ||
|
||
}); | ||
}); | ||
|
||
$this->info("Cleaned {$this->cleaned} submissions."); | ||
} | ||
} |
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
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
17 changes: 17 additions & 0 deletions
17
database/migrations/2023_10_26_123811_add_has_autodelete_attribute_to_forms.php
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,17 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class () extends Migration { | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::table('forms', function (Blueprint $table) { | ||
$table->boolean('is_auto_delete_enabled')->default(false)->after('data_retention_days'); | ||
}); | ||
} | ||
}; |
Oops, something went wrong.