incstore

package
v0.0.0-...-1a3a2fa Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const StoreCtxKey storeCtxKey = "store"

Variables

This section is empty.

Functions

func CtxWithStore

func CtxWithStore(ctx context.Context, s Store) context.Context

Types

type CallsFilter

type CallsFilter struct {
	common.Pagination
}

type Incident

type Incident struct {
	incidents.Incident

	CallCount int `json:"callCount"`
}

type IncidentOption

type IncidentOption func(*incidentOptions)

func WithoutCalls

func WithoutCalls() IncidentOption

type IncidentsParams

type IncidentsParams struct {
	common.Pagination
	OrderBy   *Order                `json:"orderBy"`
	Direction *common.SortDirection `json:"dir"`
	Filter    *string               `json:"filter"`

	Start *jsontypes.Time `json:"start"`
	End   *jsontypes.Time `json:"end"`
}

func (*IncidentsParams) SortDir

func (p *IncidentsParams) SortDir() (string, error)

SortDir computes the sortField_order string used by the ListIncidentsP SQL query.

type Order

type Order string
const (
	OrderStart    Order = "start"
	OrderNumCalls Order = "numcalls"
)

func (*Order) IsValid

func (t *Order) IsValid() bool

type Store

type Store interface {
	// CreateIncident creates an incident.
	CreateIncident(ctx context.Context, inc incidents.Incident) (*incidents.Incident, error)

	// AddToIncident adds the specified call IDs to an incident.
	// If not nil, notes must be valid json.
	AddRemoveIncidentCalls(ctx context.Context, incidentID uuid.UUID, addCallIDs []uuid.UUID, notes []byte, removeCallIDs []uuid.UUID) error

	// UpdateNotes updates the notes for a call-incident mapping.
	UpdateNotes(ctx context.Context, incidentID uuid.UUID, callID uuid.UUID, notes []byte) error

	// Incidents gets incidents matching parameters and pagination.
	Incidents(ctx context.Context, p IncidentsParams) (incs []Incident, totalCount int, err error)

	// Incident gets a single incident.
	Incident(ctx context.Context, id uuid.UUID, opts ...IncidentOption) (*incidents.Incident, error)

	// IncidentCalls gets the calls in an incident.
	IncidentCalls(ctx context.Context, id uuid.UUID, pag *CallsFilter) (*incidents.IncidentCalls, error)

	// UpdateIncident updates an incident.
	UpdateIncident(ctx context.Context, id uuid.UUID, p UpdateIncidentParams) (*incidents.Incident, error)

	// DeleteIncident deletes an incident.
	DeleteIncident(ctx context.Context, id uuid.UUID) error

	// Owner returns an incident with only the owner filled out.
	Owner(ctx context.Context, id uuid.UUID) (incidents.Incident, error)

	// CallIn returns whether an incident is in an call
	CallIn(ctx context.Context, inc uuid.UUID, call uuid.UUID) (bool, error)

	// TGsIn returns the talkgroups referenced by an incident as a map, primarily for rbac use.
	TGsIn(ctx context.Context, inc uuid.UUID) (talkgroups.PresenceMap, error)
}

func FromCtx

func FromCtx(ctx context.Context) Store

func NewStore

func NewStore(db database.Store) Store

type UpdateIncidentParams

type UpdateIncidentParams struct {
	Name        *string            `json:"name"`
	Description *string            `json:"description"`
	StartTime   *jsontypes.Time    `json:"startTime"`
	EndTime     *jsontypes.Time    `json:"endTime"`
	Location    []byte             `json:"location"`
	Metadata    jsontypes.Metadata `json:"metadata"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL