Documentation ¶
Index ¶
- func BackupDatabase(dbPath, backupPath string) error
- func BackupDatabaseWithContext(ctx context.Context, dbPath, backupPath string) (err error)
- func GetContract(id string, expiryYear int, expiryMonth int) (*api.ContractProperties, error)
- func GetContractCount() (int, error)
- func GetCoopContracts() ([]*api.ContractProperties, error)
- func GetCoopMemberActivityStats(c *coop.CoopStatus, refreshTime time.Time) (activities map[string]*coop.CoopMemberActivity, err error)
- func GetPeekedGroupedByContract(since time.Time) (contractIds []string, groups map[string][]*Peeked, err error)
- func GetSoloAndCoopStatusesFromRefresh(byThisTime time.Time, dedupe bool) (timestamp time.Time, solos []*solo.SoloContract, coops []*coop.CoopStatus, ...)
- func GzipFile(path string) error
- func GzipFileRemoveOriginal(path string) error
- func InitDB(conf config.DatabaseConfig) error
- func InsertContract(now time.Time, c *api.ContractProperties, checkExistence bool) (exists bool, err error)
- func InsertCoopStatus(timestamp time.Time, refreshId int64, c *api.CoopStatus) error
- func InsertEvent(seen time.Time, e *api.Event) error
- func InsertPeeked(p *Peeked) error
- func InsertRefresh(timestamp time.Time) (refreshId int64, err error)
- func InsertSoloStatus(timestamp time.Time, refreshId int64, c *solo.SoloContract) error
- func WrapCoopStatusWithDB(c *api.CoopStatus) (*coop.CoopStatus, error)
- type Contract
- type ContractSignature
- type Event
- type Peeked
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BackupDatabase ¶
func GetContract ¶
expiryYear and expiryMonth are optional. When expiryYear is 0, the latest iteration is retrieved. If no matching contract is found in the database, the return value is (nil, nil), i.e., error is not set in that case.
func GetContractCount ¶
func GetCoopContracts ¶
func GetCoopContracts() ([]*api.ContractProperties, error)
func GetCoopMemberActivityStats ¶
func GetCoopMemberActivityStats(c *coop.CoopStatus, refreshTime time.Time) ( activities map[string]*coop.CoopMemberActivity, err error, )
func GetPeekedGroupedByContract ¶
func GetPeekedGroupedByContract(since time.Time) (contractIds []string, groups map[string][]*Peeked, err error)
GetPeekedGroupedByContract retrieves the list of peeked coops since the specified time, grouped by contract ID. Returned groups are ordered reverse chronologically (order is preserved in contractIds).
func GetSoloAndCoopStatusesFromRefresh ¶
func GetSoloAndCoopStatusesFromRefresh(byThisTime time.Time, dedupe bool) ( timestamp time.Time, solos []*solo.SoloContract, coops []*coop.CoopStatus, err error, )
GetSoloAndCoopStatusesFromRefresh returns contract statuses from the last refresh by the specified cutoff time. If no such refresh can be found in the database, all return values will be set to the corresponding zero values (including nil err).
If dedupe is true, filter out coops where the user has apparently joined a tracked coop already (coop status can be more up-to-date than contract farm backup).
func GzipFileRemoveOriginal ¶
func InitDB ¶
func InitDB(conf config.DatabaseConfig) error
func InsertContract ¶
func InsertContract(now time.Time, c *api.ContractProperties, checkExistence bool) (exists bool, err error)
InsertContract upserts the contract into the database. If checkExistence is true, perform an additional query beforehand to determine whether the contract already exists in the database, and if so, set exists to true in the return values. If checkExistence is false, then exists in the return values is meaningless.
func InsertCoopStatus ¶
refreshId is optional, and will be inserted as NULL if zero.
func InsertPeeked ¶
func InsertSoloStatus ¶
refreshId is optional, and will be inserted as NULL if zero.
func WrapCoopStatusWithDB ¶
func WrapCoopStatusWithDB(c *api.CoopStatus) (*coop.CoopStatus, error)
Contract is set to nil if no matching contract is found or if there is a database error.
Types ¶
type ContractSignature ¶
ContractSignature is used to determine contract uniqueness.
func GetContractSignature ¶
func GetContractSignature(c *api.ContractProperties) ContractSignature
type Event ¶
type Event struct { Id string EventType string Multiplier float64 Message string FirstSeenTime time.Time LastSeenTime time.Time ExpiryTime time.Time }
func (*Event) HasTimeLeft ¶
func (*Event) UnhypedMessage ¶
type Peeked ¶
type Peeked struct { ContractId string Code string LastPeekedTime time.Time HasCompleted bool Openings int32 EggsLaid float64 EggsPerHour float64 RequiredEggsPerHour float64 TimeLeft time.Duration MaxEarningBonusPercentage float64 MeanEarningBonusPercentage float64 }
func GetPeeked ¶
GetPeeked retrieves the list of peeked coops since the specified time. contractId is optional; when nonempty, only return peeked coops for that particular contract. Returned coops are ordered reverse chronologically.