counter

package
v1.36.4 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultShards = 3
	ConfigKind    = "_counterconfig"
	ShardKind     = "_countershard"
)

Variables

View Source
var AddMemberTask *delay.Function
View Source
var IncrementByTask *delay.Function

Functions

func AddCurrency

func AddCurrency(ctx context.Context, org *organization.Organization, cur currency.Type) error

func AddMember

func AddMember(c context.Context, name, tag, storeId, geo string, p Period, value string, t time.Time) error

Adds a member to the array on the Shard

func AddSetMember

func AddSetMember(c context.Context, name, tag, storeId, geo string, p Period, value string, t time.Time) error

Adds a member to the array if it does not exist

func Count

func Count(c context.Context, name string) (int, error)

Count retrieves the value of the named counter.

func IncrAffiliateFees

func IncrAffiliateFees(ctx context.Context, org *organization.Organization, affId string, rfl *referral.Referral) error

func IncrOrder

func IncrOrder(ctx context.Context, ord *order.Order) error

func IncrOrderRefund

func IncrOrderRefund(ctx context.Context, ord *order.Order, refund int, t time.Time) error

func IncrOrderReturn

func IncrOrderReturn(ctx context.Context, items []lineitem.LineItem, rtn *return_.Return) error

func IncrOrderShip

func IncrOrderShip(ctx context.Context, ord *order.Order, t time.Time) error

func IncrProduct

func IncrProduct(ctx context.Context, prod *product.Product, ord *order.Order) error

func IncrProductRefund

func IncrProductRefund(ctx context.Context, prod *product.Product, ord *order.Order) error

func IncrProductReturn

func IncrProductReturn(ctx context.Context, prod *product.Product, ord *order.Order, rtn *return_.Return) error

func IncrProductShip

func IncrProductShip(ctx context.Context, prod *product.Product, ord *order.Order) error

func IncrReferrerFees

func IncrReferrerFees(ctx context.Context, org *organization.Organization, refId string, rfl *referral.Referral) error

func IncrStoreOrders

func IncrStoreOrders(ctx context.Context, org *organization.Organization, storeId string, t time.Time) error

func IncrStoreProductOrders

func IncrStoreProductOrders(ctx context.Context, org *organization.Organization, storeId string, ord *order.Order, t time.Time) error

func IncrStoreSales

func IncrStoreSales(ctx context.Context, org *organization.Organization, storeId string, pays []*payment.Payment, t time.Time) error

func IncrSubscriber

func IncrSubscriber(ctx context.Context, t time.Time) error

func IncrSubscribers

func IncrSubscribers(ctx context.Context, org *organization.Organization, mailinglistId string, t time.Time) error

func IncrTotalOrders

func IncrTotalOrders(ctx context.Context, org *organization.Organization, t time.Time) error

func IncrTotalProductOrders

func IncrTotalProductOrders(ctx context.Context, org *organization.Organization, ord *order.Order, t time.Time) error

func IncrTotalSales

func IncrTotalSales(ctx context.Context, org *organization.Organization, pays []*payment.Payment, t time.Time) error

func IncrUser

func IncrUser(ctx context.Context, t time.Time) error

func IncrUsers

func IncrUsers(ctx context.Context, org *organization.Organization, t time.Time) error

func IncreaseShards

func IncreaseShards(c context.Context, name string, n int) error

IncreaseShards increases the number of Shards for the named counter to n. It will never decrease the number of Shards.

func Increment

func Increment(c context.Context, name, tag, storeId, geo string, p Period, t time.Time) error

Increment increments the named counter by 1

func IncrementBy

func IncrementBy(c context.Context, name, tag, storeId, geo string, p Period, amount int, t time.Time) error

Increment increments the named counter by amount

func IncrementByAll

func IncrementByAll(ctx context.Context, tag, storeId, geo string, value int, t time.Time) error

func MemberExists

func MemberExists(c context.Context, name string, value string) bool

func Members

func Members(c context.Context, name string) ([]string, error)

Types

type DashboardData

type DashboardData struct {
	TotalSales       currencyValue
	TotalOrders      int
	TotalUsers       int
	TotalSubscribers int

	DailySales       currencyValues
	DailyOrders      []int
	DailyUsers       []int
	DailySubscribers []int
}

func GetDashboardData

func GetDashboardData(ctx context.Context, t Period, date time.Time, tzOffset int, org *organization.Organization) (DashboardData, error)

type Period

type Period string
const (
	None    Period = "none"
	Total   Period = "total"
	Hourly  Period = "hourly"
	Daily   Period = "daily"
	Weekly  Period = "weekly"
	Monthly Period = "monthly"
	Yearly  Period = "yearly"
)

type Shard

type Shard struct {
	Name string `json:"name"`
	Tag  string `json:"tag"`
	// Counter
	Count   int    `json:"count"`
	StoreId string `json:"storeId"`
	Geo     string `json:"geo"`
	// Array
	Set  map[string]bool `datastore:"-"`
	Set_ string          `datastore:",noindex" json:"set"`

	Period Period `json:"period"`

	Time time.Time `json:"time"`
}

func (*Shard) Load

func (s *Shard) Load(ps []datastore.Property) (err error)

func (*Shard) Save

func (s *Shard) Save() (ps []datastore.Property, err error)

type TimeFunc

type TimeFunc func(t time.Time) string

Jump to

Keyboard shortcuts

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