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
67
plugins-core/events/src/EventKnowledge.php
Normal file
67
plugins-core/events/src/EventKnowledge.php
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\Events;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Models\User;
|
||||
use Inhaus\Plugins\Events\Models\Event;
|
||||
|
||||
/** Wissensquelle für „Frag das Portal“: kommende und kürzlich vergangene Termine, die die Person sieht */
|
||||
class EventKnowledge
|
||||
{
|
||||
public function __construct(private readonly Registrations $registrations) {}
|
||||
|
||||
/**
|
||||
* @param list<string> $terms
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function __invoke(User $user, array $terms, int $limit): array
|
||||
{
|
||||
$query = Event::query()->visibleTo($user)->where('is_published', true)
|
||||
// Alte Termine verwirren nur („Wann ist das Sommerfest?“ meint das nächste)
|
||||
->whereRaw('COALESCE(ends_at, starts_at) >= ?', [now()->subDays(60)]);
|
||||
Knowledge::whereAny($query, ['title', 'description', 'location'], $terms);
|
||||
|
||||
return $query->orderByRaw('COALESCE(ends_at, starts_at) < ?', [now()])->orderBy('starts_at')->limit($limit)->get()
|
||||
->map(fn (Event $event) => [
|
||||
'title' => $event->title,
|
||||
'url' => '/termine/'.$event->id,
|
||||
'text' => $this->facts($event)."\n".Knowledge::plain($event->description_html ?? $event->description),
|
||||
'meta' => $this->when($event),
|
||||
])->all();
|
||||
}
|
||||
|
||||
private function when(Event $event): string
|
||||
{
|
||||
$start = $event->starts_at->locale('de');
|
||||
|
||||
if ($event->all_day) {
|
||||
return $start->translatedFormat('l, j. F Y').($event->ends_at && ! $event->ends_at->isSameDay($start) ? ' bis '.$event->ends_at->locale('de')->translatedFormat('l, j. F Y') : '').' (ganztägig)';
|
||||
}
|
||||
|
||||
return $start->translatedFormat('l, j. F Y, H:i').' Uhr'.($event->ends_at ? ' bis '.($event->ends_at->isSameDay($start) ? $event->ends_at->format('H:i') : $event->ends_at->locale('de')->translatedFormat('j. F Y, H:i')).' Uhr' : '');
|
||||
}
|
||||
|
||||
private function facts(Event $event): string
|
||||
{
|
||||
$lines = ['Termin: '.$this->when($event).'.'];
|
||||
|
||||
if ($event->location) {
|
||||
$lines[] = 'Ort: '.$event->location.'.';
|
||||
}
|
||||
|
||||
if ($event->online_url) {
|
||||
$lines[] = 'Auch online möglich.';
|
||||
}
|
||||
|
||||
if (($event->ends_at ?? $event->starts_at)->isPast()) {
|
||||
$lines[] = 'Dieser Termin ist bereits vorbei.';
|
||||
} elseif ($event->registration_enabled) {
|
||||
$free = $event->capacity === null ? null : max(0, $event->capacity - $this->registrations->confirmedCount($event));
|
||||
$lines[] = 'Anmeldung im Portal'.($free === null ? '' : ($free > 0 ? " – noch {$free} von {$event->capacity} Plätzen frei" : ' – ausgebucht'.($event->waitlist ? ', Warteliste möglich' : ''))).
|
||||
($event->registration_deadline ? ', Anmeldeschluss '.$event->registration_deadline->locale('de')->translatedFormat('j. F Y, H:i').' Uhr' : '').'.';
|
||||
}
|
||||
|
||||
return implode(' ', $lines);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Inhaus\Plugins\Events;
|
||||
|
||||
use App\Ask\Knowledge;
|
||||
use App\Dashboard\Widgets;
|
||||
use App\Digest\Digest;
|
||||
use App\Editorial\Editorial;
|
||||
|
|
@ -26,6 +27,7 @@ class EventsPlugin extends Plugin
|
|||
{
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->make(Knowledge::class)->add('events', 'Termine', fn (...$args) => app(EventKnowledge::class)(...$args));
|
||||
// Wochenüberblick: Termine der nächsten zwei Wochen
|
||||
$this->app->make(Digest::class)->add('events', 'Termine', 20, fn (User $user) => Event::query()
|
||||
->upcoming()->visibleTo($user)->where('starts_at', '<=', now()->addDays(14))->limit(8)->get()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue