Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTimeTooShort is when the time between two ASNs is not long enough to compute the daily turn ErrTimeTooShort = errors.New("time between asn is too short, daily turn will not be computed") // ErrNoInventory is when an ASN comes in but there is no existing inventory for that product ErrNoInventory = errors.New("no inventory found for product, daily turn will not be computed") )
Functions ¶
func CreateHistoryMap ¶
CreateHistoryMap builds a map[string] based of array of product ids for search efficiency
func ProcessIncomingASNList ¶
func ProcessIncomingASNList(dbs *sql.DB, asnList []tag.AdvanceShippingNotice)
ProcessIncomingASNList takes a list of advance shipping notices and ingests it into the database for calculating the dailyturn. NOTE: this should be called AFTER ingesting the new tags into the database. The reason for this is we don't want to double count EPCs already in the database by simply adding quantity to the inventory count, so we let the inventory count fill up via the processing already in place.
Types ¶
type History ¶
type History struct { ProductID string `json:"product_id" bson:"product_id"` DailyTurn float64 `json:"daily_turn" bson:"daily_turn"` Records []Record `json:"records" bson:"records"` Timestamp int64 `json:"last_timestamp" bson:"last_timestamp"` }
History is the model of the history of daily turn computations for a product
func FindHistoryByProductId ¶
FindHistoryByProductId searches DB for tag based on the productId value Returns the History if found or empty History if it does not exist
func (*History) ComputeAverageDailyTurn ¶
func (history *History) ComputeAverageDailyTurn()
type PresentOrDepartedResults ¶
type PresentOrDepartedResults struct { ProductId string `db:"_id"` DepartedTags int `db:"departedTags"` PresentTags int `db:"presentTags"` }
type Record ¶
type Record struct { Present int `json:"present" bson:"present"` Departed int `json:"departed" bson:"departed"` DailyTurn float64 `json:"daily_turn" bson:"daily_turn"` PreviousTimestamp int64 `json:"previous_timestamp" bson:"previous_timestamp"` Timestamp int64 `json:"timestamp" bson:"timestamp"` }
Record is the model for each daily turn data point