Watcher Models
Watchers sind benutzerdefinierte Sammlungen beobachteter Social-Media-Profile. Ein Workspace enthält mehrere Watchers, jeder Watcher verknüpft über WatcherSource mit einem oder mehreren SocialProfile-Einträgen. Der Import-Prozess wird über WatcherImportRun, WatcherImportItem und WatcherImportFailure protokolliert.
Watcher
Benannte Sammlung von beobachteten Profilen innerhalb eines Workspace.
Tabelle: watchers
| Feld | Typ | Nullable | Beschreibung |
|---|---|---|---|
id | bigint | PK | Primary Key |
workspace_id | bigint (FK) | nein | Zugehöriger Workspace |
created_by | bigint (FK) | nein | Erstellender User |
name | string | nein | Anzeigename |
is_name_custom | boolean | nein | Vom User manuell vergeben (vs. auto-generiert) |
created_at | datetime | nein | Erstellt am |
updated_at | datetime | nein | Aktualisiert am |
Relations:
| Methode | Typ | Related Model | FK | Beschreibung |
|---|---|---|---|---|
workspace() | belongsTo | Workspace | workspace_id | Übergeordneter Workspace |
creator() | belongsTo | User | created_by | Erstellender User |
sources() | hasMany | WatcherSource | watcher_id | Alle verknüpften Profile |
primarySource() | hasOne | WatcherSource | watcher_id | Erste Quelle (oldestOfMany) |
Casts: is_name_custom → boolean
Location: app/Models/Watcher.php
WatcherSource
Polymorphe Verknüpfung zwischen Watcher und SocialProfile. Speichert die Original-URL des Imports und die Plattform als Enum.
Tabelle: watcher_sources
| Feld | Typ | Nullable | Beschreibung |
|---|---|---|---|
id | bigint | PK | Primary Key |
watcher_id | bigint (FK) | nein | Zugehöriger Watcher |
social_profile_id | bigint (FK) | nein | Verknüpftes Profil |
platform | string (Enum) | nein | Plattform (youtube, instagram) |
input_url | string | ja | Ursprünglich eingegebene URL |
created_at | datetime | nein | Erstellt am |
updated_at | datetime | nein | Aktualisiert am |
Relations:
| Methode | Typ | Related Model | FK | Beschreibung |
|---|---|---|---|---|
watcher() | belongsTo | Watcher | watcher_id | Übergeordneter Watcher |
profile() | belongsTo | SocialProfile | social_profile_id | Verknüpftes Profil |
Casts: platform → SocialPlatform (Enum)
Unique-Constraints:
-- Ein Profil kann pro Watcher nur einmal verknüpft sein
UNIQUE (watcher_id, social_profile_id)
Location: app/Models/WatcherSource.php
WatcherImportRun
Protokolliert einen Bulk-Import-Durchlauf. Enthält Zähler für den Fortschritt und Status-Tracking für die UI-Anzeige via WebSocket.
Tabelle: watcher_import_runs
| Feld | Typ | Nullable | Beschreibung |
|---|---|---|---|
id | bigint | PK | Primary Key |
workspace_id | bigint (FK) | nein | Zugehöriger Workspace |
created_by | bigint (FK) | nein | Auslösender User |
platform | string | nein | Zielplattform |
status | string | nein | pending, processing, paused, completed, failed |
total_count | integer | nein | Gesamtanzahl URLs |
processed_count | integer | nein | Bisher verarbeitete |
added_count | integer | nein | Neu hinzugefügte Profile |
duplicates_in_input_count | integer | nein | Duplikate im Input |
already_in_workspace_count | integer | nein | Bereits im Workspace vorhanden |
global_reused_count | integer | nein | Global vorhandene Profile wiederverwendet |
failed_count | integer | nein | Fehlgeschlagene Imports |
finished_at | datetime | ja | Abschluss-Zeitpunkt |
paused_until | datetime | ja | Pausiert bis (Rate-Limiting) |
pause_reason | string | ja | Grund der Pausierung |
created_at | datetime | nein | Erstellt am |
updated_at | datetime | nein | Aktualisiert am |
Relations:
| Methode | Typ | Related Model | FK | Beschreibung |
|---|---|---|---|---|
failures() | hasMany | WatcherImportFailure | watcher_import_run_id | Fehlgeschlagene URLs |
items() | hasMany | WatcherImportItem | watcher_import_run_id | Alle Import-URLs |
Casts: finished_at → datetime, paused_until → datetime
Status-Lifecycle:
pending → processing → completed
→ failed
→ paused → processing → ...
Der Fortschritt wird via WatcherImportProgress-Event per WebSocket an den Client gebroadcastet (workspace.{id} Channel).
Location: app/Models/WatcherImportRun.php
WatcherImportItem
Einzelne URL innerhalb eines Import-Durchlaufs. Enthält einen dedupe_key zur Erkennung von Duplikaten innerhalb desselben Imports.
Tabelle: watcher_import_items
| Feld | Typ | Nullable | Beschreibung |
|---|---|---|---|
id | bigint | PK | Primary Key |
watcher_import_run_id | bigint (FK) | nein | Zugehöriger Import-Run |
url | string | nein | Zu importierende URL |
dedupe_key | string | ja | Normalisierter Key für Duplikat-Erkennung |
created_at | datetime | nein | Erstellt am |
updated_at | datetime | nein | Aktualisiert am |
Relations:
| Methode | Typ | Related Model | FK | Beschreibung |
|---|---|---|---|---|
run() | belongsTo | WatcherImportRun | watcher_import_run_id | Zugehöriger Import-Run |
Location: app/Models/WatcherImportItem.php
WatcherImportFailure
Dokumentiert fehlgeschlagene Import-URLs mit Error-Code und Begründung.
Tabelle: watcher_import_failures
| Feld | Typ | Nullable | Beschreibung |
|---|---|---|---|
id | bigint | PK | Primary Key |
watcher_import_run_id | bigint (FK) | nein | Zugehöriger Import-Run |
url | string | nein | Fehlgeschlagene URL |
error_code | string | ja | Fehlercode (z.B. not_found, rate_limited) |
reason | text | ja | Detaillierte Fehlerbeschreibung |
created_at | datetime | nein | Erstellt am |
updated_at | datetime | nein | Aktualisiert am |
Relations:
| Methode | Typ | Related Model | FK | Beschreibung |
|---|---|---|---|---|
run() | belongsTo | WatcherImportRun | watcher_import_run_id | Zugehöriger Import-Run |
Location: app/Models/WatcherImportFailure.php