catalog

package
v0.0.0-...-df769fd Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SourceSearch = "search"
	SourceGet    = "get"
	SourceCart   = "cart"
	SourceOrder  = "order"

	DefaultQueryTTLDays = 7
)

Variables

This section is empty.

Functions

func BuildDelioQueryNorm

func BuildDelioQueryNorm(phrase string, coords *delio.Coordinates) string

func BuildFriscoQueryNorm

func BuildFriscoQueryNorm(phrase, categoryID string) string

func IngestCart

func IngestCart(provider string, payload any) error

func IngestGet

func IngestGet(provider string, payload any) error

func IngestSearch

func IngestSearch(provider, queryText string, payload any) error

func IsFresh

func IsFresh(rec *QueryRecord, now time.Time) bool

func IsStale

func IsStale(rec *QueryRecord, now time.Time) bool

Types

type DB

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

func Open

func Open() (*DB, error)

func OpenPath

func OpenPath(path string) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) GetQuery

func (db *DB) GetQuery(ctx context.Context, provider, queryNorm string) (*QueryRecord, error)

func (*DB) Path

func (db *DB) Path() string

func (*DB) UpsertProducts

func (db *DB) UpsertProducts(ctx context.Context, records []ProductRecord) error

func (*DB) UpsertQueryError

func (db *DB) UpsertQueryError(ctx context.Context, provider, queryText, queryNorm, errorCode string, now time.Time, fallbackUsed bool) error

func (*DB) UpsertQuerySuccess

func (db *DB) UpsertQuerySuccess(ctx context.Context, input QuerySuccessInput) error

type ProductRecord

type ProductRecord struct {
	Provider          string
	ExternalID        string
	Slug              string
	Name              string
	Brand             string
	Description       string
	MeasureValue      float64
	MeasureUnit       string
	MeasureText       string
	ImageURL          string
	Currency          string
	PriceMinor        *int64
	RegularPriceMinor *int64
	PromoPriceMinor   *int64
	UnitPriceMinor    *int64
	Available         *bool
	Source            string
	SeenAt            time.Time
	SearchBlob        string
	RawJSON           []byte
}

func NormalizeDelioCart

func NormalizeDelioCart(payload any, seenAt time.Time) ([]ProductRecord, error)

func NormalizeDelioGet

func NormalizeDelioGet(payload any, seenAt time.Time) ([]ProductRecord, error)

func NormalizeDelioSearch

func NormalizeDelioSearch(payload any, seenAt time.Time) ([]ProductRecord, error)

func NormalizeFriscoCart

func NormalizeFriscoCart(payload any, seenAt time.Time) ([]ProductRecord, error)

func NormalizeFriscoGet

func NormalizeFriscoGet(payload any, seenAt time.Time) ([]ProductRecord, error)

func NormalizeFriscoSearch

func NormalizeFriscoSearch(payload any, seenAt time.Time) ([]ProductRecord, error)

type QueryRecord

type QueryRecord struct {
	Provider              string
	QueryText             string
	QueryNorm             string
	TTLDays               int
	LastLiveSearchAt      *time.Time
	LastSelectedProductID string
	LastSelectedAt        *time.Time
	LastUsedAt            time.Time
	SuccessCount          int
	FallbackCount         int
	LastErrorCode         string
	LastErrorAt           *time.Time
}

type QuerySuccessInput

type QuerySuccessInput struct {
	Provider              string
	QueryText             string
	QueryNorm             string
	TTLDays               int
	LastSelectedProductID string
	Now                   time.Time
	LiveSearchUsed        bool
	FallbackUsed          bool
	PreserveSelection     bool
}

type SnapshotRecord

type SnapshotRecord struct {
	SeenAt            time.Time
	Source            string
	QueryText         string
	Currency          string
	PriceMinor        *int64
	RegularPriceMinor *int64
	PromoPriceMinor   *int64
	UnitPriceMinor    *int64
	Available         *bool
	ChangeHash        string
	RawOfferJSON      []byte
}

Jump to

Keyboard shortcuts

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