Documentation
¶
Index ¶
- Variables
- func ComputeAPISecretHash(secret string, key []byte) string
- func CountPPPlayerAchievementsAchieved(node sqalx.Node) (int, error)
- func CountPPPlayers(node sqalx.Node) (int, error)
- func CountPPXPTransactionsWithType(node sqalx.Node, txtype string) (int, error)
- func CountPairActivationsByDay(node sqalx.Node, start time.Time, end time.Time) ([]time.Time, []int, error)
- func CountTripsByDay(node sqalx.Node, start time.Time, end time.Time) ([]time.Time, []int, []int, error)
- func GenerateAPIKey() string
- func GenerateAPISecret() string
- func GetPPNotificationSetting(node sqalx.Node, discordID uint64, notifType string, method string, ...) (bool, error)
- func GetPPXPTransactionsTotal(node sqalx.Node) (int, error)
- func GetTripIDs(node sqalx.Node) ([]string, error)
- func GetTripIDsBetween(node sqalx.Node, start time.Time, end time.Time) ([]string, error)
- func PosPlayLevelToXP(level int) int
- func PosPlayPlayerLevel(totalXP int) (int, float64)
- func RegisterPPAchievementStrategy(s PPAchievementStrategy)
- func SetPPNotificationSetting(node sqalx.Node, discordID uint64, notifType string, method string, ...) error
- func UnregisterPPAchievementStrategy(s PPAchievementStrategy)
- func VehicleIDLessFunc(vi, vj *VehicleETA) bool
- func VehicleIDLessFuncString(vi, vj string) bool
- type APIPair
- type AndroidPairRequest
- type Announcement
- type AnnouncementStore
- type BaseReport
- type Connection
- func GetConnection(node sqalx.Node, from string, to string, closedCompat bool) (*Connection, error)
- func GetConnections(node sqalx.Node, closedCompat bool) ([]*Connection, error)
- func GetConnectionsFrom(node sqalx.Node, from string, closedCompat bool) ([]*Connection, error)
- func GetConnectionsFromPlatform(node sqalx.Node, fromPlatform string) ([]*Connection, error)
- func GetConnectionsTo(node sqalx.Node, to string, closedCompat bool) ([]*Connection, error)
- func GetConnectionsToPlatform(node sqalx.Node, toPlatform string) ([]*Connection, error)
- type Dataset
- type Disturbance
- func GetDisturbance(node sqalx.Node, id string) (*Disturbance, error)
- func GetDisturbances(node sqalx.Node) ([]*Disturbance, error)
- func GetDisturbancesBetween(node sqalx.Node, start time.Time, end time.Time, officialOnly bool) ([]*Disturbance, error)
- func GetLatestNDisturbances(node sqalx.Node, limit uint64) ([]*Disturbance, error)
- func GetOngoingDisturbances(node sqalx.Node) ([]*Disturbance, error)
- type DisturbanceCategory
- type Duration
- func (d *Duration) DecodeMsgpack(dec *msgpack.Decoder) error
- func (d Duration) EncodeMsgpack(enc *msgpack.Encoder) error
- func (d Duration) MarshalJSON() ([]byte, error)
- func (d *Duration) Scan(value interface{}) error
- func (d *Duration) UnmarshalJSON(b []byte) error
- func (d Duration) Value() (driver.Value, error)
- type Exit
- type Feedback
- type FeedbackType
- type Line
- func (line *Line) AddStatus(node sqalx.Node, status *Status, letNotify bool) error
- func (line *Line) Availability(node sqalx.Node, startTime time.Time, endTime time.Time, officialOnly bool) (availability float64, avgDuration time.Duration, err error)
- func (line *Line) Conditions(node sqalx.Node) ([]*LineCondition, error)
- func (line *Line) CountDisturbancesByDay(node sqalx.Node, start time.Time, end time.Time, officialOnly bool) ([]int, error)
- func (line *Line) CountDisturbancesByHourOfDay(node sqalx.Node, start time.Time, end time.Time, officialOnly bool) ([]int, error)
- func (line *Line) CurrentlyClosed(tx sqalx.Node) (bool, error)
- func (line *Line) Delete(node sqalx.Node) error
- func (line *Line) DisturbanceDuration(node sqalx.Node, startTime time.Time, endTime time.Time, officialOnly bool) (totalDuration time.Duration, count int, err error)
- func (line *Line) DisturbancesBetween(node sqalx.Node, startTime time.Time, endTime time.Time, officialOnly bool) ([]*Disturbance, error)
- func (line *Line) GetDirectionForConnection(node sqalx.Node, connection *Connection) (*Station, error)
- func (line *Line) LastCondition(node sqalx.Node) (*LineCondition, error)
- func (line *Line) LastDisturbance(node sqalx.Node, officialOnly bool) (*Disturbance, error)
- func (line *Line) LastOngoingDisturbance(node sqalx.Node, officialOnly bool) (*Disturbance, error)
- func (line *Line) LastStatus(node sqalx.Node) (*Status, error)
- func (line *Line) OngoingDisturbances(node sqalx.Node, officialOnly bool) ([]*Disturbance, error)
- func (line *Line) Paths(node sqalx.Node) ([]*LinePath, error)
- func (line *Line) Schedules(node sqalx.Node) ([]*LineSchedule, error)
- func (line *Line) Stations(node sqalx.Node) ([]*Station, error)
- func (line *Line) Statuses(node sqalx.Node) ([]*Status, error)
- func (line *Line) Update(node sqalx.Node) error
- type LineCondition
- type LineDisturbanceReport
- func (r *LineDisturbanceReport) Category() string
- func (r *LineDisturbanceReport) Line() *Line
- func (r *LineDisturbanceReport) RateLimiterKey() string
- func (r *LineDisturbanceReport) ReplayProtected() bool
- func (r *LineDisturbanceReport) Submitter() *APIPair
- func (r *LineDisturbanceReport) Time() time.Time
- type LinePath
- type LineSchedule
- type Lobby
- type LobbySchedule
- type Network
- func (network *Network) CountDisturbancesByHour(node sqalx.Node, start time.Time, end time.Time) ([]int, error)
- func (network *Network) Delete(node sqalx.Node) error
- func (network *Network) LastDisturbance(node sqalx.Node, officialOnly bool) (*Disturbance, error)
- func (network *Network) LastDisturbanceTime(node sqalx.Node, officialOnly bool) (time.Time, error)
- func (network *Network) Lines(node sqalx.Node) ([]*Line, error)
- func (network *Network) Schedules(node sqalx.Node) ([]*NetworkSchedule, error)
- func (network *Network) Stations(node sqalx.Node) ([]*Station, error)
- func (network *Network) Update(node sqalx.Node) error
- type NetworkSchedule
- type POI
- type PPAchievement
- func (achievement *PPAchievement) CountAchieved(node sqalx.Node) (int, error)
- func (achievement *PPAchievement) Delete(node sqalx.Node) error
- func (achievement *PPAchievement) FirstAchieved(node sqalx.Node) (time.Time, error)
- func (achievement *PPAchievement) LastAchieved(node sqalx.Node) (time.Time, error)
- func (achievement *PPAchievement) MarshalConfig(v interface{}) error
- func (achievement *PPAchievement) UnmarshalConfig(v interface{}) error
- func (achievement *PPAchievement) Update(node sqalx.Node) error
- type PPAchievementContext
- type PPAchievementStrategy
- type PPLeaderboardEntry
- type PPNotificationSetting
- type PPPair
- type PPPlayer
- func (player *PPPlayer) Achievement(node sqalx.Node, achievementID string) (*PPPlayerAchievement, error)
- func (player *PPPlayer) Achievements(node sqalx.Node) ([]*PPPlayerAchievement, error)
- func (player *PPPlayer) AnonymousName() string
- func (player *PPPlayer) CountXPTransactionsWithType(node sqalx.Node, txtype string) (int, error)
- func (player *PPPlayer) Delete(node sqalx.Node) error
- func (player *PPPlayer) Level(node sqalx.Node) (int, int, float64, error)
- func (player *PPPlayer) RankBetween(node sqalx.Node, start, end time.Time) (int, error)
- func (player *PPPlayer) Seed() uint64
- func (player *PPPlayer) Update(node sqalx.Node) error
- func (player *PPPlayer) XPBalance(node sqalx.Node) (int, error)
- func (player *PPPlayer) XPBalanceBetween(node sqalx.Node, start, end time.Time) (int, error)
- func (player *PPPlayer) XPBalanceWithType(node sqalx.Node, txtype string) (int, error)
- func (player *PPPlayer) XPBalanceWithTypeBetween(node sqalx.Node, txtype string, start, end time.Time) (int, error)
- func (player *PPPlayer) XPTransactions(node sqalx.Node) ([]*PPXPTransaction, error)
- func (player *PPPlayer) XPTransactionsBetween(node sqalx.Node, start, end time.Time) ([]*PPXPTransaction, error)
- func (player *PPPlayer) XPTransactionsCustomFilter(node sqalx.Node, preds ...interface{}) ([]*PPXPTransaction, error)
- func (player *PPPlayer) XPTransactionsLimit(node sqalx.Node, limit uint64) ([]*PPXPTransaction, error)
- func (player *PPPlayer) XPTransactionsWithType(node sqalx.Node, txtype string) ([]*PPXPTransaction, error)
- type PPPlayerAchievement
- type PPXPTransaction
- func GetPPXPTransaction(node sqalx.Node, id string) (*PPXPTransaction, error)
- func GetPPXPTransactions(node sqalx.Node) ([]*PPXPTransaction, error)
- func GetPPXPTransactionsBetween(node sqalx.Node, start time.Time, end time.Time) ([]*PPXPTransaction, error)
- func GetPPXPTransactionsWithType(node sqalx.Node, txtype string) ([]*PPXPTransaction, error)
- type PairConnection
- type Point
- type Report
- type Script
- type Source
- type Station
- func (station *Station) Closed(node sqalx.Node) (bool, error)
- func (station *Station) Delete(node sqalx.Node) error
- func (station *Station) Directions(node sqalx.Node, withAllServices bool) ([]*Station, error)
- func (station *Station) HasTag(needle string) bool
- func (station *Station) Lines(node sqalx.Node) ([]*Line, error)
- func (station *Station) Lobbies(node sqalx.Node) ([]*Lobby, error)
- func (station *Station) POIs(node sqalx.Node) ([]*POI, error)
- func (station *Station) Update(node sqalx.Node) error
- func (station *Station) WiFiAPs(node sqalx.Node) ([]*WiFiAP, error)
- type StationTags
- type StationUse
- type StationUseType
- type Status
- type StatusMessageType
- type StatusNotification
- type Time
- type Transfer
- type Trip
- func GetTrip(node sqalx.Node, id string) (*Trip, error)
- func GetTrips(node sqalx.Node) ([]*Trip, error)
- func GetTripsForSubmitter(node sqalx.Node, submitter *APIPair) ([]*Trip, error)
- func GetTripsForSubmitterBetween(node sqalx.Node, submitter *APIPair, start time.Time, end time.Time) ([]*Trip, error)
- func (trip *Trip) AverageSpeed(node sqalx.Node) (speed float64, totalDistance int64, totalDuration time.Duration, err error)
- func (trip *Trip) Delete(node sqalx.Node) error
- func (trip *Trip) SimultaneousTripIDs(node sqalx.Node, excludeLongerThan time.Duration) ([]string, error)
- func (trip *Trip) SimultaneousTrips(node sqalx.Node, excludeLongerThan time.Duration) ([]*Trip, error)
- func (trip *Trip) Update(node sqalx.Node) error
- type VehicleETA
- func (eta *VehicleETA) LiveETA() time.Duration
- func (eta *VehicleETA) LiveETAlowerBound() time.Duration
- func (eta *VehicleETA) LiveETAupperBound() time.Duration
- func (eta *VehicleETA) RemainingValidity() time.Duration
- func (eta *VehicleETA) SetETA(d time.Duration)
- func (eta *VehicleETA) SetETALowerBound(d time.Duration)
- func (eta *VehicleETA) SetETAUpperBound(d time.Duration)
- func (eta *VehicleETA) VehicleIDgetLine(node sqalx.Node) (*Line, error)
- func (eta *VehicleETA) VehicleIDgetLineString() (string, error)
- func (eta *VehicleETA) VehicleIDgetNumber() int
- func (eta *VehicleETA) VehicleIDisSpecial() bool
- type VehicleETAType
- type WiFiAP
Constants ¶
This section is empty.
Variables ¶
var Consts = map[string]reflect.Value{ "CommunityReportedCategory": reflect.ValueOf(CommunityReportedCategory), "GoneThrough": reflect.ValueOf(GoneThrough), "Interchange": reflect.ValueOf(Interchange), "MLClosedMessage": reflect.ValueOf(MLClosedMessage), "MLCompositeMessage": reflect.ValueOf(MLCompositeMessage), "MLGenericMessage": reflect.ValueOf(MLGenericMessage), "MLSolvedMessage": reflect.ValueOf(MLSolvedMessage), "MLSpecialServiceMessage": reflect.ValueOf(MLSpecialServiceMessage), "NetworkEntry": reflect.ValueOf(NetworkEntry), "NetworkExit": reflect.ValueOf(NetworkExit), "PassengerIncidentCategory": reflect.ValueOf(PassengerIncidentCategory), "PowerOutageCategory": reflect.ValueOf(PowerOutageCategory), "RawMessage": reflect.ValueOf(RawMessage), "ReportBeginMessage": reflect.ValueOf(ReportBeginMessage), "ReportConfirmMessage": reflect.ValueOf(ReportConfirmMessage), "ReportReconfirmMessage": reflect.ValueOf(ReportReconfirmMessage), "ReportSolvedMessage": reflect.ValueOf(ReportSolvedMessage), "S2LSincorrectDetection": reflect.ValueOf(S2LSincorrectDetection), "SignalFailureCategory": reflect.ValueOf(SignalFailureCategory), "StationAnomalyCategory": reflect.ValueOf(StationAnomalyCategory), "ThirdPartyFaultCategory": reflect.ValueOf(ThirdPartyFaultCategory), "TrainFailureCategory": reflect.ValueOf(TrainFailureCategory), "Visit": reflect.ValueOf(Visit), }
var ErrTimeParse = errors.New(`TimeParseError: should be a string formatted as "15:04:05"`)
ErrTimeParse is returned when time unmarshaling fails
var Functions = map[string]reflect.Value{ "ComputeAPISecretHash": reflect.ValueOf(ComputeAPISecretHash), "CountPPPlayerAchievementsAchieved": reflect.ValueOf(CountPPPlayerAchievementsAchieved), "CountPPPlayers": reflect.ValueOf(CountPPPlayers), "CountPPXPTransactionsWithType": reflect.ValueOf(CountPPXPTransactionsWithType), "CountPairActivationsByDay": reflect.ValueOf(CountPairActivationsByDay), "CountTripsByDay": reflect.ValueOf(CountTripsByDay), "GenerateAPIKey": reflect.ValueOf(GenerateAPIKey), "GenerateAPISecret": reflect.ValueOf(GenerateAPISecret), "GetAutorunScriptsWithType": reflect.ValueOf(GetAutorunScriptsWithType), "GetConnection": reflect.ValueOf(GetConnection), "GetConnections": reflect.ValueOf(GetConnections), "GetDataset": reflect.ValueOf(GetDataset), "GetDatasets": reflect.ValueOf(GetDatasets), "GetDisturbance": reflect.ValueOf(GetDisturbance), "GetDisturbances": reflect.ValueOf(GetDisturbances), "GetDisturbancesBetween": reflect.ValueOf(GetDisturbancesBetween), "GetExit": reflect.ValueOf(GetExit), "GetExits": reflect.ValueOf(GetExits), "GetFeedbacks": reflect.ValueOf(GetFeedbacks), "GetLatestNDisturbances": reflect.ValueOf(GetLatestNDisturbances), "GetLine": reflect.ValueOf(GetLine), "GetLineCondition": reflect.ValueOf(GetLineCondition), "GetLineConditions": reflect.ValueOf(GetLineConditions), "GetLinePaths": reflect.ValueOf(GetLinePaths), "GetLineSchedules": reflect.ValueOf(GetLineSchedules), "GetLines": reflect.ValueOf(GetLines), "GetLobbies": reflect.ValueOf(GetLobbies), "GetLobbiesForStation": reflect.ValueOf(GetLobbiesForStation), "GetLobby": reflect.ValueOf(GetLobby), "GetLobbySchedules": reflect.ValueOf(GetLobbySchedules), "GetNetwork": reflect.ValueOf(GetNetwork), "GetNetworkSchedules": reflect.ValueOf(GetNetworkSchedules), "GetNetworks": reflect.ValueOf(GetNetworks), "GetOngoingDisturbances": reflect.ValueOf(GetOngoingDisturbances), "GetPOI": reflect.ValueOf(GetPOI), "GetPOIs": reflect.ValueOf(GetPOIs), "GetPPAchievement": reflect.ValueOf(GetPPAchievement), "GetPPAchievements": reflect.ValueOf(GetPPAchievements), "GetPPNotificationSetting": reflect.ValueOf(GetPPNotificationSetting), "GetPPPair": reflect.ValueOf(GetPPPair), "GetPPPairForKey": reflect.ValueOf(GetPPPairForKey), "GetPPPairs": reflect.ValueOf(GetPPPairs), "GetPPPlayer": reflect.ValueOf(GetPPPlayer), "GetPPPlayerAchievement": reflect.ValueOf(GetPPPlayerAchievement), "GetPPPlayerAchievements": reflect.ValueOf(GetPPPlayerAchievements), "GetPPPlayers": reflect.ValueOf(GetPPPlayers), "GetPPXPTransaction": reflect.ValueOf(GetPPXPTransaction), "GetPPXPTransactions": reflect.ValueOf(GetPPXPTransactions), "GetPPXPTransactionsBetween": reflect.ValueOf(GetPPXPTransactionsBetween), "GetPPXPTransactionsTotal": reflect.ValueOf(GetPPXPTransactionsTotal), "GetPPXPTransactionsWithType": reflect.ValueOf(GetPPXPTransactionsWithType), "GetPair": reflect.ValueOf(GetPair), "GetPairIfCorrect": reflect.ValueOf(GetPairIfCorrect), "GetScript": reflect.ValueOf(GetScript), "GetScripts": reflect.ValueOf(GetScripts), "GetScriptsWithType": reflect.ValueOf(GetScriptsWithType), "GetSource": reflect.ValueOf(GetSource), "GetSources": reflect.ValueOf(GetSources), "GetStation": reflect.ValueOf(GetStation), "GetStationTags": reflect.ValueOf(GetStationTags), "GetStationUses": reflect.ValueOf(GetStationUses), "GetStations": reflect.ValueOf(GetStations), "GetStatus": reflect.ValueOf(GetStatus), "GetStatuses": reflect.ValueOf(GetStatuses), "GetTransfer": reflect.ValueOf(GetTransfer), "GetTransfers": reflect.ValueOf(GetTransfers), "GetTrip": reflect.ValueOf(GetTrip), "GetTripIDs": reflect.ValueOf(GetTripIDs), "GetTripIDsBetween": reflect.ValueOf(GetTripIDsBetween), "GetTrips": reflect.ValueOf(GetTrips), "GetTripsForSubmitter": reflect.ValueOf(GetTripsForSubmitter), "GetTripsForSubmitterBetween": reflect.ValueOf(GetTripsForSubmitterBetween), "GetWiFiAP": reflect.ValueOf(GetWiFiAP), "GetWiFiAPs": reflect.ValueOf(GetWiFiAPs), "NewAndroidPairRequest": reflect.ValueOf(NewAndroidPairRequest), "NewLineDisturbanceReport": reflect.ValueOf(NewLineDisturbanceReport), "NewLineDisturbanceReportDebug": reflect.ValueOf(NewLineDisturbanceReportDebug), "NewLineDisturbanceReportThroughAPI": reflect.ValueOf(NewLineDisturbanceReportThroughAPI), "NewPair": reflect.ValueOf(NewPair), "PPLeaderboardBetween": reflect.ValueOf(PPLeaderboardBetween), "PosPlayLevelToXP": reflect.ValueOf(PosPlayLevelToXP), "PosPlayPlayerLevel": reflect.ValueOf(PosPlayPlayerLevel), "RegisterPPAchievementStrategy": reflect.ValueOf(RegisterPPAchievementStrategy), "SetPPNotificationSetting": reflect.ValueOf(SetPPNotificationSetting), "UnregisterPPAchievementStrategy": reflect.ValueOf(UnregisterPPAchievementStrategy), }
var NewStatusNotification = make(chan StatusNotification)
NewStatusNotification is a channel where a StatusNotification will be sent whenever a new status/disturbance notification should be issued
var Types = map[string]reflect.Type{ "APIPair": reflect.TypeOf((*APIPair)(nil)).Elem(), "AndroidPairRequest": reflect.TypeOf((*AndroidPairRequest)(nil)).Elem(), "Announcement": reflect.TypeOf((*Announcement)(nil)).Elem(), "AnnouncementStore": reflect.TypeOf((*AnnouncementStore)(nil)).Elem(), "BaseReport": reflect.TypeOf((*BaseReport)(nil)).Elem(), "Connection": reflect.TypeOf((*Connection)(nil)).Elem(), "Dataset": reflect.TypeOf((*Dataset)(nil)).Elem(), "Disturbance": reflect.TypeOf((*Disturbance)(nil)).Elem(), "DisturbanceCategory": reflect.TypeOf((*DisturbanceCategory)(nil)).Elem(), "Duration": reflect.TypeOf((*Duration)(nil)).Elem(), "Exit": reflect.TypeOf((*Exit)(nil)).Elem(), "Feedback": reflect.TypeOf((*Feedback)(nil)).Elem(), "FeedbackType": reflect.TypeOf((*FeedbackType)(nil)).Elem(), "Line": reflect.TypeOf((*Line)(nil)).Elem(), "LineCondition": reflect.TypeOf((*LineCondition)(nil)).Elem(), "LineDisturbanceReport": reflect.TypeOf((*LineDisturbanceReport)(nil)).Elem(), "LinePath": reflect.TypeOf((*LinePath)(nil)).Elem(), "LineSchedule": reflect.TypeOf((*LineSchedule)(nil)).Elem(), "Lobby": reflect.TypeOf((*Lobby)(nil)).Elem(), "LobbySchedule": reflect.TypeOf((*LobbySchedule)(nil)).Elem(), "Network": reflect.TypeOf((*Network)(nil)).Elem(), "NetworkSchedule": reflect.TypeOf((*NetworkSchedule)(nil)).Elem(), "POI": reflect.TypeOf((*POI)(nil)).Elem(), "PPAchievement": reflect.TypeOf((*PPAchievement)(nil)).Elem(), "PPAchievementContext": reflect.TypeOf((*PPAchievementContext)(nil)).Elem(), "PPAchievementStrategy": reflect.TypeOf((*PPAchievementStrategy)(nil)).Elem(), "PPLeaderboardEntry": reflect.TypeOf((*PPLeaderboardEntry)(nil)).Elem(), "PPNotificationSetting": reflect.TypeOf((*PPNotificationSetting)(nil)).Elem(), "PPPair": reflect.TypeOf((*PPPair)(nil)).Elem(), "PPPlayer": reflect.TypeOf((*PPPlayer)(nil)).Elem(), "PPPlayerAchievement": reflect.TypeOf((*PPPlayerAchievement)(nil)).Elem(), "PPXPTransaction": reflect.TypeOf((*PPXPTransaction)(nil)).Elem(), "PairConnection": reflect.TypeOf((*PairConnection)(nil)).Elem(), "Point": reflect.TypeOf((*Point)(nil)).Elem(), "Report": reflect.TypeOf((*Report)(nil)).Elem(), "Script": reflect.TypeOf((*Script)(nil)).Elem(), "Source": reflect.TypeOf((*Source)(nil)).Elem(), "Station": reflect.TypeOf((*Station)(nil)).Elem(), "StationTags": reflect.TypeOf((*StationTags)(nil)).Elem(), "StationUse": reflect.TypeOf((*StationUse)(nil)).Elem(), "StationUseType": reflect.TypeOf((*StationUseType)(nil)).Elem(), "Status": reflect.TypeOf((*Status)(nil)).Elem(), "StatusMessageType": reflect.TypeOf((*StatusMessageType)(nil)).Elem(), "StatusNotification": reflect.TypeOf((*StatusNotification)(nil)).Elem(), "Time": reflect.TypeOf((*Time)(nil)).Elem(), "Transfer": reflect.TypeOf((*Transfer)(nil)).Elem(), "Trip": reflect.TypeOf((*Trip)(nil)).Elem(), "WiFiAP": reflect.TypeOf((*WiFiAP)(nil)).Elem(), }
var Variables = map[string]reflect.Value{ "ErrTimeParse": reflect.ValueOf(&ErrTimeParse), "NewStatusNotification": reflect.ValueOf(&NewStatusNotification), }
Functions ¶
func ComputeAPISecretHash ¶
ComputeAPISecretHash calculates the hash for the specified secret with SHA256 HMAC using the specified key
func CountPPPlayerAchievementsAchieved ¶
CountPPPlayerAchievementsAchieved returns the total of achieved achievements
func CountPPPlayers ¶
CountPPPlayers returns the total number of players
func CountPPXPTransactionsWithType ¶
CountPPXPTransactionsWithType returns the count of transactions with this type
func CountPairActivationsByDay ¶
func CountPairActivationsByDay(node sqalx.Node, start time.Time, end time.Time) ([]time.Time, []int, error)
CountPairActivationsByDay counts APIPair activations by day between the specified dates
func CountTripsByDay ¶
func CountTripsByDay(node sqalx.Node, start time.Time, end time.Time) ([]time.Time, []int, []int, error)
CountTripsByDay counts trips by day between the specified dates
func GenerateAPIKey ¶
func GenerateAPIKey() string
GenerateAPIKey returns a securely randomly generated API key
func GenerateAPISecret ¶
func GenerateAPISecret() string
GenerateAPISecret returns a securely randomly generated API secret
func GetPPNotificationSetting ¶
func GetPPNotificationSetting(node sqalx.Node, discordID uint64, notifType string, method string, defaultValues map[string]map[string]bool) (bool, error)
GetPPNotificationSetting returns the setting for the given parameters
func GetPPXPTransactionsTotal ¶
GetPPXPTransactionsTotal returns the total of XP in the system
func GetTripIDs ¶
GetTripIDs returns a slice containing the IDs of all the trips in the database
func GetTripIDsBetween ¶
GetTripIDsBetween returns a slice containing the IDs of the trips in the specified interval
func PosPlayLevelToXP ¶
PosPlayLevelToXP computes the PosPlay XP necessary to reach the given level
func PosPlayPlayerLevel ¶
PosPlayPlayerLevel computes the PosPlay level and the % of progression to the next level given the XP total
func RegisterPPAchievementStrategy ¶
func RegisterPPAchievementStrategy(s PPAchievementStrategy)
RegisterPPAchievementStrategy makes this package aware of an available achievement strategy All PPAchievements that can be possibly found in the database must have a corresponding strategy
func SetPPNotificationSetting ¶
func SetPPNotificationSetting(node sqalx.Node, discordID uint64, notifType string, method string, enabled bool) error
SetPPNotificationSetting sets the setting for the given parameters
func UnregisterPPAchievementStrategy ¶
func UnregisterPPAchievementStrategy(s PPAchievementStrategy)
UnregisterPPAchievementStrategy makes this package unaware of a PPAchievementStrategy
func VehicleIDLessFunc ¶
func VehicleIDLessFunc(vi, vj *VehicleETA) bool
VehicleIDLessFunc is a function for comparing vehicle ETAs when sorting by vehicle ID
func VehicleIDLessFuncString ¶
VehicleIDLessFuncString is a function for comparing vehicle IDs when sorting
Types ¶
type APIPair ¶
type APIPair struct { Key string // Secret contains the plaintext secret. Only used when the pair is newly created Secret string // SecretHash contains the SHA256-HMAC hash of the secret SecretHash string Type string Activation time.Time }
APIPair contains API auth credentials
func GetPairIfCorrect ¶
func GetPairIfCorrect(node sqalx.Node, key string, givenSecret string, hashKey []byte) (*APIPair, error)
GetPairIfCorrect returns the pair and no errors if the given secret is correct for this API key, and the pair is ready to be used. Otherwise, a nil pointer and a error is returned.
func NewPair ¶
func NewPair(node sqalx.Node, pairtype string, activation time.Time, hashKey []byte) (pair *APIPair, err error)
NewPair creates a new API access pair, stores it in the DB and returns it
func (*APIPair) CheckSecret ¶
CheckSecret returns no errors if the given secret is correct for this API pair
type AndroidPairRequest ¶
type AndroidPairRequest struct { Nonce string RequestTime time.Time AndroidID string IPaddress net.IP }
AndroidPairRequest contains info for a pair request issued by an Android app
func NewAndroidPairRequest ¶
func NewAndroidPairRequest(nonce string, androidID string, ipAddress net.IP) *AndroidPairRequest
NewAndroidPairRequest creates a new AndroidPairRequest and returns it Does NOT store the request in the DB
func (*AndroidPairRequest) CalculateActivationTime ¶
func (request *AndroidPairRequest) CalculateActivationTime(node sqalx.Node, maxTimestampSkew time.Duration) (time.Time, error)
CalculateActivationTime returns the recommended activation time for a API pair issued in response to this request If the returned time is zero, a API pair should not be granted
type Announcement ¶
type Announcement struct { Time time.Time Network *Network Title string Body string ImageURL string URL string Source string }
Announcement contains an announcement for a network
type AnnouncementStore ¶
type AnnouncementStore interface { AllAnnouncements() []*Announcement SourceAnnouncements(source string) []*Announcement }
AnnouncementStore manages announcements for one or more networks
type BaseReport ¶
type BaseReport struct {
// contains filtered or unexported fields
}
BaseReport is the base for user report structs
type Connection ¶
type Connection struct { From *Station To *Station // TypicalWaitingSeconds: time in seconds it usually takes to catch a train at the From station when moving towards To TypicalWaitingSeconds int // TypicalStopSeconds: time in seconds the train usually stops at the From station when moving towards To TypicalStopSeconds int // TypicalSeconds: the time in seconds it usually takes for the train to move from From to To TypicalSeconds int // WorldLength: the physical length of this connection in meters WorldLength int FromPlatform string ToPlatform string // contains filtered or unexported fields }
Connection connects two stations in a single direction
func GetConnection ¶
GetConnection returns the Connection with the given ID
func GetConnections ¶
func GetConnections(node sqalx.Node, closedCompat bool) ([]*Connection, error)
GetConnections returns a slice with all registered connections
func GetConnectionsFrom ¶
GetConnectionsFrom returns the Connections that point out of the given ID
func GetConnectionsFromPlatform ¶
func GetConnectionsFromPlatform(node sqalx.Node, fromPlatform string) ([]*Connection, error)
GetConnectionsFromPlatform returns the Connections that start on the given platform ID
func GetConnectionsTo ¶
GetConnectionsTo returns the Connections that point to the given ID
func GetConnectionsToPlatform ¶
func GetConnectionsToPlatform(node sqalx.Node, toPlatform string) ([]*Connection, error)
GetConnectionsToPlatform returns the Connections that end on the given platform ID
type Dataset ¶
type Dataset struct { Version string Authors pq.StringArray Network *Network }
Dataset is a dataset
func GetDataset ¶
GetDataset returns the Dataset with the given network ID
type Disturbance ¶
type Disturbance struct { ID string Official bool OStartTime time.Time OEndTime time.Time OEnded bool UStartTime time.Time UEndTime time.Time UEnded bool Line *Line Description string Notes string Statuses []*Status }
Disturbance represents a disturbance
func GetDisturbance ¶
func GetDisturbance(node sqalx.Node, id string) (*Disturbance, error)
GetDisturbance returns the Disturbance with the given ID
func GetDisturbances ¶
func GetDisturbances(node sqalx.Node) ([]*Disturbance, error)
GetDisturbances returns a slice with all registered disturbances
func GetDisturbancesBetween ¶
func GetDisturbancesBetween(node sqalx.Node, start time.Time, end time.Time, officialOnly bool) ([]*Disturbance, error)
GetDisturbancesBetween returns a slice with disturbances affecting the specified interval
func GetLatestNDisturbances ¶
func GetLatestNDisturbances(node sqalx.Node, limit uint64) ([]*Disturbance, error)
GetLatestNDisturbances returns up to `limit` most recent disturbances
func GetOngoingDisturbances ¶
func GetOngoingDisturbances(node sqalx.Node) ([]*Disturbance, error)
GetOngoingDisturbances returns a slice with all ongoing disturbances
func (*Disturbance) Categories ¶
func (disturbance *Disturbance) Categories() []DisturbanceCategory
Categories returns the categories for this disturbance
func (*Disturbance) Delete ¶
func (disturbance *Disturbance) Delete(node sqalx.Node) error
Delete deletes the disturbance
func (*Disturbance) LatestStatus ¶
func (disturbance *Disturbance) LatestStatus() *Status
LatestStatus returns the most recent status of this disturbance
type DisturbanceCategory ¶
type DisturbanceCategory string
DisturbanceCategory is a disturbance category
const ( // SignalFailureCategory is attributed to disturbances involving signal failures SignalFailureCategory DisturbanceCategory = "SIGNAL_FAILURE" // TrainFailureCategory is attributed to disturbances involving train failures TrainFailureCategory DisturbanceCategory = "TRAIN_FAILURE" // PowerOutageCategory is attributed to disturbances involving power outages PowerOutageCategory DisturbanceCategory = "POWER_OUTAGE" // ThirdPartyFaultCategory is attributed to disturbances involving 3rd party causes ThirdPartyFaultCategory DisturbanceCategory = "3RD_PARTY_FAULT" // PassengerIncidentCategory is attributed to disturbances involving incidents with passengers PassengerIncidentCategory DisturbanceCategory = "PASSENGER_INCIDENT" // StationAnomalyCategory is attributed to disturbances involving station anomalies StationAnomalyCategory DisturbanceCategory = "STATION_ANOMALY" // CommunityReportedCategory is attributed to disturbances reported by the community CommunityReportedCategory DisturbanceCategory = "COMMUNITY_REPORTED" )
type Duration ¶
Duration wraps a time.Duration with custom methods for serialization
func (*Duration) DecodeMsgpack ¶
DecodeMsgpack implements the msgpack.CustomDecoder interface
func (Duration) EncodeMsgpack ¶
EncodeMsgpack implements the msgpack.CustomEncoder interface
func (Duration) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler
type Exit ¶
Exit is a Lobby exit
type Feedback ¶
type Feedback struct { ID string Submitter *APIPair Time time.Time Type FeedbackType Contents string }
Feedback is a piece of user feedback about the service, like a bug report
func GetFeedback ¶
GetFeedback returns the Feedback with the given ID
func GetFeedbacks ¶
GetFeedbacks returns a slice with all registered feedback
type FeedbackType ¶
type FeedbackType string
FeedbackType corresponds to a type of feedback
const ( // S2LSincorrectDetection is a type of feedback reserved for incorrect detection of stations by the client S2LSincorrectDetection FeedbackType = "s2ls-incorrect-detection" )
type Line ¶
type Line struct { ID string Name string MainLocale string Names map[string]string Color string TypicalCars int Order int Network *Network ExternalID string }
Line is a Network line
func GetLineWithExternalID ¶
GetLineWithExternalID returns the Line with the given external ID
func (*Line) AddStatus ¶
AddStatus associates a new status with this line, and runs the disturbance start/end logic
func (*Line) Availability ¶
func (line *Line) Availability(node sqalx.Node, startTime time.Time, endTime time.Time, officialOnly bool) (availability float64, avgDuration time.Duration, err error)
Availability returns the fraction of time this line operated without issues between the specified times, and the average duration for each disturbance
func (*Line) Conditions ¶
func (line *Line) Conditions(node sqalx.Node) ([]*LineCondition, error)
Conditions returns all the conditions for this line
func (*Line) CountDisturbancesByDay ¶
func (line *Line) CountDisturbancesByDay(node sqalx.Node, start time.Time, end time.Time, officialOnly bool) ([]int, error)
CountDisturbancesByDay counts disturbances by day between the specified dates
func (*Line) CountDisturbancesByHourOfDay ¶
func (line *Line) CountDisturbancesByHourOfDay(node sqalx.Node, start time.Time, end time.Time, officialOnly bool) ([]int, error)
CountDisturbancesByHourOfDay counts disturbances by hour of day between the specified dates
func (*Line) CurrentlyClosed ¶
CurrentlyClosed returns whether this line is closed right now
func (*Line) DisturbanceDuration ¶
func (line *Line) DisturbanceDuration(node sqalx.Node, startTime time.Time, endTime time.Time, officialOnly bool) (totalDuration time.Duration, count int, err error)
DisturbanceDuration returns the total duration of the disturbances in this line between the specified times
func (*Line) DisturbancesBetween ¶
func (line *Line) DisturbancesBetween(node sqalx.Node, startTime time.Time, endTime time.Time, officialOnly bool) ([]*Disturbance, error)
DisturbancesBetween returns a slice with all disturbances that start or end between the specified times
func (*Line) GetDirectionForConnection ¶
func (line *Line) GetDirectionForConnection(node sqalx.Node, connection *Connection) (*Station, error)
GetDirectionForConnection returns the station that is the terminus for this line in the direction of the provided connection. If the connection is not part of this line, an error is returned
func (*Line) LastCondition ¶
func (line *Line) LastCondition(node sqalx.Node) (*LineCondition, error)
LastCondition returns the latest condition for this line
func (*Line) LastDisturbance ¶
LastDisturbance returns the latest disturbance affecting this line
func (*Line) LastOngoingDisturbance ¶
LastOngoingDisturbance returns the latest ongoing disturbance affecting this line
func (*Line) LastStatus ¶
LastStatus returns the latest status for this line
func (*Line) OngoingDisturbances ¶
OngoingDisturbances returns a slice with all ongoing disturbances on this line
func (*Line) Schedules ¶
func (line *Line) Schedules(node sqalx.Node) ([]*LineSchedule, error)
Schedules returns the schedules of this line
type LineCondition ¶
type LineCondition struct { ID string Time time.Time Line *Line TrainCars int TrainFrequency Duration Source *Source }
LineCondition represents the operational condition of a Line at a certain point in time
func GetLineCondition ¶
func GetLineCondition(node sqalx.Node, id string) (*LineCondition, error)
GetLineCondition returns the LineCondition with the given ID
func GetLineConditions ¶
func GetLineConditions(node sqalx.Node) ([]*LineCondition, error)
GetLineConditions returns a slice with all registered line conditions
type LineDisturbanceReport ¶
type LineDisturbanceReport struct { BaseReport // contains filtered or unexported fields }
LineDisturbanceReport is a Report of a disturbance in a line
func NewLineDisturbanceReport ¶
func NewLineDisturbanceReport(ipAddr string, line *Line, category string) *LineDisturbanceReport
NewLineDisturbanceReport creates a new LineDisturbanceReport
func NewLineDisturbanceReportDebug ¶
func NewLineDisturbanceReportDebug(line *Line, category string) *LineDisturbanceReport
NewLineDisturbanceReportDebug creates a test LineDisturbanceReport for debugging
func NewLineDisturbanceReportThroughAPI ¶
func NewLineDisturbanceReportThroughAPI(pair *APIPair, line *Line, category string) *LineDisturbanceReport
NewLineDisturbanceReportThroughAPI creates a new LineDisturbanceReport
func (*LineDisturbanceReport) Category ¶
func (r *LineDisturbanceReport) Category() string
Category returns the category of this report
func (*LineDisturbanceReport) Line ¶
func (r *LineDisturbanceReport) Line() *Line
Line returns the line of this report
func (*LineDisturbanceReport) RateLimiterKey ¶
func (r *LineDisturbanceReport) RateLimiterKey() string
RateLimiterKey returns a string that can be used to identify this report in a rate limiting/duplicate detection system
func (*LineDisturbanceReport) ReplayProtected ¶
func (r *LineDisturbanceReport) ReplayProtected() bool
ReplayProtected returns whether it is hard for the submitter to bypass the replay protections
func (*LineDisturbanceReport) Submitter ¶
func (r *LineDisturbanceReport) Submitter() *APIPair
Submitter returns the APIPair that submitted this report, if any Might be nil if the report was not submitted by an APIPair
func (*LineDisturbanceReport) Time ¶
func (r *LineDisturbanceReport) Time() time.Time
Time returns the creation time of this report
type LinePath ¶
LinePath is a Line path
func GetLinePaths ¶
GetLinePaths returns a slice with all registered paths
type LineSchedule ¶
type LineSchedule struct { Line *Line Holiday bool Day int Open bool OpenTime Time OpenDuration Duration }
LineSchedule is a Line schedule
func GetLineSchedules ¶
func GetLineSchedules(node sqalx.Node) ([]*LineSchedule, error)
GetLineSchedules returns a slice with all registered schedules
func (*LineSchedule) Compare ¶
func (schedule *LineSchedule) Compare(s2 *LineSchedule) bool
Compare checks if two schedules are the same regardless of their day
type Lobby ¶
Lobby is a station lobby
func GetLobbies ¶
GetLobbies returns a slice with all registered lobbies
func GetLobbiesForStation ¶
GetLobbiesForStation returns a slice with the lobbies for the specified station
type LobbySchedule ¶
type LobbySchedule struct { Lobby *Lobby Holiday bool Day int Open bool OpenTime Time OpenDuration Duration }
LobbySchedule is a Lobby schedule
func GetLobbySchedules ¶
func GetLobbySchedules(node sqalx.Node) ([]*LobbySchedule, error)
GetLobbySchedules returns a slice with all registered schedules
func (*LobbySchedule) Compare ¶
func (schedule *LobbySchedule) Compare(s2 *LobbySchedule) bool
Compare checks if two schedules are the same regardless of their day
type Network ¶
type Network struct { ID string Name string MainLocale string Names map[string]string TypicalCars int Holidays []int64 OpenTime Time OpenDuration Duration Timezone string NewsURL string }
Network is a transportation network
func GetNetwork ¶
GetNetwork returns the Line with the given ID
func GetNetworks ¶
GetNetworks returns a slice with all registered networks
func (*Network) CountDisturbancesByHour ¶
func (network *Network) CountDisturbancesByHour(node sqalx.Node, start time.Time, end time.Time) ([]int, error)
CountDisturbancesByHour counts disturbances by hour between the specified dates
func (*Network) LastDisturbance ¶
LastDisturbance returns the latest disturbance affecting this network
func (*Network) LastDisturbanceTime ¶
LastDisturbanceTime returns the end time of the latest disturbance on this network
func (*Network) Schedules ¶
func (network *Network) Schedules(node sqalx.Node) ([]*NetworkSchedule, error)
Schedules returns the schedules of this network
type NetworkSchedule ¶
type NetworkSchedule struct { Network *Network Holiday bool Day int Open bool OpenTime Time OpenDuration Duration }
NetworkSchedule is a Network schedule
func GetNetworkSchedules ¶
func GetNetworkSchedules(node sqalx.Node) ([]*NetworkSchedule, error)
GetNetworkSchedules returns a slice with all registered schedules
func (*NetworkSchedule) Compare ¶
func (schedule *NetworkSchedule) Compare(s2 *NetworkSchedule) bool
Compare checks if two schedules are the same regardless of their day
type POI ¶
type POI struct { ID string Type string WorldCoord [2]float64 URL string MainLocale string Names map[string]string }
POI is a Point of Interest
type PPAchievement ¶
type PPAchievement struct { ID string Strategy PPAchievementStrategy Config string MainLocale string Names map[string]string Descriptions map[string]string Icon string XPReward int }
PPAchievement is a PosPlay achievement
func GetPPAchievement ¶
func GetPPAchievement(node sqalx.Node, id string) (*PPAchievement, error)
GetPPAchievement returns the achievement with the given ID
func GetPPAchievements ¶
func GetPPAchievements(node sqalx.Node) ([]*PPAchievement, error)
GetPPAchievements returns a slice with all registered transactions
func (*PPAchievement) CountAchieved ¶
func (achievement *PPAchievement) CountAchieved(node sqalx.Node) (int, error)
CountAchieved returns the number of players who have achieved this achievement
func (*PPAchievement) Delete ¶
func (achievement *PPAchievement) Delete(node sqalx.Node) error
Delete deletes the PPAchievement
func (*PPAchievement) FirstAchieved ¶
FirstAchieved returns the first time anyone achieved this achievement
func (*PPAchievement) LastAchieved ¶
LastAchieved returns the last time anyone achieved this achievement
func (*PPAchievement) MarshalConfig ¶
func (achievement *PPAchievement) MarshalConfig(v interface{}) error
MarshalConfig encodes the parameter as JSON and places the result in the Config field
func (*PPAchievement) UnmarshalConfig ¶
func (achievement *PPAchievement) UnmarshalConfig(v interface{}) error
UnmarshalConfig decodes the Config field for this transaction as JSON
type PPAchievementContext ¶
type PPAchievementContext struct { Node sqalx.Node Achievement *PPAchievement Player *PPPlayer StrategyOwnCache *sync.Map }
PPAchievementContext contains the context necessary to process an achievement-producing event
type PPAchievementStrategy ¶
type PPAchievementStrategy interface { ID() string HandleTrip(context *PPAchievementContext, trip *Trip) error HandleTripEdit(context *PPAchievementContext, trip *Trip) error HandleDisturbanceReport(context *PPAchievementContext, report *LineDisturbanceReport) error HandleXPTransaction(context *PPAchievementContext, transaction *PPXPTransaction, actualValueDiff int) error Progress(context *PPAchievementContext) (current, total int, err error) ProgressHTML(context *PPAchievementContext) string CriteriaHTML(context *PPAchievementContext) string }
PPAchievementStrategy is a strategy/driver for handing a PosPlay achievement
type PPLeaderboardEntry ¶
PPLeaderboardEntry represents a PosPlay leaderboard entry
type PPNotificationSetting ¶
type PPNotificationSetting struct { DiscordID uint64 NotificationType string Method string Enabled bool }
PPNotificationSetting is a PosPlay notification setting
type PPPair ¶
PPPair is a PosPlay pair
func GetPPPairForKey ¶
GetPPPairForKey returns the pair with the given Discord ID
func GetPPPairs ¶
GetPPPairs returns a slice with all registered pairs
type PPPlayer ¶
type PPPlayer struct { DiscordID uint64 Joined time.Time LBPrivacy string ProfilePrivacy string NameType string InGuild bool CachedName string }
PPPlayer is a PosPlay player
func GetPPPlayer ¶
GetPPPlayer returns the player with the given Discord ID
func GetPPPlayers ¶
GetPPPlayers returns a slice with all registered players
func (*PPPlayer) Achievement ¶
func (player *PPPlayer) Achievement(node sqalx.Node, achievementID string) (*PPPlayerAchievement, error)
Achievement returns the PPPlayerAchievement for this player corresponding to the given achievement ID
func (*PPPlayer) Achievements ¶
func (player *PPPlayer) Achievements(node sqalx.Node) ([]*PPPlayerAchievement, error)
Achievements returns the PPPlayerAchievements for this player (achieved and non-achieved)
func (*PPPlayer) AnonymousName ¶
AnonymousName returns an anonymous fixed name for this player
func (*PPPlayer) CountXPTransactionsWithType ¶
CountXPTransactionsWithType counts the number of transactions for this player with the specified type
func (*PPPlayer) Level ¶
Level returns the user's level, and a % indicating the progression to the next one
func (*PPPlayer) RankBetween ¶
RankBetween returns the global XP rank for this player within the specified time interval
func (*PPPlayer) XPBalanceBetween ¶
XPBalanceBetween returns the total XP for this player within the specified time interval
func (*PPPlayer) XPBalanceWithType ¶
XPBalanceWithType returns the total XP with transactions of specified type
func (*PPPlayer) XPBalanceWithTypeBetween ¶
func (player *PPPlayer) XPBalanceWithTypeBetween(node sqalx.Node, txtype string, start, end time.Time) (int, error)
XPBalanceWithTypeBetween returns the total XP with transactions of specified type within the specified time interval
func (*PPPlayer) XPTransactions ¶
func (player *PPPlayer) XPTransactions(node sqalx.Node) ([]*PPXPTransaction, error)
XPTransactions returns a slice with all registered transactions for this player
func (*PPPlayer) XPTransactionsBetween ¶
func (player *PPPlayer) XPTransactionsBetween(node sqalx.Node, start, end time.Time) ([]*PPXPTransaction, error)
XPTransactionsBetween returns a slice with all registered transactions for this player within the specified interval
func (*PPPlayer) XPTransactionsCustomFilter ¶
func (player *PPPlayer) XPTransactionsCustomFilter(node sqalx.Node, preds ...interface{}) ([]*PPXPTransaction, error)
XPTransactionsCustomFilter returns a slice with the transactions for this player matching a custom filter
func (*PPPlayer) XPTransactionsLimit ¶
func (player *PPPlayer) XPTransactionsLimit(node sqalx.Node, limit uint64) ([]*PPXPTransaction, error)
XPTransactionsLimit returns a slice with `limit` most recent transactions for this player
func (*PPPlayer) XPTransactionsWithType ¶
func (player *PPPlayer) XPTransactionsWithType(node sqalx.Node, txtype string) ([]*PPXPTransaction, error)
XPTransactionsWithType returns a slice with the transactions for this player of the specified type
type PPPlayerAchievement ¶
type PPPlayerAchievement struct { DiscordID uint64 Achievement *PPAchievement AchievedTime time.Time Achieved bool Extra string }
PPPlayerAchievement contains data about a PosPlay achievement for one user
func GetPPPlayerAchievement ¶
func GetPPPlayerAchievement(node sqalx.Node, discordID uint64, achievementID string) (*PPPlayerAchievement, error)
GetPPPlayerAchievement returns the achievement with the given ID
func GetPPPlayerAchievements ¶
func GetPPPlayerAchievements(node sqalx.Node) ([]*PPPlayerAchievement, error)
GetPPPlayerAchievements returns a slice with all registered transactions
func (*PPPlayerAchievement) Delete ¶
func (achievement *PPPlayerAchievement) Delete(node sqalx.Node) error
Delete deletes the PPPlayerAchievement
func (*PPPlayerAchievement) MarshalExtra ¶
func (achievement *PPPlayerAchievement) MarshalExtra(v interface{}) error
MarshalExtra encodes the parameter as JSON and places the result in the Extra field
func (*PPPlayerAchievement) UnmarshalExtra ¶
func (achievement *PPPlayerAchievement) UnmarshalExtra(v interface{}) error
UnmarshalExtra decodes the Extra field for this transaction as JSON
type PPXPTransaction ¶
type PPXPTransaction struct { ID string DiscordID uint64 Time time.Time Value int Type string Extra string }
PPXPTransaction is a PosPlay XP transaction
func GetPPXPTransaction ¶
func GetPPXPTransaction(node sqalx.Node, id string) (*PPXPTransaction, error)
GetPPXPTransaction returns the transaction with the given ID
func GetPPXPTransactions ¶
func GetPPXPTransactions(node sqalx.Node) ([]*PPXPTransaction, error)
GetPPXPTransactions returns a slice with all registered transactions
func GetPPXPTransactionsBetween ¶
func GetPPXPTransactionsBetween(node sqalx.Node, start time.Time, end time.Time) ([]*PPXPTransaction, error)
GetPPXPTransactionsBetween returns a slice with all transactions within the specified interval
func GetPPXPTransactionsWithType ¶
func GetPPXPTransactionsWithType(node sqalx.Node, txtype string) ([]*PPXPTransaction, error)
GetPPXPTransactionsWithType returns a slice with all transactions with the specified type
func (*PPXPTransaction) Delete ¶
func (transaction *PPXPTransaction) Delete(node sqalx.Node) error
Delete deletes the PPXPTransaction
func (*PPXPTransaction) MarshalExtra ¶
func (transaction *PPXPTransaction) MarshalExtra(f map[string]interface{})
MarshalExtra encodes the parameter as JSON and places the result in the Extra field
func (*PPXPTransaction) UnmarshalExtra ¶
func (transaction *PPXPTransaction) UnmarshalExtra() map[string]interface{}
UnmarshalExtra decodes the Extra field for this transaction as JSON
type PairConnection ¶
PairConnection represents a APIPair connection with an external service
type Point ¶
type Point [2]float64
Point represents bidimentional coordinates (such as GPS coordinates as used by Google Maps)
type Report ¶
type Report interface { Submitter() *APIPair // might be nil RateLimiterKey() string ReplayProtected() bool // whether it is hard for the submitter to bypass the replay protections Time() time.Time }
Report is a user report
type Script ¶
Script contains dynamic behavior for the system to implement at run time
func GetAutorunScriptsWithType ¶
func GetAutorunScriptsWithType(node sqalx.Node, scriptType string, autorunLevel int) ([]*Script, error)
GetAutorunScriptsWithType returns a slice with all registered Scripts with the given type and specified autorun level
func GetScripts ¶
GetScripts returns a slice with all registered Scripts
func GetScriptsWithType ¶
GetScriptsWithType returns a slice with all registered Scripts with the given type
type Source ¶
Source represents a Status source
func GetSources ¶
GetSources returns a slice with all registered sources
type Station ¶
type Station struct { ID string Name string AltNames []string Tags []string LowTags []string Network *Network }
Station is a Network station
func GetStation ¶
GetStation returns the Station with the given ID
func GetStations ¶
GetStations returns a slice with all registered stations
func (*Station) Directions ¶
Directions returns the directions (stations at an end of a line) that can be reached directly from this station (i.e. without additional line changes)
type StationTags ¶
StationTags contains station tags
func GetStationTags ¶
func GetStationTags(node sqalx.Node) ([]*StationTags, error)
GetStationTags returns a slice with all registered tags
type StationUse ¶
type StationUse struct { Station *Station EntryTime time.Time LeaveTime time.Time Type StationUseType Manual bool SourceLine *Line TargetLine *Line }
StationUse represents the stationUse of a Line at a certain point in time
func GetStationUses ¶
func GetStationUses(node sqalx.Node) ([]*StationUse, error)
GetStationUses returns a slice with all registered stationUses
type StationUseType ¶
type StationUseType string
StationUseType corresponds to a type of station use (i.e. "how" the station was used)
const ( // NetworkEntry is a type of station use reserved for the first station in a trip NetworkEntry StationUseType = "NETWORK_ENTRY" // NetworkExit is a type of station use reserved for the last station in a trip NetworkExit StationUseType = "NETWORK_EXIT" // Interchange is a type of station use reserved for a line change in a trip Interchange StationUseType = "INTERCHANGE" // GoneThrough is a type of station use reserved for when an user simply goes through a station on his way to somewhere GoneThrough StationUseType = "GONE_THROUGH" // Visit is a type of station use reserved for trips with a single station use Visit StationUseType = "VISIT" )
type Status ¶
type Status struct { ID string Time time.Time Line *Line IsDowntime bool Status string Source *Source MsgType StatusMessageType }
Status represents the status of a Line at a certain point in time
func GetStatuses ¶
GetStatuses returns a slice with all registered statuses
func (*Status) ComputeMsgType ¶
func (status *Status) ComputeMsgType()
ComputeMsgType analyses the status message to assign the correct MsgType
type StatusMessageType ¶
type StatusMessageType string
StatusMessageType indicates the type of the status message (to help with e.g. translation and disturbance categorization)
const ( // RawMessage is an untranslatable message RawMessage StatusMessageType = "RAW" // ReportBeginMessage is the message for when users begin reporting disturbances ReportBeginMessage StatusMessageType = "REPORT_BEGIN" // ReportConfirmMessage is the message for when users confirm disturbance reports ReportConfirmMessage StatusMessageType = "REPORT_CONFIRM" // ReportReconfirmMessage is the message for when users confirm disturbance reports shortly after a disturbance ended ReportReconfirmMessage StatusMessageType = "REPORT_RECONFIRM" // ReportSolvedMessage is the message for when reports of disturbances are gone ReportSolvedMessage StatusMessageType = "REPORT_SOLVED" // MLGenericMessage corresponds to the format "existem perturbações na circulação. O tempo de espera pode ser superior ao normal. Pedimos desculpa pelo incómodo causado" MLGenericMessage StatusMessageType = "ML_GENERIC" // MLSolvedMessage corresponds to the format "Circulação normal" MLSolvedMessage StatusMessageType = "ML_SOLVED" // MLClosedMessage corresponds to the format "Serviço encerrado" MLClosedMessage StatusMessageType = "ML_CLOSED" // MLSpecialServiceMessage corresponds to the format "Serviço especial$1" (only observed $1 so far is " de passagem de ano") MLSpecialServiceMessage StatusMessageType = "ML_SPECIAL" // MLCompositeMessage corresponds to the format: // "[d|D]evido a $1$2$3" // $1 may be one of: // - "avaria na sinalização" (SIGNAL) // - "avaria de comboio" (TRAIN) // - "falha de energia" (POWER) // - "causa alheia ao Metro" (3RDPARTY) // - "incidente com passageiro" (PASSENGER) // - "anomalia na estação" (STATION) // $2 may be one of: // - ", a circulação está interrompida desde as XX:XX." (SINCE) // - " está interrompida a circulação." (HALTED) // - " está interrompida a circulação na linha entre as estações YYY e ZZZ." (BETWEEN) // - ", a circulação encontra-se com perturbações." (DELAYED) // $3 may be one of: // - " Não é possível prever a duração da interrupção, que poderá ser prolongada. Pedimos desculpa pelo incómodo causado" (LONGHALT, typically used with HALTED and BETWEEN) // - " O tempo de espera pode ser superior ao normal. Pedimos desculpa pelo incómodo" (LONGWAIT, typically used with DELAYED) // - " Esperamos retomar a circulação dentro de instantes" (SOON, typically used with SINCE) // - " Esperamos retomar a circulação num período inferior a 15 minutos. Pedimos desculpa pelo incómodo" (UNDER15, typically used with SINCE) // - " O tempo de reposição poderá ser superior a 15 minutos. Pedimos desculpa pelo incómodo" (OVER15, typically used with SINCE) MLCompositeMessage StatusMessageType = "ML_%s_%s_%s" )
type StatusNotification ¶
type StatusNotification struct { Disturbance *Disturbance Status *Status }
StatusNotification contains the information needed to issue a disturbance notification
type Time ¶
Time wraps a time.Time with custom methods for serialization
func (*Time) DecodeMsgpack ¶
DecodeMsgpack implements the msgpack.CustomDecoder interface
func (Time) EncodeMsgpack ¶
EncodeMsgpack implements the msgpack.CustomEncoder interface
func (Time) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (*Time) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler
type Transfer ¶
Transfer represents a crossing between two lines at a station
func GetTransfer ¶
GetTransfer returns the Transfer with the given ID
func GetTransfers ¶
GetTransfers returns a slice with all registered transfers
type Trip ¶
type Trip struct { ID string StartTime time.Time EndTime time.Time Submitter *APIPair SubmitTime time.Time EditTime time.Time Edited bool UserConfirmed bool StationUses []*StationUse }
Trip represents a user-submitted subway trip
func GetTripsForSubmitter ¶
GetTripsForSubmitter returns a slice with all trips submitted by the specified submitter
func GetTripsForSubmitterBetween ¶
func GetTripsForSubmitterBetween(node sqalx.Node, submitter *APIPair, start time.Time, end time.Time) ([]*Trip, error)
GetTripsForSubmitterBetween returns a slice with trips submitted by the specified submitter made in the specified interval
func (*Trip) AverageSpeed ¶
func (trip *Trip) AverageSpeed(node sqalx.Node) (speed float64, totalDistance int64, totalDuration time.Duration, err error)
AverageSpeed computes the average speed (km/h), total distance (m) and total duration of this trip
func (*Trip) SimultaneousTripIDs ¶
func (trip *Trip) SimultaneousTripIDs(node sqalx.Node, excludeLongerThan time.Duration) ([]string, error)
SimultaneousTripIDs returns a slice containing IDs of the trips that took place alongside this one
type VehicleETA ¶
type VehicleETA struct { Station *Station Direction *Station ArrivalOrder int // 0 is N/A, 1 is the next vehicle, 2 is the vehicle after the next one, etc. TransportUnits int // number of train cars or equivalent. 0 is unknown or N/A VehicleServiceID string Platform string Computed time.Time ValidFor time.Duration Type VehicleETAType // the following fields are (un)used depending on Type AbsoluteETA time.Time Precision time.Duration // contains filtered or unexported fields }
VehicleETA defines the estimated arrival time at Station for a vehicle going in Direction
func (*VehicleETA) LiveETA ¶
func (eta *VehicleETA) LiveETA() time.Duration
LiveETA returns an adjusted ETA based on how much time elapsed since this ETA was computed/received
func (*VehicleETA) LiveETAlowerBound ¶
func (eta *VehicleETA) LiveETAlowerBound() time.Duration
LiveETAlowerBound returns an adjusted ETAlowerBound based on how much time elapsed since this ETA was computed/received
func (*VehicleETA) LiveETAupperBound ¶
func (eta *VehicleETA) LiveETAupperBound() time.Duration
LiveETAupperBound returns an adjusted ETAupperBound based on how much time elapsed since this ETA was computed/received
func (*VehicleETA) RemainingValidity ¶
func (eta *VehicleETA) RemainingValidity() time.Duration
RemainingValidity returns an adjusted ValidFor based on how much time elapsed since this ETA was computed/received
func (*VehicleETA) SetETA ¶
func (eta *VehicleETA) SetETA(d time.Duration)
SetETA sets the eta field and automatically sets the Type to RelativeExact
func (*VehicleETA) SetETALowerBound ¶
func (eta *VehicleETA) SetETALowerBound(d time.Duration)
SetETALowerBound sets the etaLowerBound field
func (*VehicleETA) SetETAUpperBound ¶
func (eta *VehicleETA) SetETAUpperBound(d time.Duration)
SetETAUpperBound sets the etaUpperBound field
func (*VehicleETA) VehicleIDgetLine ¶
func (eta *VehicleETA) VehicleIDgetLine(node sqalx.Node) (*Line, error)
VehicleIDgetLine returns the service line of the vehicle for this ETA
func (*VehicleETA) VehicleIDgetLineString ¶
func (eta *VehicleETA) VehicleIDgetLineString() (string, error)
VehicleIDgetLineString returns the service line of the vehicle for this ETA
func (*VehicleETA) VehicleIDgetNumber ¶
func (eta *VehicleETA) VehicleIDgetNumber() int
VehicleIDgetNumber returns the service number of the vehicle for this ETA
func (*VehicleETA) VehicleIDisSpecial ¶
func (eta *VehicleETA) VehicleIDisSpecial() bool
VehicleIDisSpecial returns whether the vehicle ID of this ETA corresponds to a special service
type VehicleETAType ¶
type VehicleETAType int
VehicleETAType is a type of VehicleETA
const ( // Absolute is an ETA with a defined absolute time (e.g. for scheduled vehicles, like a train arriving at 22:43 on September 9 2020...) Absolute VehicleETAType = iota // RelativeExact is a relative ETA that is exact and known (e.g. the next bus will arrive in 5 minutes) RelativeExact // RelativeRange is a relative ETA that has a lower and upper bound (e.g. the bus will arrive within 3 to 6 minutes) RelativeRange // RelativeMinimum is a relative ETA that has a lower bound and no upper bound (e.g. the train will not arrive within the next hour) RelativeMinimum // RelativeMaximum is a relative ETA that has an upper bound only (e.g. the train will arrive within 10 minutes - but it could arrive much sooner) RelativeMaximum )
type WiFiAP ¶
WiFiAP is a WiFi access point
func GetWiFiAPs ¶
GetWiFiAPs returns a slice with all registered wiFiAPs
Source Files
¶
- androidpairrequest.go
- announcement.go
- apipair.go
- connection.go
- dataobjects.go
- dataset.go
- disturbance.go
- exit.go
- feedback.go
- line.go
- linecondition.go
- linepath.go
- lineschedule.go
- lobby.go
- lobbyschedule.go
- network.go
- networkschedule.go
- pairconnection.go
- pkgreflect.go
- poi.go
- posplay.go
- pp_achievement.go
- pp_notification_setting.go
- pp_pair.go
- pp_player.go
- pp_player_achievement.go
- pp_xp_tx.go
- randgen.go
- report.go
- script.go
- source.go
- station.go
- stationtags.go
- stationuse.go
- status.go
- transfer.go
- trip.go
- vehicleeta.go
- wifiap.go