Documentation
¶
Overview ¶
Package activity provides a persistent activity log that records events from the in-memory event bus so they survive restarts and are queryable.
Index ¶
- func ValidCategory(c string) bool
- type Activity
- type AttentionItem
- type AttentionResult
- type Category
- type ListResult
- type Service
- func (s *Service) List(ctx context.Context, category *string, since *string, limit int64) (*ListResult, error)
- func (s *Service) NeedsAttention(ctx context.Context, window time.Duration, perKind int) (*AttentionResult, error)
- func (s *Service) Prune(ctx context.Context, olderThan time.Duration) error
- func (s *Service) Subscribe(bus *events.Bus)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidCategory ¶
ValidCategory returns true if c is a known category.
Types ¶
type Activity ¶
type Activity struct {
ID string `json:"id"`
Type string `json:"type"`
Category string `json:"category"`
MovieID *string `json:"movie_id,omitempty"`
Title string `json:"title"`
Detail map[string]any `json:"detail,omitempty"`
CreatedAt string `json:"created_at"`
}
Activity is the domain representation of an activity log entry.
type AttentionItem ¶
type AttentionItem struct {
Kind string `json:"kind"` // "grab_failed" | "import_failed"
GrabID string `json:"grab_id,omitempty"`
MovieID string `json:"movie_id,omitempty"`
ReleaseTitle string `json:"release_title"`
Detail string `json:"detail,omitempty"`
CreatedAt string `json:"created_at"`
}
AttentionItem is one entry in the "Needs attention" rail. Each item is either a failed or removed grab (from grab_history.download_status) or a failed import (from activity_log.category=import_failed).
type AttentionResult ¶
type AttentionResult struct {
Items []AttentionItem `json:"items"`
// Counts breaks the items down by kind so the UI can show a summary
// without re-counting client-side.
Counts struct {
GrabFailed int `json:"grab_failed"`
ImportFailed int `json:"import_failed"`
} `json:"counts"`
}
AttentionResult is the response shape for /api/v1/activity/needs-attention.
type Category ¶
type Category string
Category groups related event types for filtering. Mirrors Pilot's success/failure split so the Activity-page "Needs attention" rail can find failed grabs/imports without re-parsing the type column.
const ( CategoryGrabSucceeded Category = "grab_succeeded" CategoryGrabFailed Category = "grab_failed" CategoryImportSucceeded Category = "import_succeeded" CategoryImportFailed Category = "import_failed" CategoryTask Category = "task" CategoryHealth Category = "health" CategoryMovie Category = "movie" // Legacy values kept in the validator so existing API clients that // filter by the old coarse names ("grab"/"import") don't break. // Migration 00005_activity_categories.sql back-fills DB rows to // the new vocabulary; these constants exist only to accept legacy // query strings. CategoryGrabLegacy Category = "grab" CategoryImportLegacy Category = "import" )
type ListResult ¶
ListResult is the paginated response from List.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service records and queries activity log entries.
func NewService ¶
NewService creates a new activity service.
func (*Service) List ¶
func (s *Service) List(ctx context.Context, category *string, since *string, limit int64) (*ListResult, error)
List returns activity entries matching the given filters.
func (*Service) NeedsAttention ¶
func (s *Service) NeedsAttention(ctx context.Context, window time.Duration, perKind int) (*AttentionResult, error)
NeedsAttention returns recent failures for the Activity-page "Needs attention" rail. window controls how far back to look; perKind caps each bucket so a flood of one type doesn't drown out the others.
Mirrors Pilot's NeedsAttention shape (see pilot/internal/core/activity /service.go) — minus the "stalled" bucket, which Prism doesn't have a stallwatcher for. Add stalled here if/when one ships.