db

package
v0.0.0-...-7360598 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const NoRows = "no rows"

NoRows is returned when a query finds no rows

Variables

This section is empty.

Functions

This section is empty.

Types

type Accessor

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

Accessor provides cache-fronted database functions

func New

func New(uri string, connectionLimit int, hotItemTimeoutDays int, cacheAccessor cache.ICache) (*Accessor, error)

New initializes and returns a cache-fronted database accessor

func (*Accessor) AddItemToList

func (a *Accessor) AddItemToList(ctx *model.AucBotContext, shoppingListID int, item *model.RankedItem, threshold int) error

func (*Accessor) ClearPendingChoice

func (a *Accessor) ClearPendingChoice(ctx *model.AucBotContext, userSessionID string) error

ClearPendingChoice removes a pending choice. If no choice is pending, it returns NoPendingChoiceErr TODO deprecated -- to be used by cleanup lambda?

func (*Accessor) Close

func (a *Accessor) Close()

Close closes the datasource db connection

func (*Accessor) CreateNewList

func (a *Accessor) CreateNewList(ctx *model.AucBotContext, guildRealmID int, discordChannelID, discordUserID, discordUsername string) error

func (*Accessor) GetAllItemIds

func (a *Accessor) GetAllItemIds(ctx *model.AucBotContext) ([]int, error)

func (*Accessor) GetComponentIDs

func (a *Accessor) GetComponentIDs(abLog *model.AucBotContext, id int) ([][]int, error)

GetComponentIDs returns the list of components which make up a given item

func (*Accessor) GetItemGroups

func (a *Accessor) GetItemGroups(abLog *model.AucBotContext) ([]string, error)

GetItemGroups retrieves all available item group names

func (*Accessor) GetItemIDsInSet

func (a *Accessor) GetItemIDsInSet(abLog *model.AucBotContext, setName string) ([]int, error)

GetItemIDsInSet retrives itemIDs in a given item set

func (*Accessor) GetItemInfo

func (a *Accessor) GetItemInfo(abLog *model.AucBotContext, id int, includeBOP bool) (*model.Item, error)

GetItemInfo retrieves item info from our private item database The Item struct returned will not be complete, it will only include attributes we care about/have saved

func (*Accessor) GetItemValuationFunction

func (a *Accessor) GetItemValuationFunction(abLog *model.AucBotContext, id int) (string, error)

GetItemValuationFunction retrives a string key for a valuation function or an empty string if no function exists for the given item

func (*Accessor) GetItemsByName

func (a *Accessor) GetItemsByName(abLog *model.AucBotContext, name string, includeBOP bool, limit int) ([]*model.Item, error)

GetItemsByName retrieves pointers to any auctionable items that have the given name Name is case insensitive, and will have leading and trailing spaces and quotes stripped

func (*Accessor) GetItemsForValuation

func (a *Accessor) GetItemsForValuation(abLog *model.AucBotContext, funcName string) ([]int, error)

GetItemsForValuation retrives items considered in the given valuation function

func (*Accessor) GetLastSavedID

func (a *Accessor) GetLastSavedID(abLog *model.AucBotContext, table, pk string) (int, error)

GetLastSavedID gets the last itemID added to the db. useful for restarting scans

func (*Accessor) GetMultipleItemInfo

func (a *Accessor) GetMultipleItemInfo(abLog *model.AucBotContext, ids []int) (map[int]*model.Item, error)

GetMultipleItemInfo retrieves multiple items by id. The returned map is sorted by itemID. Not all ids are guaranteed to be returned

func (*Accessor) GetPendingChoice

func (a *Accessor) GetPendingChoice(ctx *model.AucBotContext, userSessionID string, choiceIndex int) (*model.ChoiceResult, string, error)

GetPendingChoice returns a pending choice. If no choice is pending, it returns NoPendingChoiceErr

func (*Accessor) GetPriceAlerts

func (a *Accessor) GetPriceAlerts(ctx *model.AucBotContext, region, realmSlug string) ([]model.SinglePriceAlert, error)

func (*Accessor) GetRecipes

func (a *Accessor) GetRecipes(abLog *model.AucBotContext, id int, profFilter string, bonusRank ...int) ([]*model.Recipe, error)

GetRecipes returns the list of recipes which create the given item Optional bonusRank looks for a recipe for the given itemID that matches the 1-indexed rank for the _item_, not recipe. This rank corresponds to bonus item level or other stats determined by bonusIDs corresponding to the rank. Optional profFilter limits recipes to those made with a given profession

func (*Accessor) GetSupportedValuationItems

func (a *Accessor) GetSupportedValuationItems(abLog *model.AucBotContext) ([]*model.ValuationFunctionEntry, error)

GetSupportedValuationItems retrives items with custom valuation functions

func (*Accessor) HasPendingChoice

func (a *Accessor) HasPendingChoice(ctx *model.AucBotContext, userSessionID string) (int, error)

HasPendingChoice returns the number of choices if a pending choice exists. If no choice is pending, it returns NoPendingChoiceErr TODO deprecated

func (*Accessor) ListAlertedOn

func (a *Accessor) ListAlertedOn(ctx *model.AucBotContext, discordChannelID string, messageIDs []string) error

func (*Accessor) ListForGuild

func (a *Accessor) ListForGuild(ctx *model.AucBotContext, guildRealmID int) (*model.ShoppingList, error)

func (*Accessor) LoadGuildRealmCache

func (a *Accessor) LoadGuildRealmCache(abLog *model.AucBotContext) (map[string]*model.RealmCacheEntry, error)

LoadGuildRealmCache loads the saved discord guild -> WoW realm mappings Realms will always have the suffix "-us" or "-eu"

func (*Accessor) LogPriceRequest

func (a *Accessor) LogPriceRequest(abLog *model.AucBotContext, itemID, guildRealmID int, discordUsername, requestType string)

LogPriceRequest saves a record of who is requesting which item This function returns immediately, logging is done asynchronously

func (*Accessor) LookupRealmForGuild

func (a *Accessor) LookupRealmForGuild(abLog *model.AucBotContext, id string, mappingTypeTag model.AccessTypeTag) (*model.RealmCacheEntry, error)

LookupRealmForGuild loads a specific realm for a guild or channel This method bypasses cache

func (*Accessor) Ping

func (a *Accessor) Ping() error

Ping verifies the health of the database connection

func (*Accessor) RemoveFromList

func (a *Accessor) RemoveFromList(ctx *model.AucBotContext, priceAlertID int) error

func (*Accessor) ResetList

func (a *Accessor) ResetList(ctx *model.AucBotContext, shoppingListID int) error

func (*Accessor) SaveChoice

func (a *Accessor) SaveChoice(ctx *model.AucBotContext, userSessionID, token, callbackFunc string, choiceData []model.ChoiceResult) error

SaveChoice saves the options for a pending choice to the database. The choices will be saved in the order they are presented to the user, so they can be subsequently queried by index.

func (*Accessor) SaveItem

func (a *Accessor) SaveItem(abLog *model.AucBotContext, item *model.Item) error

SaveItem adds an item to the database If the item already exists (by id), it will upsert (replace) the existing item Note cache will become invalid after using this, although it should never be needed outside of a scan

func (*Accessor) SaveRecipe

func (a *Accessor) SaveRecipe(abLog *model.AucBotContext, recipe *model.Recipe, version *model.RecipeVersion) error

SaveRecipe saves a new recipe to the db. If a recipe already exists, this will error and perform no action.

func (*Accessor) UpdateListOptions

func (a *Accessor) UpdateListOptions(ctx *model.AucBotContext, shoppingListID int, options model.ShoppingListOptions) error

func (*Accessor) UpsertRealmMapping

func (a *Accessor) UpsertRealmMapping(abLog *model.AucBotContext, channelID string, mappingTypeTag model.AccessTypeTag, realmSlug, region string) (int, error)

UpsertRealmMapping adds or updates a discord DM channel ID -> realm mapping it returns the guildRealmID of the modified record

Jump to

Keyboard shortcuts

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