| | |
| | | } |
| | | |
| | | use Exception; |
| | | use JVBase\registrar\Registrar; |
| | | |
| | | class CheckCustomTables |
| | | { |
| | |
| | | error_log("JVB: Error in notification section: " . $e->getMessage()); |
| | | } |
| | | |
| | | try { |
| | | // try { |
| | | // if (array_key_exists('dashboard', $this->JVB_SITE) && $this->JVB_SITE['dashboard']) { |
| | | $tables = array_merge($tables, $this->queueTables(), $this->errorLogTables()); |
| | | // $tables = array_merge($tables, $this->queueTables(), $this->errorLogTables()); |
| | | // } |
| | | } catch (Exception $e) { |
| | | error_log("JVB: Error in dashboard section: " . $e->getMessage()); |
| | | } |
| | | // } catch (Exception $e) { |
| | | // error_log("JVB: Error in dashboard section: " . $e->getMessage()); |
| | | // } |
| | | |
| | | try { |
| | | if (array_key_exists('referrals', $this->JVB_SITE) && $this->JVB_SITE['referrals']) { |
| | |
| | | * Table Definitions |
| | | *****************************************************/ |
| | | |
| | | protected function queueTables():array |
| | | { |
| | | |
| | | return [ |
| | | '_operation_queue' => "( |
| | | `id` VARCHAR(64) NOT NULL, |
| | | `type` varchar(50) NOT NULL, |
| | | `user_id` {$this->userIDType} NOT NULL, |
| | | |
| | | `request_data` JSON NOT NULL CHECK (JSON_VALID(request_data)), |
| | | |
| | | `total_items` int(11) NOT NULL DEFAULT 1, |
| | | `processed_items` int(11) DEFAULT 0, |
| | | `failed_items` JSON, |
| | | |
| | | `priority` ENUM('high', 'normal', 'low') DEFAULT 'normal', |
| | | `state` enum('pending', 'scheduled', 'processing', 'completed') DEFAULT 'pending', |
| | | `outcome` enum('pending', 'success', 'partial', 'merged', 'failed', 'failed_permanent') DEFAULT 'pending', |
| | | |
| | | `retries` int(11) DEFAULT 0, |
| | | `last_error_hash` CHAR(32) DEFAULT NULL, |
| | | `error_message` text, |
| | | |
| | | `scheduled_at` datetime DEFAULT NULL, |
| | | `started_at` datetime DEFAULT CURRENT_TIMESTAMP, |
| | | `completed_at` datetime DEFAULT NULL, |
| | | |
| | | `metadata` JSON DEFAULT NULL, |
| | | `result` JSON, |
| | | `dependencies` JSON, |
| | | `merged_into` VARCHAR(64) DEFAULT NULL, |
| | | |
| | | `user_dismissed` tinyint(1) DEFAULT 0, |
| | | `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP, |
| | | `updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP, |
| | | PRIMARY KEY (`id`), |
| | | KEY `idx_run_queue` (state, priority, scheduled_at), |
| | | KEY `idx_user_ops` (user_id, state), |
| | | KEY `idx_user_type_pending` (user_id, type, state), |
| | | KEY `idx_completed_at` (completed_at), |
| | | KEY `idx_processing_stuck` (`state`, `started_at`) |
| | | )", |
| | | |
| | | 'stats__operation_queue' => "( |
| | | `id` bigint unsigned AUTO_INCREMENT, |
| | | `date` date NOT NULL, |
| | | `type` varchar(50) NOT NULL, |
| | | |
| | | `total_operations` int NOT NULL DEFAULT 0, |
| | | `successful_operations` int NOT NULL DEFAULT 0, |
| | | `partial_operations` int NOT NULL DEFAULT 0, |
| | | `failed_operations` int NOT NULL DEFAULT 0, |
| | | `failed_permanent_operations` int NOT NULL DEFAULT 0, |
| | | |
| | | `total_items_processed` int NOT NULL DEFAULT 0, |
| | | |
| | | `average_duration` float DEFAULT NULL, |
| | | `max_duration` int DEFAULT NULL, |
| | | |
| | | `peak_queue_size` int NOT NULL DEFAULT 0, |
| | | |
| | | `peak_memory_usage` int DEFAULT NULL, |
| | | `peak_cpu_usage` float DEFAULT NULL, |
| | | |
| | | `created_at` timestamp DEFAULT CURRENT_TIMESTAMP, |
| | | PRIMARY KEY (`id`), |
| | | UNIQUE KEY (date, type), |
| | | KEY `date_idx` (date), |
| | | KEY `type_idx` (type) |
| | | )" |
| | | ]; |
| | | } |
| | | // protected function queueTables():array |
| | | // { |
| | | // |
| | | // return [ |
| | | // '_operation_queue' => "( |
| | | // `id` VARCHAR(64) NOT NULL, |
| | | // `type` varchar(50) NOT NULL, |
| | | // `user_id` {$this->userIDType} NOT NULL, |
| | | // |
| | | // `request_data` JSON NOT NULL CHECK (JSON_VALID(request_data)), |
| | | // |
| | | // `total_items` int(11) NOT NULL DEFAULT 1, |
| | | // `processed_items` int(11) DEFAULT 0, |
| | | // `failed_items` JSON, |
| | | // |
| | | // `priority` ENUM('high', 'normal', 'low') DEFAULT 'normal', |
| | | // `state` enum('pending', 'scheduled', 'processing', 'completed') DEFAULT 'pending', |
| | | // `outcome` enum('pending', 'success', 'partial', 'merged', 'failed', 'failed_permanent') DEFAULT 'pending', |
| | | // |
| | | // `retries` int(11) DEFAULT 0, |
| | | // `last_error_hash` CHAR(32) DEFAULT NULL, |
| | | // `error_message` text, |
| | | // |
| | | // `scheduled_at` datetime DEFAULT NULL, |
| | | // `started_at` datetime DEFAULT CURRENT_TIMESTAMP, |
| | | // `completed_at` datetime DEFAULT NULL, |
| | | // |
| | | // `metadata` JSON DEFAULT NULL, |
| | | // `result` JSON, |
| | | // `dependencies` JSON, |
| | | // `merged_into` VARCHAR(64) DEFAULT NULL, |
| | | // |
| | | // `user_dismissed` tinyint(1) DEFAULT 0, |
| | | // `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP, |
| | | // `updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP, |
| | | // PRIMARY KEY (`id`), |
| | | // KEY `idx_run_queue` (state, priority, scheduled_at), |
| | | // KEY `idx_user_ops` (user_id, state), |
| | | // KEY `idx_user_type_pending` (user_id, type, state), |
| | | // KEY `idx_completed_at` (completed_at), |
| | | // KEY `idx_processing_stuck` (`state`, `started_at`) |
| | | // )", |
| | | // |
| | | // 'stats__operation_queue' => "( |
| | | // `id` bigint unsigned AUTO_INCREMENT, |
| | | // `date` date NOT NULL, |
| | | // `type` varchar(50) NOT NULL, |
| | | // |
| | | // `total_operations` int NOT NULL DEFAULT 0, |
| | | // `successful_operations` int NOT NULL DEFAULT 0, |
| | | // `partial_operations` int NOT NULL DEFAULT 0, |
| | | // `failed_operations` int NOT NULL DEFAULT 0, |
| | | // `failed_permanent_operations` int NOT NULL DEFAULT 0, |
| | | // |
| | | // `total_items_processed` int NOT NULL DEFAULT 0, |
| | | // |
| | | // `average_duration` float DEFAULT NULL, |
| | | // `max_duration` int DEFAULT NULL, |
| | | // |
| | | // `peak_queue_size` int NOT NULL DEFAULT 0, |
| | | // |
| | | // `peak_memory_usage` int DEFAULT NULL, |
| | | // `peak_cpu_usage` float DEFAULT NULL, |
| | | // |
| | | // `created_at` timestamp DEFAULT CURRENT_TIMESTAMP, |
| | | // PRIMARY KEY (`id`), |
| | | // UNIQUE KEY (date, type), |
| | | // KEY `date_idx` (date), |
| | | // KEY `type_idx` (type) |
| | | // )" |
| | | // ]; |
| | | // } |
| | | |
| | | protected function errorLogTables():array |
| | | { |
| | |
| | | } |
| | | |
| | | try { |
| | | $contentFields = jvbGetFields($type); |
| | | $contentFields = Registrar::getFieldsFor($type); |
| | | |
| | | if (!$contentFields || empty($contentFields)) { |
| | | return; |