Frag das Portal durchsucht alles, neue Demo-Inhalte (0.66.0)
All checks were successful
CI / PHP 8.3 / mariadb:10.6 (pull_request) Has been skipped
CI / PHP 8.4 / mariadb:10.6 (pull_request) Has been skipped
CI / PHP 8.3 / mariadb:11.4 (pull_request) Has been skipped
CI / PHP 8.4 / mariadb:11.4 (pull_request) Has been skipped
CI / PHP 8.3 / mysql:8.0 (pull_request) Has been skipped
CI / PHP 8.4 / mysql:8.0 (pull_request) Has been skipped
CI / PHP 8.3 / mysql:8.4 (pull_request) Has been skipped
CI / PHP 8.4 / mysql:8.4 (pull_request) Has been skipped
CI / Browser-Tests (pull_request) Successful in 8m33s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 9m8s
CI / PHP 8.3 / mysql:8.4-1 (pull_request) Successful in 17m55s
CI / Build-Artefakte aktuell (pull_request) Successful in 9m50s
All checks were successful
CI / PHP 8.3 / mariadb:10.6 (pull_request) Has been skipped
CI / PHP 8.4 / mariadb:10.6 (pull_request) Has been skipped
CI / PHP 8.3 / mariadb:11.4 (pull_request) Has been skipped
CI / PHP 8.4 / mariadb:11.4 (pull_request) Has been skipped
CI / PHP 8.3 / mysql:8.0 (pull_request) Has been skipped
CI / PHP 8.4 / mysql:8.0 (pull_request) Has been skipped
CI / PHP 8.3 / mysql:8.4 (pull_request) Has been skipped
CI / PHP 8.4 / mysql:8.4 (pull_request) Has been skipped
CI / Browser-Tests (pull_request) Successful in 8m33s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 9m8s
CI / PHP 8.3 / mysql:8.4-1 (pull_request) Successful in 17m55s
CI / Build-Artefakte aktuell (pull_request) Successful in 9m50s
- Wissensquellen: Termine, Downloads, Formulare, Stellen, Ideen, Umfragen, Personen, eigene IT-Tickets/Geräte (OpenNIT, je Anfrage zwischengespeichert) - Ranking mit IDF, Abfrage je Begriff, Abkürzungen als ganze Wörter, LIKE unabhängig von Groß-/Kleinschreibung (JSON-Spalten), Datum im Prompt - Demo-Inhalte für einen Träger der Eingliederungshilfe (DemoData), mehrseitige PDFs, vorhandene Inhalte je Bereich entfernen Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1656cd8090
commit
3addc09c38
165 changed files with 2258 additions and 814 deletions
91
plugins-core/it-service/src/ItKnowledge.php
Normal file
91
plugins-core/it-service/src/ItKnowledge.php
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\ItService;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Models\User;
|
||||
use Inhaus\Plugins\ItService\OpenNit\Settings;
|
||||
|
||||
/**
|
||||
* Wissensquelle für „Frag das Portal“: die eigenen IT-Tickets und Geräte der fragenden
|
||||
* Person aus OpenNIT („Wie ist der Stand meines Druckertickets?“, „Welchen Laptop habe ich?“)
|
||||
* sowie der Hinweistext des IT-Service. Nie Daten anderer Personen.
|
||||
*/
|
||||
class ItKnowledge
|
||||
{
|
||||
/** Volltext (Beschreibung und Antworten) nur für so viele Tickets – je Ticket ein Aufruf bei OpenNIT */
|
||||
private const DETAILS = 2;
|
||||
|
||||
/** @var array<string, mixed> Antworten von OpenNIT für diese Anfrage (je Frage wird die Quelle mehrfach gefragt) */
|
||||
private array $memo = [];
|
||||
|
||||
public function __construct(private readonly ItService $it, private readonly Settings $settings) {}
|
||||
|
||||
private function remember(string $key, \Closure $load): mixed
|
||||
{
|
||||
return array_key_exists($key, $this->memo) ? $this->memo[$key] : ($this->memo[$key] = $load());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $terms
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function __invoke(User $user, array $terms, int $limit): array
|
||||
{
|
||||
if (! $this->it->configured()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$matches = fn (string $text) => collect($terms)->contains(fn (string $term) => Knowledge::occurrences(mb_strtolower($text), $term) > 0);
|
||||
// „mein Ticket“, „Störung“: dann auch offene Tickets ohne passenden Betreff
|
||||
$aboutTickets = collect($terms)->contains(fn (string $term) => in_array($term, ['ticket', 'stör', 'anfrag', 'meld', 'support'], true));
|
||||
$results = [];
|
||||
|
||||
$intro = Knowledge::plain((string) $this->settings->intro());
|
||||
|
||||
if ($intro !== '' && $matches('IT-Service IT Support Ticket '.$intro)) {
|
||||
$results[] = ['title' => 'IT-Service', 'url' => route('it-service.index'), 'text' => $intro, 'meta' => 'Hinweise des IT-Teams'];
|
||||
}
|
||||
|
||||
$tickets = array_values(array_filter($this->remember('tickets.'.$user->id, fn () => $this->it->tickets($user)), fn (array $t) => $matches($t['subject']) || ($aboutTickets && $t['open'])));
|
||||
|
||||
foreach (array_slice($tickets, 0, $limit) as $i => $ticket) {
|
||||
$text = 'Ihr IT-Ticket'.($ticket['number'] ? ' Nr. '.$ticket['number'] : '').': „'.$ticket['subject'].'“. Stand: '.$ticket['status_label'].'.'
|
||||
.($ticket['created_at'] ? ' Erstellt am '.$ticket['created_at'].'.' : '').($ticket['updated_at'] ? ' Zuletzt bearbeitet am '.$ticket['updated_at'].'.' : '');
|
||||
|
||||
if ($i < self::DETAILS) {
|
||||
$detail = $this->remember('ticket.'.$user->id.'.'.$ticket['id'], fn () => $this->it->ticket($user, $ticket['id']));
|
||||
$text .= "\n".Knowledge::plain((string) ($detail['description'] ?? ''));
|
||||
|
||||
foreach (array_slice($detail['replies'] ?? [], -3) as $reply) {
|
||||
$text .= "\n".($reply['from_staff'] ? 'Antwort des IT-Teams' : 'Ihre Nachricht').': '.Knowledge::plain((string) $reply['message']);
|
||||
}
|
||||
}
|
||||
|
||||
$results[] = ['title' => 'Mein Ticket: '.$ticket['subject'], 'url' => route('it-service.tickets.show', $ticket['id']), 'text' => $text, 'meta' => $ticket['status_label']];
|
||||
}
|
||||
|
||||
foreach ($this->remember('assets.'.$user->id, fn () => $this->it->assets($user)) as $asset) {
|
||||
$description = collect([$asset['type'], $asset['manufacturer'], $asset['model']])->filter()->implode(' ');
|
||||
|
||||
if (! $matches($asset['name'].' '.$description.' gerät geräte laptop computer')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$results[] = [
|
||||
'title' => 'Mein Gerät: '.$asset['name'],
|
||||
'url' => route('it-service.index'),
|
||||
'text' => implode(' ', array_filter([
|
||||
'Ihnen zugeordnetes Gerät: '.$asset['name'].($description ? ' ('.$description.')' : '').'.',
|
||||
$asset['inventory'] ? 'Inventarnummer '.$asset['inventory'].'.' : null,
|
||||
$asset['serial'] ? 'Seriennummer '.$asset['serial'].'.' : null,
|
||||
$asset['location'] ? 'Standort '.$asset['location'].'.' : null,
|
||||
$asset['warranty_end'] ? 'Garantie bis '.$asset['warranty_end'].'.' : null,
|
||||
])),
|
||||
'meta' => 'Meine IT',
|
||||
];
|
||||
}
|
||||
|
||||
return array_slice($results, 0, $limit);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Inhaus\Plugins\ItService;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Dashboard\Widgets;
|
||||
use App\Models\User;
|
||||
use App\Plugins\Hooks;
|
||||
|
|
@ -18,6 +19,9 @@ class ItServicePlugin extends Plugin
|
|||
{
|
||||
public function register(): void
|
||||
{
|
||||
// Eine Instanz je Anfrage: merkt sich die Antworten von OpenNIT
|
||||
$this->app->scoped(ItKnowledge::class);
|
||||
$this->app->make(Knowledge::class)->add('it-service', 'Meine IT', fn (...$args) => app(ItKnowledge::class)(...$args));
|
||||
$this->app->singleton(Settings::class);
|
||||
$this->app->make(Abilities::class)->define('it-service.manage', 'IT-Service (OpenNIT) einrichten', 'IT-Service');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue