lookups

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package lookups provides static lookup data including country codes.

Index

Constants

View Source
const (
	StateTypeNew             = "new"
	StateTypeOpen            = "open"
	StateTypeClosed          = "closed"
	StateTypePendingReminder = "pending reminder"
	StateTypePendingAuto     = "pending auto"
	StateTypeRemoved         = "removed"
	StateTypeMerged          = "merged"
)

OTRS ticket state type names.

View Source
const (
	StateNew                = "new"
	StateOpen               = "open"
	StateClosedSuccessful   = "closed successful"
	StateClosedUnsuccessful = "closed unsuccessful"
	StatePendingReminder    = "pending reminder"
	StatePendingAutoPlus    = "pending auto close+"
	StatePendingAutoMinus   = "pending auto close-"
	StateRemoved            = "removed"
	StateMerged             = "merged"
)

OTRS default ticket state names.

View Source
const (
	SenderAgent    = "agent"
	SenderSystem   = "system"
	SenderCustomer = "customer"
)

OTRS article sender type names.

View Source
const (
	LockUnlock  = "unlock"
	LockLock    = "lock"
	LockTmpLock = "tmp_lock"
)

OTRS ticket lock type names.

View Source
const (
	ChannelEmail    = "Email"
	ChannelPhone    = "Phone"
	ChannelInternal = "Internal"
	ChannelChat     = "Chat"
)

OTRS communication channel names.

View Source
const (

	// NewOpenStateIDsSQL: states of type new or open.
	NewOpenStateIDsSQL = stateIDsOfTypes + "('new', 'open')"
	// PendingStateIDsSQL: states of type pending reminder or pending auto.
	PendingStateIDsSQL = stateIDsOfTypes + "('pending reminder', 'pending auto')"
	// PendingReminderStateIDsSQL: states of type pending reminder.
	PendingReminderStateIDsSQL = stateIDsOfTypes + "('pending reminder')"
	// ClosedStateIDsSQL: states of type closed.
	ClosedStateIDsSQL = stateIDsOfTypes + "('closed')"
	// ViewableStateIDsSQL: OTRS Ticket::ViewableStateType default
	// (new, open, pending reminder, pending auto).
	ViewableStateIDsSQL = stateIDsOfTypes + "('new', 'open', 'pending reminder', 'pending auto')"
	// FinishedStateIDsSQL: states of type closed, removed or merged.
	FinishedStateIDsSQL = stateIDsOfTypes + "('closed', 'removed', 'merged')"
)

SQL fragments selecting ticket_state ids by state type name. Use them inside `ticket_state_id IN (...)` / `NOT IN (...)`.

Variables

This section is empty.

Functions

func Countries

func Countries() []string

Countries returns the currently loaded list of ISO country names.

func ID added in v0.10.0

func ID(ctx context.Context, db *sql.DB, t Table, name string) (int, error)

ID returns the id of the row named name (case-insensitive) in table t. A cache miss reloads the table once, so rows added after the first load are found. Missing rows return an error wrapping sql.ErrNoRows.

func IDs added in v0.10.0

func IDs(ctx context.Context, db *sql.DB, t Table, names ...string) ([]int, error)

IDs resolves several names of one table; names that do not exist are skipped (an OTRS database may lack optional rows).

func Invalidate added in v0.10.0

func Invalidate(db *sql.DB)

Invalidate drops cached rows for db (all tables).

func IsClosedStateType added in v0.10.0

func IsClosedStateType(typeName string) bool

IsClosedStateType reports whether a state type name ends the ticket's life (closed, removed or merged).

func IsPendingStateType added in v0.10.0

func IsPendingStateType(typeName string) bool

IsPendingStateType reports whether a state type name is a pending type.

func LoadCountries

func LoadCountries(configDir string) error

LoadCountries loads the country list from the provided config directory overriding the embedded defaults.

func Name added in v0.10.0

func Name(ctx context.Context, db *sql.DB, t Table, id int) (string, error)

Name returns the name of row id in table t ("" with sql.ErrNoRows when absent). A cache miss reloads the table once.

func StateTypeNameOfState added in v0.10.0

func StateTypeNameOfState(ctx context.Context, db *sql.DB, stateID int) (string, error)

StateTypeNameOfState returns the state type name of ticket_state id.

Types

type Table added in v0.10.0

type Table string

Table is a lookup table whose rows are resolved by name. Only these tables are accepted, so the table name can safely be part of the query text.

const (
	StateType       Table = "ticket_state_type"
	HistoryType     Table = "ticket_history_type"
	SenderType      Table = "article_sender_type"
	LockType        Table = "ticket_lock_type"
	Channel         Table = "communication_channel"
	LinkType        Table = "link_type"
	LinkState       Table = "link_state"
	LinkObject      Table = "link_object"
	AutoResponse    Table = "auto_response_type"
	FollowUp        Table = "follow_up_possible"
	ValidLookup     Table = "valid"
	StateLookup     Table = "ticket_state"
	PriorityTable   Table = "ticket_priority"
	TicketTypeTable Table = "ticket_type"
)

Lookup tables with fixed, OTRS-defined row names.

Directories

Path Synopsis
Package lookupstest provides test helpers for lookup numbering.
Package lookupstest provides test helpers for lookup numbering.

Jump to

Keyboard shortcuts

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