Documentation ¶
Index ¶
- Variables
- func AppraisalIDToUint64(appraisalID string) uint64
- func NewContextMultiParser(typeDB typedb.TypeDB, parserList []parsers.Parser) parsers.Parser
- func Uint64ToAppraisalID(aID uint64) string
- type App
- type Appraisal
- type AppraisalDB
- type AppraisalItem
- func (i AppraisalItem) BuyISKVolume() float64
- func (i AppraisalItem) BuyPrice() float64
- func (i AppraisalItem) BuyTotal() float64
- func (i AppraisalItem) RepresentativePrice() float64
- func (i AppraisalItem) SellISKVolume() float64
- func (i AppraisalItem) SellPrice() float64
- func (i AppraisalItem) SellTotal() float64
- func (i AppraisalItem) SingleRepresentativePrice() float64
- func (i AppraisalItem) TotalVolume() float64
- type MarketItemPrices
- type PriceDB
- type PriceStats
- type Prices
- type Totals
- type Transaction
- type TransactionLogger
- type User
- type WebContext
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAppraisalNotFound is returned whenever an appraisal by a given ID can't be found ErrAppraisalNotFound = errors.New("Appraisal not found") )
var ( // ErrNoValidLinesFound is returned when the appraisal text finds no items ErrNoValidLinesFound = fmt.Errorf("No valid lines found") )
Functions ¶
func AppraisalIDToUint64 ¶
AppraisalIDToUint64 returns a Uint64 appraisal ID for the given string version appraisalID. This is used to make nicer/smaller appraisal IDs
func NewContextMultiParser ¶
NewContextMultiParser implements a parser that knows about what types exist. This makes it much more powerful and prevents accidentally parsing one format as another
func Uint64ToAppraisalID ¶
Uint64ToAppraisalID returns a string AppraisalID for the given Uint64 representation
Types ¶
type App ¶
type App struct { AppraisalDB AppraisalDB TypeDB typedb.TypeDB PriceDB PriceDB Parser parsers.Parser WebContext WebContext NewRelicApplication newrelic.Application }
App holds references to all of the app state that's needed. This is typically created in the 'evepraisal' package.
func (*App) PopulateItems ¶
PopulateItems will populate appraisal items with type and price information
func (*App) PricesForItem ¶
func (app *App) PricesForItem(market string, item AppraisalItem) (Prices, error)
PricesForItem will look up market prices for the given item in the given market
func (*App) StringToAppraisal ¶
func (app *App) StringToAppraisal(market string, s string, pricePercentage float64) (*Appraisal, error)
StringToAppraisal is the big function that everything is based on. It returns a full appraisal at the given market with a string of the appraisal contents (and pricePercentage).
type Appraisal ¶
type Appraisal struct { ID string `json:"id,omitempty"` Created int64 `json:"created"` Kind string `json:"kind"` MarketName string `json:"market_name"` Totals Totals `json:"totals"` Items []AppraisalItem `json:"items"` Raw string `json:"raw"` ParserLines map[string][]int `json:"parser_lines,omitempty"` Unparsed map[int]string `json:"unparsed"` User *User `json:"user,omitempty"` Private bool `json:"private"` PrivateToken string `json:"private_token,omitempty"` PricePercentage float64 `json:"price_percentage,omitempty"` Live bool `json:"live"` ExpireTime *time.Time `json:"expire_time,omitempty"` ExpireMinutes int64 `json:"expire_minutes,omitempty"` }
Appraisal represents an appraisal (duh?). This is what is persisted and returned to users. See cleanAppraisal to see what is never returned to the user
func (*Appraisal) CreatedTime ¶
CreatedTime is the time that the appraisal was created (needed because the time is actually stored as a int64/unix timestamp)
func (*Appraisal) IsExpired ¶
IsExpired returns true if an appraisal is expired and should be deleted. Can be caused by ExpireTime or ExpireMinutes
func (*Appraisal) UsingPercentage ¶
UsingPercentage returns if a custom percentage is specified for the appraisal
type AppraisalDB ¶
type AppraisalDB interface { PutNewAppraisal(appraisal *Appraisal) error GetAppraisal(appraisalID string, updateUsedTime bool) (*Appraisal, error) LatestAppraisals(count int, kind string) ([]Appraisal, error) LatestAppraisalsByUser(user User, count int, kind string, after string) ([]Appraisal, error) TotalAppraisals() (int64, error) IncrementTotalAppraisals() error DeleteAppraisal(appraisalID string) error Close() error }
AppraisalDB allows for creating, deleting and retreiving appraisals
type AppraisalItem ¶
type AppraisalItem struct { Name string `json:"name"` TypeID int64 `json:"typeID"` TypeName string `json:"typeName"` TypeVolume float64 `json:"typeVolume"` Quantity int64 `json:"quantity"` Prices Prices `json:"prices"` Extra struct { Fitted bool `json:"fitted,omitempty"` Dropped bool `json:"dropped,omitempty"` Destroyed bool `json:"destroyed,omitempty"` Location string `json:"location,omitempty"` PlayerName string `json:"player_name,omitempty"` Routed bool `json:"routed,omitempty"` Volume float64 `json:"volume,omitempty"` Distance string `json:"distance,omitempty"` BPC bool `json:"bpc,omitempty"` BPCRuns int64 `json:"bpcRuns,omitempty"` } `json:"meta,omitempty"` }
AppraisalItem represents a single type of item and details the name, quantity, prices, etc. for the appraisal.
func (AppraisalItem) BuyISKVolume ¶
func (i AppraisalItem) BuyISKVolume() float64
BuyISKVolume is used to give ISK per volume using the representative buy price
func (AppraisalItem) BuyPrice ¶
func (i AppraisalItem) BuyPrice() float64
func (AppraisalItem) BuyTotal ¶
func (i AppraisalItem) BuyTotal() float64
BuyTotal is used to give a representative buy total for an item
func (AppraisalItem) RepresentativePrice ¶
func (i AppraisalItem) RepresentativePrice() float64
RepresentativePrice is used to give a representative price for an item. This is used for sorting.
func (AppraisalItem) SellISKVolume ¶
func (i AppraisalItem) SellISKVolume() float64
SellISKVolume is used to give ISK per volume using the representative sell price
func (AppraisalItem) SellPrice ¶
func (i AppraisalItem) SellPrice() float64
func (AppraisalItem) SellTotal ¶
func (i AppraisalItem) SellTotal() float64
SellTotal is used to give a representative sell total for an item
func (AppraisalItem) SingleRepresentativePrice ¶
func (i AppraisalItem) SingleRepresentativePrice() float64
SingleRepresentativePrice is used to give a representative price for a single item
func (AppraisalItem) TotalVolume ¶
func (i AppraisalItem) TotalVolume() float64
type MarketItemPrices ¶
type PriceDB ¶
type PriceDB interface { GetPrice(market string, typeID int64) (Prices, bool) UpdatePrices([]MarketItemPrices) error Close() error }
PriceDB holds prices for eve online items. Something else should update them
type PriceStats ¶
type PriceStats struct { Average float64 `json:"avg"` Max float64 `json:"max"` Median float64 `json:"median"` Min float64 `json:"min"` Percentile float64 `json:"percentile"` Stddev float64 `json:"stddev"` Volume int64 `json:"volume"` OrderCount int64 `json:"order_count"` }
PriceStats has results of statistical functions used to combine a bunch of orders into easier to process numbers
type Prices ¶
type Prices struct { All PriceStats `json:"all"` Buy PriceStats `json:"buy"` Sell PriceStats `json:"sell"` Updated time.Time `json:"updated"` Strategy string `json:"strategy"` }
Prices represents prices for an item
func (Prices) Set ¶
Set returns a new Prices object with the given price set in all applicable stats
type Totals ¶
type Totals struct { Buy float64 `json:"buy"` Sell float64 `json:"sell"` Volume float64 `json:"volume"` }
Totals represents sums of all prices/volumes for all items in the appraisal
type Transaction ¶
Transaction is used to signal the normal or abnormal end to a given event
type TransactionLogger ¶
type TransactionLogger interface { StartTransaction(identifier string) Transaction StartWebTransaction(identifier string, w http.ResponseWriter, r *http.Request) Transaction }
TransactionLogger is used to log general events and HTTP requests
type User ¶
User is information about a logged-in user. Currently, this is only stored in the user's session but may be used as keys in a user settings database
type WebContext ¶
WebContext holds HTTP handlers and stuff