postgres

package
v0.0.0-...-d0a596a Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CallsCTE = `` /* 5436-byte string literal not displayed */

	EmailsCTE = `` /* 926-byte string literal not displayed */

	ChatsCTE = `` /* 1840-byte string literal not displayed */

	CallsCounterCTE = `` /* 437-byte string literal not displayed */

	ChatsCounterCTE = `` /* 379-byte string literal not displayed */

	EmailsCounterCTE = `` /* 370-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{
	"calls", "chats", "emails",
}

Functions

func AddSubqueryAsColumn

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

func ConvertRelationType

func ConvertRelationType(relationType _go.RelationType) (int, error)

ConvertRelationType validates the cases.RelationType and returns its integer representation.

func DeduplicateFields

func DeduplicateFields(fields []string) []string

DeduplicateFields removes duplicate fields from rpc.Fields while preserving order.

func NewAccessControlStore

func NewAccessControlStore(store db.Store) (db.AccessControlStore, error)

func NewCaseCommentStore

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

func NewCaseCommunicationStore

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

func NewCaseFileStore

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

NewCaseFileStore initializes a new CaseFileStore.

func NewCaseLinkStore

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

func NewCaseStore

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

func NewCaseTimelineStore

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

func NewCatalogStore

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

func NewCloseReasonGroupStore

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

func NewCloseReasonStore

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

func NewPriorityStore

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

func NewRelatedCaseStore

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

func NewSLAConditionStore

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

func NewSLAStore

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

func NewServiceStore

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

func NewSourceStore

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

func NewStatusConditionStore

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

func NewStatusStore

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

func ValidateLinkCreate

func ValidateLinkCreate(caseId int64, input *_go.InputCaseLink) *dberr.DBError

Types

type AccessContol

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

func (AccessContol) RbacAccess

func (s AccessContol) RbacAccess(ctx context.Context, domainId int64, id int64, groups []int, access uint8, table string) (bool, error)

Check RBAC rights for the user to access the resource

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) BuildListCaseCommentsSqlizer

func (c *CaseCommentStore) BuildListCaseCommentsSqlizer(
	rpc *model.SearchOptions,
) (sq.Sqlizer, func(*_go.CaseComment) []any, error)

func (*CaseCommentStore) BuildUpdateCaseCommentSqlizer

func (c *CaseCommentStore) BuildUpdateCaseCommentSqlizer(
	rpc *model.UpdateOptions,
	input struct {
		Text string
		Id   int64
	},
) (sq.Sqlizer, []func(comment *_go.CaseComment) any, error)

func (*CaseCommentStore) Delete

func (c *CaseCommentStore) Delete(
	rpc *model.DeleteOptions,
) error

Delete implements store.CommentCaseStore.

func (*CaseCommentStore) List

func (*CaseCommentStore) Publish

func (c *CaseCommentStore) Publish(
	rpc *model.CreateOptions,
	add *_go.CaseComment,
) (*_go.CaseComment, error)

Publish implements store.CommentCaseStore for publishing a single comment.

func (*CaseCommentStore) Update

func (c *CaseCommentStore) Update(
	rpc *model.UpdateOptions,
	upd *_go.CaseComment,
) (*_go.CaseComment, error)

type CaseCommunicationStore

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

func (*CaseCommunicationStore) List

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

type CaseFileStore

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

func (*CaseFileStore) BuildListCaseFilesSqlizer

func (c *CaseFileStore) BuildListCaseFilesSqlizer(
	rpc *model.SearchOptions,
) (sq.Sqlizer, []func(file *cases.File) any, error)

func (*CaseFileStore) Delete

func (c *CaseFileStore) Delete(rpc *model.DeleteOptions) error

Delete implements store.CaseFileStore.

func (*CaseFileStore) List

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 *model.CreateOptions, add *_go.InputCaseLink) (*_go.CaseLink, error)

Create implements store.CaseLinkStore.

func (*CaseLinkStore) Delete

func (l *CaseLinkStore) Delete(opts *model.DeleteOptions) error

Delete implements store.CaseLinkStore.

func (*CaseLinkStore) List

List implements store.CaseLinkStore.

func (*CaseLinkStore) Update

func (l *CaseLinkStore) Update(opts *model.UpdateOptions, upd *_go.InputCaseLink) (*_go.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 *model.CreateOptions,
	add *_go.Case,
) (*_go.Case, error)

func (*CaseStore) Delete

func (c *CaseStore) Delete(rpc *model.DeleteOptions) error

Delete implements store.CaseStore.

func (*CaseStore) List

func (c *CaseStore) List(opts *model.SearchOptions) (*_go.CaseList, error)

List implements store.CaseStore.

func (*CaseStore) ScanSla

func (c *CaseStore) ScanSla(
	rpc *model.CreateOptions,
	txManager *transaction.TxManager,
	serviceID int64,
	priorityID int64,
) (
	slaID,
	slaConditionID,
	reactionTime,
	resolutionTime,
	calendarID int,
	err error,
)

ScanSla 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) Update

func (c *CaseStore) Update(
	rpc *model.UpdateOptions,
	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 *model.SearchOptions) ([]*model.TimelineCounter, error)

type CatalogStore

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

func (*CatalogStore) Create

func (s *CatalogStore) Create(rpc *model.CreateOptions, add *cases.Catalog) (*cases.Catalog, error)

Create implements store.CatalogStore.

func (*CatalogStore) Delete

func (s *CatalogStore) Delete(rpc *model.DeleteOptions) error

Delete implements store.CatalogStore.

func (*CatalogStore) List

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

List implements store.CatalogStore.

func (*CatalogStore) Update

func (s *CatalogStore) Update(rpc *model.UpdateOptions, 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(rpc *model.CreateOptions, add *_go.CloseReason) (*_go.CloseReason, error)

Create implements store.CloseReasonStore.

func (*CloseReason) Delete

func (s *CloseReason) Delete(rpc *model.DeleteOptions, closeReasonId int64) error

Delete implements store.CloseReasonStore.

func (*CloseReason) List

func (s *CloseReason) List(rpc *model.SearchOptions, closeReasonId int64) (*_go.CloseReasonList, error)

List implements store.CloseReasonStore.

func (*CloseReason) Update

Update implements store.CloseReasonStore.

type CloseReasonGroup

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

func (CloseReasonGroup) Create

func (CloseReasonGroup) Delete

func (s CloseReasonGroup) Delete(rpc *model.DeleteOptions) 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 *model.CreateOptions, add *api.Priority) (*api.Priority, error)

Create implements store.PriorityStore.

func (*Priority) Delete

func (p *Priority) Delete(rpc *model.DeleteOptions) error

func (*Priority) List

func (p *Priority) List(
	rpc *model.SearchOptions,
	notInSla int64,
	inSla int64,
) (*api.PriorityList, error)

List implements store.PriorityStore.

func (*Priority) Update

func (p *Priority) Update(rpc *model.UpdateOptions, update *api.Priority) (*api.Priority, error)

Update implements store.PriorityStore.

type PriorityScan

type PriorityScan func(priority *api.Priority) any

type RelatedCaseStore

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

func (*RelatedCaseStore) Create

func (r *RelatedCaseStore) Create(
	rpc *model.CreateOptions,
	relation *cases.RelationType,
) (*cases.RelatedCase, error)

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

func (*RelatedCaseStore) Delete

func (r *RelatedCaseStore) Delete(
	rpc *model.DeleteOptions,
) 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

type SLAConditionStore

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

func (*SLAConditionStore) Create

func (s *SLAConditionStore) Create(rpc *model.CreateOptions, add *cases.SLACondition, priorities []int64) (*cases.SLACondition, error)

func (*SLAConditionStore) Delete

func (s *SLAConditionStore) Delete(rpc *model.DeleteOptions) error

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 *model.CreateOptions, add *cases.SLA) (*cases.SLA, error)

Create implements store.SLAStore.

func (*SLAStore) Delete

func (s *SLAStore) Delete(rpc *model.DeleteOptions) error

Delete implements store.SLAStore.

func (*SLAStore) List

func (s *SLAStore) List(rpc *model.SearchOptions) (*cases.SLAList, error)

List implements store.SLAStore.

func (*SLAStore) Update

func (s *SLAStore) Update(rpc *model.UpdateOptions, l *cases.SLA) (*cases.SLA, error)

Update implements store.SLAStore.

type ServiceStore

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

func (*ServiceStore) Create

func (s *ServiceStore) Create(rpc *model.CreateOptions, add *cases.Service) (*cases.Service, error)

func (*ServiceStore) Delete

func (s *ServiceStore) Delete(rpc *model.DeleteOptions) error

Delete implements store.ServiceStore.

func (*ServiceStore) List

List implements store.ServiceStore.

func (*ServiceStore) Update

func (s *ServiceStore) Update(rpc *model.UpdateOptions, lookup *cases.Service) (*cases.Service, error)

Update implements store.ServiceStore.

type Source

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

func (Source) Create

func (s Source) Create(rpc *model.CreateOptions, add *_go.Source) (*_go.Source, error)

func (Source) Delete

func (s Source) Delete(rpc *model.DeleteOptions) error

func (Source) List

func (s Source) List(rpc *model.SearchOptions) (*_go.SourceList, error)

func (Source) Update

func (s Source) Update(rpc *model.UpdateOptions, l *_go.Source) (*_go.Source, error)

type Status

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

func (Status) Create

func (s Status) Create(rpc *model.CreateOptions, add *_go.Status) (*_go.Status, error)

Create creates a new status in the database. Implements the store.StatusStore interface.

func (Status) Delete

func (s Status) Delete(rpc *model.DeleteOptions) error

Delete removes a status from the database. Implements the store.StatusStore interface.

func (Status) List

func (s Status) List(rpc *model.SearchOptions) (*_go.StatusList, error)

List retrieves a list of statuses from the database. Implements the store.StatusStore interface.

func (Status) Update

func (s Status) Update(rpc *model.UpdateOptions, l *_go.Status) (*_go.Status, error)

Update modifies a status in the database. Implements the store.StatusStore interface.

type StatusConditionStore

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

func (StatusConditionStore) Create

func (StatusConditionStore) Delete

func (s StatusConditionStore) Delete(rpc *model.DeleteOptions, statusId int64) error

func (StatusConditionStore) List

func (StatusConditionStore) Update

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) AccessControl

func (s *Store) AccessControl() store.AccessControlStore

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() *dberr.DBError

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) Database

func (s *Store) Database() (*pgxpool.Pool, *dberr.DBError)

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

func (*Store) Open

func (s *Store) Open() *dberr.DBError

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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