postgres

package
v0.0.0-...-e63bc4c Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2025 License: MIT Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CallCounterQuery = `` /* 502-byte string literal not displayed */

	ChatCounterQuery = `` /* 479-byte string literal not displayed */

	EmailCounterQuery = `` /* 469-byte string literal not displayed */

	// JSONB CTE Queries
	CallsJSONBCTE = `` /* 4918-byte string literal not displayed */

	ChatsJSONBCTE = `` /* 1457-byte string literal not displayed */

	EmailsJSONBCTE = `` /* 1146-byte string literal not displayed */

)

Variables

View Source
var CaseCommunicationFields = []string{"id", "ver", "communication_type", "communication_id"}
View Source
var CaseLinkFields = []string{
	"created_by", "created_at", "updated_by", "updated_at", "id", "ver", "author", "name", "url",
}
View Source
var CaseTimelineFields = []string{
	"call", "chat", "email",
}

Functions

func AddSubqueryAsColumn

func AddSubqueryAsColumn(mainQuery *Select, subquery sq.SelectBuilder, subAlias string, filtersApplied bool) error

func ApplyFilters

func ApplyFilters(base sq.SelectBuilder, filters *filters.FilterExpr) (sq.SelectBuilder, error)

func ApplyFiltersToQuery

func ApplyFiltersToQuery(qb sq.SelectBuilder, column string, filters []util.FilterExpr) sq.SelectBuilder

ApplyFiltersToQuery applies the filters to the given SelectBuilder query.

func NewCaseCommentStore

func NewCaseCommentStore(store *Store) (store.CaseCommentStore, error)

func NewCaseCommunicationStore

func NewCaseCommunicationStore(store *Store) (store.CaseCommunicationStore, error)

func NewCaseFileStore

func NewCaseFileStore(store *Store) (store.CaseFileStore, error)

NewCaseFileStore initializes a new CaseFileStore.

func NewCaseLinkStore

func NewCaseLinkStore(store *Store) (store.CaseLinkStore, error)

func NewCaseStore

func NewCaseStore(store *Store) (store.CaseStore, error)

func NewCaseTimelineStore

func NewCaseTimelineStore(store *Store) (store.CaseTimelineStore, error)

func NewCatalogStore

func NewCatalogStore(store *Store) (store.CatalogStore, error)

func NewCloseReasonGroupStore

func NewCloseReasonGroupStore(store *Store) (store.CloseReasonGroupStore, error)

func NewCloseReasonStore

func NewCloseReasonStore(store *Store) (store.CloseReasonStore, error)

func NewPriorityStore

func NewPriorityStore(store *Store) (store.PriorityStore, error)

func NewRelatedCaseStore

func NewRelatedCaseStore(store *Store) (store.RelatedCaseStore, error)

func NewSLAConditionStore

func NewSLAConditionStore(store *Store) (store.SLAConditionStore, error)

func NewSLAStore

func NewSLAStore(store *Store) (store.SLAStore, error)

func NewServiceStore

func NewServiceStore(store *Store) (store.ServiceStore, error)

func NewSourceStore

func NewSourceStore(store *Store) (store.SourceStore, error)

func NewStatusConditionStore

func NewStatusConditionStore(store *Store) (store.StatusConditionStore, error)

func NewStatusStore

func NewStatusStore(store *Store) (store.StatusStore, error)

func NormalizeFilters

func NormalizeFilters(base *Select, opts options.Searcher, join func(options.Searcher, *Select, string) (string, error)) error

NormalizeFilters normalizes the filters by applying the join function to each filter and changing column names that they become valid sql in format: "table.column".

func ParseError

func ParseError(err error) error

func ParseFilters

func ParseFilters(expr *filters.FilterExpr) (sq.Sqlizer, error)

func RegisterConstraint

func RegisterConstraint(name, message string)

RegisterConstraint register custom database check constraint (like "CHECK balance > 0"). Postgres doesn't define a very useful message for constraint failures (new row for relation "accounts" violates check constraint), so you can define your own.

  • name - should be the name of the constraint in the database.
  • message - your own custom error message

Panics if you attempt to register two constraints with the same name.

func ValidateLinkCreate

func ValidateLinkCreate(caseId int64, input *model.CaseLink) error

Types

type BuilderOptions

type BuilderOptions func(s *Select) error

func WithFiltersEncoder

func WithFiltersEncoder(encoder map[string]func(any) any) BuilderOptions

type CalendarSlot

type CalendarSlot struct {
	Day            int
	StartTimeOfDay int
	EndTimeOfDay   int
	Disabled       bool
}

type CaseCommentStore

type CaseCommentStore struct {
	// contains filtered or unexported fields
}

func (*CaseCommentStore) Delete

Delete implements store.CaseCommentStore

func (*CaseCommentStore) GetRolesById

func (c *CaseCommentStore) GetRolesById(
	ctx context.Context,
	commentId int64,
	access auth.AccessMode,
) ([]int64, error)

func (*CaseCommentStore) List

List implements store.CaseCommentStore

func (*CaseCommentStore) Publish

Publish implements store.CaseCommentStore

func (*CaseCommentStore) Update

type CaseCommunicationStore

type CaseCommunicationStore struct {
	// contains filtered or unexported fields
}
func (c *CaseCommunicationStore) Link(
	options options.Creator,
	communications []*model.CaseCommunication,
) ([]*model.CaseCommunication, error)

func (*CaseCommunicationStore) List

func (c *CaseCommunicationStore) Unlink(options options.Deleter) (int64, error)

type CaseFileStore

type CaseFileStore struct {
	// contains filtered or unexported fields
}

func (*CaseFileStore) BuildListCaseFilesSqlizer

func (c *CaseFileStore) BuildListCaseFilesSqlizer(
	rpc options.Searcher,
) (sq.SelectBuilder, error)

func (*CaseFileStore) Delete

func (c *CaseFileStore) Delete(rpc options.Deleter) (*model.CaseFile, error)

Delete implements store.CaseFileStore.

func (*CaseFileStore) List

func (c *CaseFileStore) List(rpc options.Searcher) ([]*model.CaseFile, error)

List implements store.CaseFileStore for listing case files.

type CaseLinkStore

type CaseLinkStore struct {
	// contains filtered or unexported fields
}

func (*CaseLinkStore) Create

func (l *CaseLinkStore) Create(rpc options.Creator, add *model.CaseLink) (*model.CaseLink, error)

Create implements store.CaseLinkStore.

func (*CaseLinkStore) Delete

func (l *CaseLinkStore) Delete(opts options.Deleter) (*model.CaseLink, error)

Delete implements store.CaseLinkStore.

func (*CaseLinkStore) List

func (l *CaseLinkStore) List(opts options.Searcher) ([]*model.CaseLink, error)

List implements store.CaseLinkStore.

func (*CaseLinkStore) Update

func (l *CaseLinkStore) Update(opts options.Updator, upd *model.CaseLink) (*model.CaseLink, error)

Update implements store.CaseLinkStore.

type CaseStore

type CaseStore struct {
	// contains filtered or unexported fields
}

func (*CaseStore) CheckRbacAccess

func (c *CaseStore) CheckRbacAccess(ctx context.Context, auth auth.Auther, access auth.AccessMode, caseId int64) (bool, error)

func (*CaseStore) Create

func (c *CaseStore) Create(
	rpc options.Creator,
	add *_go.Case,
) (*_go.Case, error)

func (*CaseStore) Delete

func (c *CaseStore) Delete(rpc options.Deleter) error

Delete implements store.CaseStore.

func (*CaseStore) GetRolesById

func (c *CaseStore) GetRolesById(
	ctx context.Context,
	caseId int64,
	access auth.AccessMode,
) ([]int64, error)

func (*CaseStore) List

func (c *CaseStore) List(
	opts options.Searcher,
) (*_go.CaseList, error)

List implements store.CaseStore.

func (*CaseStore) ScanServiceDefs

func (c *CaseStore) ScanServiceDefs(
	ctx context.Context,
	txManager *transaction.TxManager,
	serviceID int64,
	priorityID int64,
) (*ServiceRelatedDefs, error)

ScanServiceDefs fetches the SLA ID, reaction time, resolution time, calendar ID, and SLA condition ID for the last child service with a non-NULL SLA ID.

func (*CaseStore) SetOverdueCases

func (c *CaseStore) SetOverdueCases(so options.Searcher) ([]*_go.Case, bool, error)

func (*CaseStore) Update

func (c *CaseStore) Update(
	rpc options.Updator,
	upd *_go.Case,
) (*_go.Case, error)

region UPDATE

type CaseTimelineStore

type CaseTimelineStore struct {
	// contains filtered or unexported fields
}

func (*CaseTimelineStore) Get

func (*CaseTimelineStore) GetCounter

func (c *CaseTimelineStore) GetCounter(rpc options.Searcher) ([]*model.TimelineCounter, error)

GetCounter retrieves timeline counter data for a case

type CatalogStore

type CatalogStore struct {
	// contains filtered or unexported fields
}

func (*CatalogStore) Create

func (s *CatalogStore) Create(rpc options.Creator, add *cases.Catalog) (*cases.Catalog, error)

Create implements store.CatalogStore.

func (*CatalogStore) Delete

func (s *CatalogStore) Delete(rpc options.Deleter) error

Delete implements store.CatalogStore.

func (*CatalogStore) List

func (s *CatalogStore) List(
	rpc options.Searcher,
	depth int64,
	subfields []string,
	hasSubservices bool,
) (*cases.CatalogList, error)

List implements store.CatalogStore.

func (*CatalogStore) Update

func (s *CatalogStore) Update(rpc options.Updator, lookup *cases.Catalog) (*cases.Catalog, error)

Update implements store.CatalogStore.

type CloseReason

type CloseReason struct {
	// contains filtered or unexported fields
}

func (*CloseReason) Create

func (s *CloseReason) Create(creator options.Creator, input *model.CloseReason) (*model.CloseReason, error)

func (*CloseReason) Delete

func (s *CloseReason) Delete(deleter options.Deleter) (*model.CloseReason, error)

func (*CloseReason) List

func (s *CloseReason) List(searcher options.Searcher, closeReasonId int64) ([]*model.CloseReason, error)

func (*CloseReason) Update

func (s *CloseReason) Update(updator options.Updator, input *model.CloseReason) (*model.CloseReason, error)

type CloseReasonGroup

type CloseReasonGroup struct {
	// contains filtered or unexported fields
}

func (*CloseReasonGroup) Create

func (*CloseReasonGroup) Delete

func (s *CloseReasonGroup) Delete(rpc options.Deleter) error

func (*CloseReasonGroup) List

func (*CloseReasonGroup) Update

type CommentScan

type CommentScan func(comment *_go.CaseComment) any

type ExceptionSlot

type ExceptionSlot struct {
	Date           time.Time
	StartTimeOfDay int
	EndTimeOfDay   int
	Disabled       bool
	Repeat         bool
	Working        bool
}

type MergedSlot

type MergedSlot struct {
	Day            int       // Weekday (0-6, Sunday-Saturday)
	Date           time.Time // Specific date (can be empty if not an exception)
	StartTimeOfDay int       // Start time of the slot (in minutes from midnight)
	EndTimeOfDay   int       // End time of the slot (in minutes from midnight)
	Disabled       bool      // Is the slot disabled
}

type Priority

type Priority struct {
	// contains filtered or unexported fields
}

func (*Priority) Create

func (p *Priority) Create(rpc options.Creator, add *model.Priority) (*model.Priority, error)

Create implements store.PriorityStore.

func (*Priority) Delete

func (p *Priority) Delete(rpc options.Deleter) (*model.Priority, error)

func (*Priority) List

func (p *Priority) List(
	rpc options.Searcher,
	notInSla int64,
	inSla int64,
) ([]*model.Priority, error)

List implements store.PriorityStore.

func (*Priority) Update

func (p *Priority) Update(rpc options.Updator, update *model.Priority) (*model.Priority, error)

Update implements store.PriorityStore.

type RelatedCaseStore

type RelatedCaseStore struct {
	// contains filtered or unexported fields
}

func (*RelatedCaseStore) Create

func (r *RelatedCaseStore) Create(
	rpc options.Creator,
	relation *cases.RelationType,
	userID int64,
) (*cases.RelatedCase, error)

Create implements store.RelatedCaseStore for creating a new related case.

func (*RelatedCaseStore) Delete

func (r *RelatedCaseStore) Delete(
	rpc options.Deleter,
) error

Delete implements store.RelatedCaseStore for deleting a related case.

func (*RelatedCaseStore) List

List implements store.RelatedCaseStore for fetching related cases.

func (*RelatedCaseStore) ParseRelationTypeWithReversion

func (r *RelatedCaseStore) ParseRelationTypeWithReversion(
	rawType string,
) (cases.RelationType, error)

ParseRelationTypeWithReversion determines the relation type based on parent-case matching.

func (*RelatedCaseStore) Update

func (r *RelatedCaseStore) Update(
	rpc options.Updator,
	input *cases.InputRelatedCase,
	userID int64,
) (*cases.RelatedCase, error)

type SLAConditionStore

type SLAConditionStore struct {
	// contains filtered or unexported fields
}

func (*SLAConditionStore) Create

func (*SLAConditionStore) Delete

Delete implements store.SLAConditionStore.

func (*SLAConditionStore) List

List implements store.SLAConditionStore.

func (*SLAConditionStore) Update

Update implements store.SLAConditionStore.

type SLAStore

type SLAStore struct {
	// contains filtered or unexported fields
}

func (*SLAStore) Create

func (s *SLAStore) Create(rpc options.Creator, input *model.SLA) (*model.SLA, error)

func (*SLAStore) Delete

func (s *SLAStore) Delete(rpc options.Deleter) (*model.SLA, error)

func (*SLAStore) List

func (s *SLAStore) List(rpc options.Searcher) ([]*model.SLA, error)

func (*SLAStore) Update

func (s *SLAStore) Update(rpc options.Updator, input *model.SLA) (*model.SLA, error)

type Select

type Select struct {
	TableAlias                 string
	Joins                      map[string]string
	Query                      sq.SelectBuilder
	FilterSpecialFieldsEncoder map[string]func(any) any
}

func NewSelect

func NewSelect(rootTableAlias string, builder sq.SelectBuilder, opts ...BuilderOptions) (*Select, error)

func (*Select) ToSql

func (s *Select) ToSql() (string, []any, error)

type ServiceRelatedDefs

type ServiceRelatedDefs struct {
	SLAID              int
	SLAConditionID     int
	ReactionTime       int
	ResolutionTime     int
	CalendarID         int
	StatusID           int
	CloseReasonGroupID int
	AssigneeID         int
	GroupID            int
}

type ServiceStore

type ServiceStore struct {
	// contains filtered or unexported fields
}

func (*ServiceStore) Create

func (s *ServiceStore) Create(rpc options.Creator, add *model.Service) (*model.Service, error)

func (*ServiceStore) Delete

func (s *ServiceStore) Delete(rpc options.Deleter) (*model.Service, error)

Delete implements store.ServiceStore.

func (*ServiceStore) List

func (s *ServiceStore) List(rpc options.Searcher) ([]*model.Service, error)

List implements store.ServiceStore.

func (*ServiceStore) Update

func (s *ServiceStore) Update(rpc options.Updator, lookup *model.Service) (*model.Service, error)

Update implements store.ServiceStore.

type Source

type Source struct {
	// contains filtered or unexported fields
}

func (*Source) Create

func (s *Source) Create(rpc options.Creator, source *model.Source) (*model.Source, error)

func (*Source) Delete

func (s *Source) Delete(rpc options.Deleter) (*model.Source, error)

func (*Source) List

func (s *Source) List(rpc options.Searcher) ([]*model.Source, error)

func (*Source) Update

func (s *Source) Update(rpc options.Updator, source *model.Source) (*model.Source, error)

type Status

type Status struct {
	// contains filtered or unexported fields
}

func (*Status) Create

func (s *Status) Create(rpc options.Creator, input *model.Status) (*model.Status, error)

func (*Status) Delete

func (s *Status) Delete(rpc options.Deleter) (*model.Status, error)

func (*Status) List

func (s *Status) List(rpc options.Searcher) ([]*model.Status, error)

func (*Status) Update

func (s *Status) Update(rpc options.Updator, input *model.Status) (*model.Status, error)

type StatusConditionStore

type StatusConditionStore struct {
	// contains filtered or unexported fields
}

func (*StatusConditionStore) Create

func (*StatusConditionStore) Delete

func (*StatusConditionStore) List

func (*StatusConditionStore) Update

type StatusScan

type StatusScan func(status *_go.Status) any

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is the struct implementing the Store interface.

func New

func New(config *conf.DatabaseConfig) *Store

New creates a new Store instance.

func (*Store) Case

func (s *Store) Case() store.CaseStore

func (*Store) CaseComment

func (s *Store) CaseComment() store.CaseCommentStore

func (*Store) CaseCommunication

func (s *Store) CaseCommunication() store.CaseCommunicationStore

func (*Store) CaseFile

func (s *Store) CaseFile() store.CaseFileStore
func (s *Store) CaseLink() store.CaseLinkStore

func (*Store) CaseTimeline

func (s *Store) CaseTimeline() store.CaseTimelineStore

func (*Store) Catalog

func (s *Store) Catalog() store.CatalogStore

func (*Store) Close

func (s *Store) Close() error

Close closes the database connection and returns a custom error if it fails.

func (*Store) CloseReason

func (s *Store) CloseReason() store.CloseReasonStore

func (*Store) CloseReasonGroup

func (s *Store) CloseReasonGroup() store.CloseReasonGroupStore

func (*Store) Custom

func (s *Store) Custom() cstore.Catalog

func (*Store) Database

func (s *Store) Database() (*pgxpool.Pool, error)

Database returns the database connection or a custom error if it is not opened.

func (*Store) GetExtension

func (s *Store) GetExtension(ctx context.Context, dc int64, pkg string) customrel.ExtensionDescriptor

func (*Store) Open

func (s *Store) Open() error

Open establishes a connection to the database and returns a custom error if it fails.

func (*Store) Priority

func (s *Store) Priority() store.PriorityStore

func (*Store) RelatedCase

func (s *Store) RelatedCase() store.RelatedCaseStore

func (*Store) SLA

func (s *Store) SLA() store.SLAStore

func (*Store) SLACondition

func (s *Store) SLACondition() store.SLAConditionStore

func (*Store) Service

func (s *Store) Service() store.ServiceStore

func (*Store) Source

func (s *Store) Source() store.SourceStore

func (*Store) Status

func (s *Store) Status() store.StatusStore

-------------Dictionary Stores ------------ //

func (*Store) StatusCondition

func (s *Store) StatusCondition() store.StatusConditionStore

type TimingOpts

type TimingOpts interface {
	RequestTime() time.Time
	GetAuthOpts() auth.Auther
	context.Context
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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