Mache die Übernahme aus Shinkan auffindbar und zeige den Zustand der Anbindung
CI Feature / test (push) Successful in 2m25s
CI Feature / test (push) Successful in 2m25s
Die Übungsliste verweist mit „Aus Shinkan übernehmen“ auf die Übernahmeseite. Die Seite zeigt Adresse (nur Host) und Schlüssel (nur ob hinterlegt) und prüft die Verbindung, ohne etwas zu übernehmen. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
881703ba0e
commit
bc140a0e83
5 files changed
+117
-7
No files matched your search
@@ -37,6 +37,45 @@ public function configured(): bool
|
||||
return filled(config('services.shinkan.url')) && filled(config('services.shinkan.key'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Zustand der Anbindung ohne Werte: Adresse und Schlüssel stehen nur in der Umgebungsdatei des Servers.
|
||||
*
|
||||
* @return array{url: bool, key: bool, host: string|null}
|
||||
*/
|
||||
public function status(): array
|
||||
{
|
||||
$url = (string) config('services.shinkan.url');
|
||||
|
||||
return [
|
||||
'url' => filled($url),
|
||||
'key' => filled(config('services.shinkan.key')),
|
||||
'host' => filled($url) ? (parse_url($url, PHP_URL_HOST) ?: null) : null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Verbindung prüfen, ohne etwas zu speichern. Der Katalogabruf legt auf der Seite von Shinkan einen Stand an; hier
|
||||
* wird nur gezählt, was die Quelle für Lara & Felix bereitstellt.
|
||||
*
|
||||
* @return array{ok: bool, message: string}
|
||||
*/
|
||||
public function check(): array
|
||||
{
|
||||
if (! $this->configured()) {
|
||||
return ['ok' => false, 'message' => 'Die Anbindung ist nicht eingerichtet. Adresse und Schlüssel fehlen in der Umgebung des Servers.'];
|
||||
}
|
||||
|
||||
try {
|
||||
$catalog = $this->get('/catalog');
|
||||
} catch (Throwable $exception) {
|
||||
return ['ok' => false, 'message' => 'Die Verbindung ist fehlgeschlagen: '.$this->plain($exception)];
|
||||
}
|
||||
|
||||
$count = count((array) ($catalog['exercises'] ?? []));
|
||||
|
||||
return ['ok' => true, 'message' => 'Die Verbindung funktioniert. Die Quelle stellt '.$count.($count === 1 ? ' Übung' : ' Übungen').' bereit. Es wurde nichts übernommen.'];
|
||||
}
|
||||
|
||||
public function fetch(): ExerciseImportRun
|
||||
{
|
||||
$run = ExerciseImportRun::query()->create(['status' => 'laeuft', 'started_at' => now()]);
|
||||
|
||||
Reference in new issue
Block a user