Fix code quality violations and enhance ROUTE-EXISTS-01 rule
Implement JQHTML function cache ID system and fix bundle compilation Implement underscore prefix for system tables Fix JS syntax linter to support decorators and grant exception to Task system SPA: Update planning docs and wishlists with remaining features SPA: Document Navigation API abandonment and future enhancements Implement SPA browser integration with History API (Phase 1) Convert contacts view page to SPA action Convert clients pages to SPA actions and document conversion procedure SPA: Merge GET parameters and update documentation Implement SPA route URL generation in JavaScript and PHP Implement SPA bootstrap controller architecture Add SPA routing manual page (rsx:man spa) Add SPA routing documentation to CLAUDE.md Phase 4 Complete: Client-side SPA routing implementation Update get_routes() consumers for unified route structure Complete SPA Phase 3: PHP-side route type detection and is_spa flag Restore unified routes structure and Manifest_Query class Refactor route indexing and add SPA infrastructure Phase 3 Complete: SPA route registration in manifest Implement SPA Phase 2: Extract router code and test decorators Rename Jqhtml_Component to Component and complete SPA foundation setup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
64
app/RSpade/Core/Session/Session_Cleanup_Service.php
Executable file
64
app/RSpade/Core/Session/Session_Cleanup_Service.php
Executable file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\RSpade\Core\Session;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\RSpade\Core\Service\Rsx_Service_Abstract;
|
||||
use App\RSpade\Core\Task\Task_Instance;
|
||||
|
||||
/**
|
||||
* Session_Cleanup_Service
|
||||
*
|
||||
* Scheduled cleanup of expired and abandoned sessions.
|
||||
*
|
||||
* Cleanup Rules:
|
||||
* - Logged-in sessions (login_user_id set): Delete if older than 365 days
|
||||
* - Anonymous sessions (login_user_id null): Delete if older than 14 days
|
||||
*
|
||||
* Runs daily at 3 AM via scheduled task.
|
||||
*/
|
||||
class Session_Cleanup_Service extends Rsx_Service_Abstract
|
||||
{
|
||||
/**
|
||||
* Clean up expired and abandoned sessions
|
||||
*
|
||||
* Deletes sessions based on age and login status:
|
||||
* - Logged-in sessions: 365 days retention
|
||||
* - Anonymous sessions: 14 days retention
|
||||
*
|
||||
* @param Task_Instance $task Task instance for logging
|
||||
* @param array $params Task parameters
|
||||
* @return array Cleanup statistics
|
||||
*/
|
||||
#[Task('Clean up expired and abandoned sessions (runs daily at 3 AM)')]
|
||||
#[Schedule('0 3 * * *')]
|
||||
public static function cleanup_sessions(Task_Instance $task, array $params = [])
|
||||
{
|
||||
// Logged-in sessions: older than 365 days
|
||||
$logged_in_cutoff = now()->subDays(365);
|
||||
$logged_in_deleted = DB::table('sessions')
|
||||
->whereNotNull('login_user_id')
|
||||
->where('last_active', '<', $logged_in_cutoff)
|
||||
->delete();
|
||||
|
||||
$task->info("Deleted {$logged_in_deleted} logged-in sessions older than 365 days");
|
||||
|
||||
// Anonymous sessions: older than 14 days
|
||||
$anonymous_cutoff = now()->subDays(14);
|
||||
$anonymous_deleted = DB::table('sessions')
|
||||
->whereNull('login_user_id')
|
||||
->where('last_active', '<', $anonymous_cutoff)
|
||||
->delete();
|
||||
|
||||
$task->info("Deleted {$anonymous_deleted} anonymous sessions older than 14 days");
|
||||
|
||||
$total_deleted = $logged_in_deleted + $anonymous_deleted;
|
||||
$task->info("Total sessions deleted: {$total_deleted}");
|
||||
|
||||
return [
|
||||
'logged_in_deleted' => $logged_in_deleted,
|
||||
'anonymous_deleted' => $anonymous_deleted,
|
||||
'total_deleted' => $total_deleted,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user