db

package
v0.0.0-...-f198a40 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type GetAllProductsRow

type GetAllProductsRow struct {
	CodigoItem float64
	Preco      float64
}

type GetNotificationEventParams

type GetNotificationEventParams struct {
	EventType  string
	CodigoItem float64
}

type GetProductsPricesParams

type GetProductsPricesParams struct {
	CodigoPrazo  int
	CodigosItens []float64
}

type GetProductsPricesRow

type GetProductsPricesRow struct {
	CodigoItem     float64
	CodigoUnidade  int
	Preco          float64
	AlteracaoPreco pgtype.Date
}

type ItemPreco

type ItemPreco struct {
	CodigoItem          float64
	CodigoUnidade       int
	CodigoPrazo         int
	CodigoComissao      pgtype.Int4
	Preco               float64
	PermiteDesconto     int
	DescontoMaximo      float64
	AlteracaoPreco      pgtype.Date
	DescontoMaximoProg  float64
	DebitoEmpresaProg   float64
	CreditoVendedorProg float64
	DebitoVendedorProg  float64
	NumeroAlteracao     int
	FlagDelivery        int
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) ClearNotificationEvents

func (q *Queries) ClearNotificationEvents(ctx context.Context, numberOfHours int) error

ClearNotificationEvents deletes old notification exem.

func (*Queries) GetAllProducts

func (q *Queries) GetAllProducts(ctx context.Context, codigoPrazo int) ([]GetAllProductsRow, error)

GetAllProducts is used to calculate the hash of the products and prices. Always sorted in a predictable order. This is used to check if the prices have changed.

func (*Queries) GetMostRecentUpdate

func (q *Queries) GetMostRecentUpdate(ctx context.Context) (pgtype.Date, error)

GetMostRecentUpdate retrieves the most recent update of the prices.

func (*Queries) GetNotificationEvent

func (q *Queries) GetNotificationEvent(ctx context.Context, arg GetNotificationEventParams) (VnLastNotificationEvent, error)

func (*Queries) GetPriceWatcher

func (q *Queries) GetPriceWatcher(ctx context.Context) (VnPriceUpdateWatcher, error)

GetPriceWatcher retrieves the last hash and update time of the prices.

func (*Queries) GetProductsPrices

func (q *Queries) GetProductsPrices(ctx context.Context, arg GetProductsPricesParams) ([]GetProductsPricesRow, error)

Get the price of products from item_preco with a given codigo_prazo. Later we'll filter by the most recent alteracao_preco. If there are two with the same alteracao_preco, we'll send a warning to the admin through email.

func (*Queries) RegisterNotificationEvent

func (q *Queries) RegisterNotificationEvent(ctx context.Context, arg RegisterNotificationEventParams) error

func (*Queries) RemoveOldPriceWatchers

func (q *Queries) RemoveOldPriceWatchers(ctx context.Context) error

RemoveOldPriceWatchers deletes all but the most recent price watcher.

func (*Queries) UpdatePriceWatcher

func (q *Queries) UpdatePriceWatcher(ctx context.Context, pricesHash string) error

UpdatePriceWatcher updates the last hash and update time of the prices.

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type RegisterNotificationEventParams

type RegisterNotificationEventParams struct {
	EventType  string
	CodigoItem float64
}

type VnLastNotificationEvent

type VnLastNotificationEvent struct {
	EventType  string
	CodigoItem float64
	DateSent   pgtype.Timestamptz
}

type VnPriceUpdateWatcher

type VnPriceUpdateWatcher struct {
	LastUpdate pgtype.Timestamptz
	PricesHash string
}

Jump to

Keyboard shortcuts

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