adasd
This commit is contained in:
@@ -134,24 +134,19 @@ $mm->registerFunction($moduleName, 'save_runtime_settings', static function (arr
|
||||
|
||||
$repository->saveSettings($projectKey, $settings);
|
||||
|
||||
return module_fn($moduleName, 'runtime_settings');
|
||||
return module_fn('mining-checker', 'runtime_settings');
|
||||
});
|
||||
|
||||
$mm->registerFunction($moduleName, 'setup_actions', static function (): array {
|
||||
return [
|
||||
[
|
||||
'name' => 'connection_test',
|
||||
'label' => 'DB-Verbindung testen',
|
||||
'help' => 'Prueft, ob die Projekt-Datenbank fuer den Mining-Checker erreichbar ist.',
|
||||
],
|
||||
[
|
||||
'name' => 'initialize_schema',
|
||||
'label' => 'Schema initialisieren',
|
||||
'label' => 'Tabellen importieren',
|
||||
'help' => 'Legt die Mining-Checker Tabellen an, wenn sie noch nicht vorhanden sind.',
|
||||
],
|
||||
[
|
||||
'name' => 'upgrade_schema',
|
||||
'label' => 'Tabellen auf neuesten Stand bringen',
|
||||
'label' => 'Tabellen updaten',
|
||||
'help' => 'Fuehrt fehlende Tabellen- und Spalten-Upgrades fuer den Mining-Checker aus.',
|
||||
],
|
||||
[
|
||||
@@ -162,6 +157,29 @@ $mm->registerFunction($moduleName, 'setup_actions', static function (): array {
|
||||
];
|
||||
});
|
||||
|
||||
$mm->registerFunction($moduleName, 'setup_status', static function (): array {
|
||||
$moduleBasePath = __DIR__;
|
||||
$config = ModuleConfig::load($moduleBasePath);
|
||||
$pdo = ConnectionFactory::make($config);
|
||||
$schema = new SchemaManager($pdo, $config->tablePrefix(), $moduleBasePath);
|
||||
$status = $schema->schemaStatus();
|
||||
|
||||
return [
|
||||
'title' => 'Tabellenstatus',
|
||||
'type' => !empty($status['all_present']) && empty($status['pending_upgrades']) ? 'success' : 'hint',
|
||||
'text' => !empty($status['all_present'])
|
||||
? (empty($status['pending_upgrades'])
|
||||
? 'Alle Mining-Checker Tabellen sind vorhanden.'
|
||||
: 'Alle Grundtabellen sind vorhanden, aber es gibt noch ausstehende Upgrades.')
|
||||
: 'Das Mining-Checker Schema ist noch unvollstaendig.',
|
||||
'stats' => [
|
||||
['label' => 'Vorhandene Tabellen', 'value' => (string) ((int) ($status['present_count'] ?? 0) . '/' . count((array) ($status['required_tables'] ?? [])))],
|
||||
['label' => 'Fehlende Tabellen', 'value' => !empty($status['missing_tables']) ? implode(', ', (array) $status['missing_tables']) : 'keine'],
|
||||
['label' => 'Ausstehende Upgrades', 'value' => !empty($status['pending_upgrades']) ? implode(', ', (array) $status['pending_upgrades']) : 'keine'],
|
||||
],
|
||||
];
|
||||
});
|
||||
|
||||
$mm->registerFunction($moduleName, 'run_setup_action', static function (string $action): array {
|
||||
$moduleBasePath = __DIR__;
|
||||
$config = ModuleConfig::load($moduleBasePath);
|
||||
@@ -174,23 +192,6 @@ $mm->registerFunction($moduleName, 'run_setup_action', static function (string $
|
||||
$repository = new MiningRepository($pdo, $config->tablePrefix(), null, $ownerSub);
|
||||
|
||||
return match ($action) {
|
||||
'connection_test' => (static function () use ($pdo, $config): array {
|
||||
$driver = strtolower((string) $pdo->getAttribute(PDO::ATTR_DRIVER_NAME));
|
||||
$database = 'n/a';
|
||||
try {
|
||||
$database = match ($driver) {
|
||||
'pgsql' => (string) ($pdo->query('SELECT current_database()')->fetchColumn() ?: 'n/a'),
|
||||
'mysql' => (string) ($pdo->query('SELECT DATABASE()')->fetchColumn() ?: 'n/a'),
|
||||
default => 'n/a',
|
||||
};
|
||||
} catch (\Throwable) {
|
||||
$database = 'n/a';
|
||||
}
|
||||
|
||||
return [
|
||||
'message' => 'DB-Verbindung erfolgreich. Driver: ' . $driver . ', Datenbank: ' . $database . ', Tabellenpraefix: ' . $config->tablePrefix() . '.',
|
||||
];
|
||||
})(),
|
||||
'initialize_schema' => (static function () use ($schema): array {
|
||||
$result = $schema->initializeSchema(false);
|
||||
$after = is_array($result['after'] ?? null) ? $result['after'] : [];
|
||||
|
||||
Reference in New Issue
Block a user