types

package
v0.0.0-...-30a0ae6 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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),
}
View Source
var ErrTimeParse = errors.New(`TimeParseError: should be a string formatted as "15:04:05"`)

ErrTimeParse is returned when time unmarshaling fails

View Source
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),
}
View Source
var NewStatusNotification = make(chan StatusNotification)

NewStatusNotification is a channel where a StatusNotification will be sent whenever a new status/disturbance notification should be issued

View Source
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(),
}
View Source
var Variables = map[string]reflect.Value{
	"ErrTimeParse":          reflect.ValueOf(&ErrTimeParse),
	"NewStatusNotification": reflect.ValueOf(&NewStatusNotification),
}

Functions

func ComputeAPISecretHash

func ComputeAPISecretHash(secret string, key []byte) string

ComputeAPISecretHash calculates the hash for the specified secret with SHA256 HMAC using the specified key

func CountPPPlayerAchievementsAchieved

func CountPPPlayerAchievementsAchieved(node sqalx.Node) (int, error)

CountPPPlayerAchievementsAchieved returns the total of achieved achievements

func CountPPPlayers

func CountPPPlayers(node sqalx.Node) (int, error)

CountPPPlayers returns the total number of players

func CountPPXPTransactionsWithType

func CountPPXPTransactionsWithType(node sqalx.Node, txtype string) (int, error)

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

func GetPPXPTransactionsTotal(node sqalx.Node) (int, error)

GetPPXPTransactionsTotal returns the total of XP in the system

func GetTripIDs

func GetTripIDs(node sqalx.Node) ([]string, error)

GetTripIDs returns a slice containing the IDs of all the trips in the database

func GetTripIDsBetween

func GetTripIDsBetween(node sqalx.Node, start time.Time, end time.Time) ([]string, error)

GetTripIDsBetween returns a slice containing the IDs of the trips in the specified interval

func PosPlayLevelToXP

func PosPlayLevelToXP(level int) int

PosPlayLevelToXP computes the PosPlay XP necessary to reach the given level

func PosPlayPlayerLevel

func PosPlayPlayerLevel(totalXP int) (int, float64)

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

func VehicleIDLessFuncString(vi, vj string) bool

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 GetPair

func GetPair(node sqalx.Node, key string) (*APIPair, error)

GetPair returns the API pair with the given ID

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) Activated

func (pair *APIPair) Activated() bool

Activated returns whether this pair is activated

func (*APIPair) CheckSecret

func (pair *APIPair) CheckSecret(givenSecret string, hashKey []byte) (err error)

CheckSecret returns no errors if the given secret is correct for this API pair

func (*APIPair) Delete

func (pair *APIPair) Delete(node sqalx.Node) error

Delete deletes the 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

func (*AndroidPairRequest) Store

func (request *AndroidPairRequest) Store(node sqalx.Node) error

Store stores this request in the DB To be used if the request is successful (i.e. the client was sent a API pair)

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

func GetConnection(node sqalx.Node, from string, to string, closedCompat bool) (*Connection, error)

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

func GetConnectionsFrom(node sqalx.Node, from string, closedCompat bool) ([]*Connection, error)

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

func GetConnectionsTo(node sqalx.Node, to string, closedCompat bool) ([]*Connection, error)

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

func (*Connection) Delete

func (connection *Connection) Delete(node sqalx.Node) error

Delete deletes the connection

func (*Connection) Update

func (connection *Connection) Update(node sqalx.Node) error

Update adds or updates the connection

type Dataset

type Dataset struct {
	Version string
	Authors pq.StringArray
	Network *Network
}

Dataset is a dataset

func GetDataset

func GetDataset(node sqalx.Node, networkID string) (*Dataset, error)

GetDataset returns the Dataset with the given network ID

func GetDatasets

func GetDatasets(node sqalx.Node) ([]*Dataset, error)

GetDatasets returns a slice with all registered Datasets

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

func (*Disturbance) Update

func (disturbance *Disturbance) Update(node sqalx.Node) error

Update adds or updates the 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

type Duration time.Duration

Duration wraps a time.Duration with custom methods for serialization

func (*Duration) DecodeMsgpack

func (d *Duration) DecodeMsgpack(dec *msgpack.Decoder) error

DecodeMsgpack implements the msgpack.CustomDecoder interface

func (Duration) EncodeMsgpack

func (d Duration) EncodeMsgpack(enc *msgpack.Encoder) error

EncodeMsgpack implements the msgpack.CustomEncoder interface

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (*Duration) Scan

func (d *Duration) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler

func (Duration) Value

func (d Duration) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type Exit

type Exit struct {
	ID         int
	WorldCoord [2]float64
	Streets    []string
	Type       string
	Lobby      *Lobby
}

Exit is a Lobby exit

func GetExit

func GetExit(node sqalx.Node, id int) (*Exit, error)

GetExit returns the Exit with the given ID

func GetExits

func GetExits(node sqalx.Node) ([]*Exit, error)

GetExits returns a slice with all registered exits

func (*Exit) Add

func (exit *Exit) Add(node sqalx.Node) error

Add adds the exit

func (*Exit) Delete

func (exit *Exit) Delete(node sqalx.Node) error

Delete deletes the 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

func GetFeedback(node sqalx.Node, id string) (*Feedback, error)

GetFeedback returns the Feedback with the given ID

func GetFeedbacks

func GetFeedbacks(node sqalx.Node) ([]*Feedback, error)

GetFeedbacks returns a slice with all registered feedback

func (*Feedback) Delete

func (feedback *Feedback) Delete(node sqalx.Node) error

Delete deletes the feedback

func (*Feedback) Update

func (feedback *Feedback) Update(node sqalx.Node) error

Update adds or updates the 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 GetLine

func GetLine(node sqalx.Node, id string) (*Line, error)

GetLine returns the Line with the given ID

func GetLineWithExternalID

func GetLineWithExternalID(node sqalx.Node, id string) (*Line, error)

GetLineWithExternalID returns the Line with the given external ID

func GetLines

func GetLines(node sqalx.Node) ([]*Line, error)

GetLines returns a slice with all registered lines

func (*Line) AddStatus

func (line *Line) AddStatus(node sqalx.Node, status *Status, letNotify bool) error

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

func (line *Line) CurrentlyClosed(tx sqalx.Node) (bool, error)

CurrentlyClosed returns whether this line is closed right now

func (*Line) Delete

func (line *Line) Delete(node sqalx.Node) error

Delete deletes the line

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

func (line *Line) LastDisturbance(node sqalx.Node, officialOnly bool) (*Disturbance, error)

LastDisturbance returns the latest disturbance affecting this line

func (*Line) LastOngoingDisturbance

func (line *Line) LastOngoingDisturbance(node sqalx.Node, officialOnly bool) (*Disturbance, error)

LastOngoingDisturbance returns the latest ongoing disturbance affecting this line

func (*Line) LastStatus

func (line *Line) LastStatus(node sqalx.Node) (*Status, error)

LastStatus returns the latest status for this line

func (*Line) OngoingDisturbances

func (line *Line) OngoingDisturbances(node sqalx.Node, officialOnly bool) ([]*Disturbance, error)

OngoingDisturbances returns a slice with all ongoing disturbances on this line

func (*Line) Paths

func (line *Line) Paths(node sqalx.Node) ([]*LinePath, error)

Paths returns the paths of this line

func (*Line) Schedules

func (line *Line) Schedules(node sqalx.Node) ([]*LineSchedule, error)

Schedules returns the schedules of this line

func (*Line) Stations

func (line *Line) Stations(node sqalx.Node) ([]*Station, error)

Stations returns the stations that are served by this line

func (*Line) Statuses

func (line *Line) Statuses(node sqalx.Node) ([]*Status, error)

Statuses returns all the statuses for this line

func (*Line) Update

func (line *Line) Update(node sqalx.Node) error

Update adds or updates the 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

func (*LineCondition) Delete

func (condition *LineCondition) Delete(node sqalx.Node) error

Delete deletes the LineCondition

func (*LineCondition) Update

func (condition *LineCondition) Update(node sqalx.Node) error

Update adds or updates the LineCondition

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

type LinePath struct {
	Line *Line
	ID   string
	Path pgtype.Path
}

LinePath is a Line path

func GetLinePaths

func GetLinePaths(node sqalx.Node) ([]*LinePath, error)

GetLinePaths returns a slice with all registered paths

func (*LinePath) Delete

func (path *LinePath) Delete(node sqalx.Node) error

Delete deletes the path

func (*LinePath) Update

func (path *LinePath) Update(node sqalx.Node) error

Update adds or updates the path

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

func (*LineSchedule) Delete

func (schedule *LineSchedule) Delete(node sqalx.Node) error

Delete deletes the schedule

func (*LineSchedule) Update

func (schedule *LineSchedule) Update(node sqalx.Node) error

Update adds or updates the schedule

type Lobby

type Lobby struct {
	ID      string
	Name    string
	Station *Station
}

Lobby is a station lobby

func GetLobbies

func GetLobbies(node sqalx.Node) ([]*Lobby, error)

GetLobbies returns a slice with all registered lobbies

func GetLobbiesForStation

func GetLobbiesForStation(node sqalx.Node, id string) ([]*Lobby, error)

GetLobbiesForStation returns a slice with the lobbies for the specified station

func GetLobby

func GetLobby(node sqalx.Node, id string) (*Lobby, error)

GetLobby returns the lobby with the given ID

func (*Lobby) Closed

func (lobby *Lobby) Closed(node sqalx.Node) (bool, error)

Closed returns whether this lobby is closed

func (*Lobby) Delete

func (lobby *Lobby) Delete(node sqalx.Node) error

Delete deletes the Lobby

func (*Lobby) Exits

func (lobby *Lobby) Exits(node sqalx.Node) ([]*Exit, error)

Exits returns the exits of this lobby

func (*Lobby) Schedules

func (lobby *Lobby) Schedules(node sqalx.Node) ([]*LobbySchedule, error)

Schedules returns the schedules of this lobby

func (*Lobby) Update

func (lobby *Lobby) Update(node sqalx.Node) error

Update adds or updates the Lobby

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

func (*LobbySchedule) Delete

func (schedule *LobbySchedule) Delete(node sqalx.Node) error

Delete deletes the schedule

func (*LobbySchedule) Update

func (schedule *LobbySchedule) Update(node sqalx.Node) error

Update adds or updates the schedule

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

func GetNetwork(node sqalx.Node, id string) (*Network, error)

GetNetwork returns the Line with the given ID

func GetNetworks

func GetNetworks(node sqalx.Node) ([]*Network, error)

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) Delete

func (network *Network) Delete(node sqalx.Node) error

Delete deletes the network

func (*Network) LastDisturbance

func (network *Network) LastDisturbance(node sqalx.Node, officialOnly bool) (*Disturbance, error)

LastDisturbance returns the latest disturbance affecting this network

func (*Network) LastDisturbanceTime

func (network *Network) LastDisturbanceTime(node sqalx.Node, officialOnly bool) (time.Time, error)

LastDisturbanceTime returns the end time of the latest disturbance on this network

func (*Network) Lines

func (network *Network) Lines(node sqalx.Node) ([]*Line, error)

Lines returns the lines in this network

func (*Network) Schedules

func (network *Network) Schedules(node sqalx.Node) ([]*NetworkSchedule, error)

Schedules returns the schedules of this network

func (*Network) Stations

func (network *Network) Stations(node sqalx.Node) ([]*Station, error)

Stations returns the stations in this network

func (*Network) Update

func (network *Network) Update(node sqalx.Node) error

Update adds or updates the 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

func (*NetworkSchedule) Delete

func (schedule *NetworkSchedule) Delete(node sqalx.Node) error

Delete deletes the schedule

func (*NetworkSchedule) Update

func (schedule *NetworkSchedule) Update(node sqalx.Node) error

Update adds or updates the schedule

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

func GetPOI

func GetPOI(node sqalx.Node, id string) (*POI, error)

GetPOI returns the POI with the given ID

func GetPOIs

func GetPOIs(node sqalx.Node) ([]*POI, error)

GetPOIs returns a slice with all registered POIs

func (*POI) Stations

func (poi *POI) Stations(node sqalx.Node) ([]*Station, error)

Stations returns the stations this POI is associated with

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

func (achievement *PPAchievement) FirstAchieved(node sqalx.Node) (time.Time, error)

FirstAchieved returns the first time anyone achieved this achievement

func (*PPAchievement) LastAchieved

func (achievement *PPAchievement) LastAchieved(node sqalx.Node) (time.Time, error)

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

func (*PPAchievement) Update

func (achievement *PPAchievement) Update(node sqalx.Node) error

Update adds or updates the PPAchievement. Does not supporting updating names, descriptions or MainLocale

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

type PPLeaderboardEntry struct {
	RowNum   int
	Position int
	Player   *PPPlayer
	Score    int
}

PPLeaderboardEntry represents a PosPlay leaderboard entry

func PPLeaderboardBetween

func PPLeaderboardBetween(node sqalx.Node, start, end time.Time, size int, showNeighbors int, mustIncludes ...*PPPlayer) ([]PPLeaderboardEntry, error)

PPLeaderboardBetween returns the PosPlay leaderboard for the specified period

type PPNotificationSetting

type PPNotificationSetting struct {
	DiscordID        uint64
	NotificationType string
	Method           string
	Enabled          bool
}

PPNotificationSetting is a PosPlay notification setting

func (*PPNotificationSetting) Delete

func (setting *PPNotificationSetting) Delete(node sqalx.Node) error

Delete deletes the PPNotificationSetting

func (*PPNotificationSetting) Update

func (setting *PPNotificationSetting) Update(node sqalx.Node) error

Update adds or updates the PPNotificationSetting

type PPPair

type PPPair struct {
	DiscordID  uint64
	Pair       *APIPair
	Paired     time.Time
	DeviceName string
}

PPPair is a PosPlay pair

func GetPPPair

func GetPPPair(node sqalx.Node, discordID uint64) (*PPPair, error)

GetPPPair returns the pair with the given Discord ID

func GetPPPairForKey

func GetPPPairForKey(node sqalx.Node, apiKey string) (*PPPair, error)

GetPPPairForKey returns the pair with the given Discord ID

func GetPPPairs

func GetPPPairs(node sqalx.Node) ([]*PPPair, error)

GetPPPairs returns a slice with all registered pairs

func (*PPPair) Delete

func (pair *PPPair) Delete(node sqalx.Node) error

Delete deletes the PPPair

func (*PPPair) Update

func (pair *PPPair) Update(node sqalx.Node) error

Update adds or updates the PPPair

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

func GetPPPlayer(node sqalx.Node, discordID uint64) (*PPPlayer, error)

GetPPPlayer returns the player with the given Discord ID

func GetPPPlayers

func GetPPPlayers(node sqalx.Node) ([]*PPPlayer, error)

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

func (player *PPPlayer) AnonymousName() string

AnonymousName returns an anonymous fixed name for this player

func (*PPPlayer) CountXPTransactionsWithType

func (player *PPPlayer) CountXPTransactionsWithType(node sqalx.Node, txtype string) (int, error)

CountXPTransactionsWithType counts the number of transactions for this player with the specified type

func (*PPPlayer) Delete

func (player *PPPlayer) Delete(node sqalx.Node) error

Delete deletes the PPPlayer

func (*PPPlayer) Level

func (player *PPPlayer) Level(node sqalx.Node) (int, int, float64, error)

Level returns the user's level, and a % indicating the progression to the next one

func (*PPPlayer) RankBetween

func (player *PPPlayer) RankBetween(node sqalx.Node, start, end time.Time) (int, error)

RankBetween returns the global XP rank for this player within the specified time interval

func (*PPPlayer) Seed

func (player *PPPlayer) Seed() uint64

Seed returns an unique ID for this user that is not his Discord ID

func (*PPPlayer) Update

func (player *PPPlayer) Update(node sqalx.Node) error

Update adds or updates the PPPlayer

func (*PPPlayer) XPBalance

func (player *PPPlayer) XPBalance(node sqalx.Node) (int, error)

XPBalance returns the total XP for this player

func (*PPPlayer) XPBalanceBetween

func (player *PPPlayer) XPBalanceBetween(node sqalx.Node, start, end time.Time) (int, error)

XPBalanceBetween returns the total XP for this player within the specified time interval

func (*PPPlayer) XPBalanceWithType

func (player *PPPlayer) XPBalanceWithType(node sqalx.Node, txtype string) (int, error)

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

func (*PPPlayerAchievement) Update

func (achievement *PPPlayerAchievement) Update(node sqalx.Node) error

Update adds or updates the PPPlayerAchievement

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

func (*PPXPTransaction) Update

func (transaction *PPXPTransaction) Update(node sqalx.Node) error

Update adds or updates the PPXPTransaction

type PairConnection

type PairConnection interface {
	Pair() *APIPair
	Created() time.Time
	Extra() interface{}
}

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)

func (*Point) Scan

func (p *Point) Scan(val interface{}) error

Scan implements the sql.Scanner interface

func (Point) Value

func (p Point) Value() (driver.Value, error)

Value implements the driver.Value interface

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

type Script struct {
	ID      string
	Type    string
	Autorun int
	Code    string
	Notes   string
}

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 GetScript

func GetScript(node sqalx.Node, id string) (*Script, error)

GetScript returns the Script with the given ID

func GetScripts

func GetScripts(node sqalx.Node) ([]*Script, error)

GetScripts returns a slice with all registered Scripts

func GetScriptsWithType

func GetScriptsWithType(node sqalx.Node, scriptType string) ([]*Script, error)

GetScriptsWithType returns a slice with all registered Scripts with the given type

func (*Script) Delete

func (script *Script) Delete(node sqalx.Node) error

Delete deletes the script

func (*Script) Update

func (script *Script) Update(node sqalx.Node) error

Update adds or updates the script

type Source

type Source struct {
	ID        string
	Name      string
	Automatic bool
	Official  bool
}

Source represents a Status source

func GetSource

func GetSource(node sqalx.Node, id string) (*Source, error)

GetSource returns the Source with the given ID

func GetSources

func GetSources(node sqalx.Node) ([]*Source, error)

GetSources returns a slice with all registered sources

func (*Source) Delete

func (source *Source) Delete(node sqalx.Node) error

Delete deletes the source

func (*Source) Update

func (source *Source) Update(node sqalx.Node) error

Update adds or updates the source

type Station

type Station struct {
	ID       string
	Name     string
	AltNames []string
	Tags     []string
	LowTags  []string
	Network  *Network
}

Station is a Network station

func GetStation

func GetStation(node sqalx.Node, id string) (*Station, error)

GetStation returns the Station with the given ID

func GetStations

func GetStations(node sqalx.Node) ([]*Station, error)

GetStations returns a slice with all registered stations

func (*Station) Closed

func (station *Station) Closed(node sqalx.Node) (bool, error)

Closed returns whether this station is closed

func (*Station) Delete

func (station *Station) Delete(node sqalx.Node) error

Delete deletes the station

func (*Station) Directions

func (station *Station) Directions(node sqalx.Node, withAllServices bool) ([]*Station, error)

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)

func (*Station) HasTag

func (station *Station) HasTag(needle string) bool

HasTag returns true if this station was assigned the provided tag

func (*Station) Lines

func (station *Station) Lines(node sqalx.Node) ([]*Line, error)

Lines returns the lines that serve this station

func (*Station) Lobbies

func (station *Station) Lobbies(node sqalx.Node) ([]*Lobby, error)

Lobbies returns the lobbies of this station

func (*Station) POIs

func (station *Station) POIs(node sqalx.Node) ([]*POI, error)

POIs returns the POIs associated with this station

func (*Station) Update

func (station *Station) Update(node sqalx.Node) error

Update adds or updates the station

func (*Station) WiFiAPs

func (station *Station) WiFiAPs(node sqalx.Node) ([]*WiFiAP, error)

WiFiAPs returns the WiFi APs that are available in this station

type StationTags

type StationTags struct {
	StationID string
	Tags      []string
	LowTags   []string
}

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

func (*StationUse) Delete

func (stationUse *StationUse) Delete(node sqalx.Node, tripID string) error

Delete deletes the stationUse

func (*StationUse) Update

func (stationUse *StationUse) Update(node sqalx.Node, tripID string) error

Update adds or updates the stationUse

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 GetStatus

func GetStatus(node sqalx.Node, id string) (*Status, error)

GetStatus returns the Status with the given ID

func GetStatuses

func GetStatuses(node sqalx.Node) ([]*Status, error)

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

func (*Status) Delete

func (status *Status) Delete(node sqalx.Node) error

Delete deletes the status

func (*Status) Update

func (status *Status) Update(node sqalx.Node) error

Update adds or updates the status

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

type Time time.Time

Time wraps a time.Time with custom methods for serialization

func (*Time) DecodeMsgpack

func (t *Time) DecodeMsgpack(dec *msgpack.Decoder) error

DecodeMsgpack implements the msgpack.CustomDecoder interface

func (Time) EncodeMsgpack

func (t Time) EncodeMsgpack(enc *msgpack.Encoder) error

EncodeMsgpack implements the msgpack.CustomEncoder interface

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (*Time) Scan

func (t *Time) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler

func (Time) Value

func (t Time) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type Transfer

type Transfer struct {
	Station        *Station
	From           *Line
	To             *Line
	TypicalSeconds int
}

Transfer represents a crossing between two lines at a station

func GetTransfer

func GetTransfer(node sqalx.Node, station string, from string, to string) (*Transfer, error)

GetTransfer returns the Transfer with the given ID

func GetTransfers

func GetTransfers(node sqalx.Node) ([]*Transfer, error)

GetTransfers returns a slice with all registered transfers

func (*Transfer) Delete

func (transfer *Transfer) Delete(node sqalx.Node) error

Delete deletes the transfer

func (*Transfer) Update

func (transfer *Transfer) Update(node sqalx.Node) error

Update adds or updates the transfer

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 GetTrip

func GetTrip(node sqalx.Node, id string) (*Trip, error)

GetTrip returns the Trip with the given ID

func GetTrips

func GetTrips(node sqalx.Node) ([]*Trip, error)

GetTrips returns a slice with all registered trips

func GetTripsForSubmitter

func GetTripsForSubmitter(node sqalx.Node, submitter *APIPair) ([]*Trip, error)

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) Delete

func (trip *Trip) Delete(node sqalx.Node) error

Delete deletes the 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

func (*Trip) SimultaneousTrips

func (trip *Trip) SimultaneousTrips(node sqalx.Node, excludeLongerThan time.Duration) ([]*Trip, error)

SimultaneousTrips returns a slice containing trips that took place alongside this one

func (*Trip) Update

func (trip *Trip) Update(node sqalx.Node) error

Update adds or updates the trip

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

type WiFiAP struct {
	BSSID string
	SSID  string
	Line  string
}

WiFiAP is a WiFi access point

func GetWiFiAP

func GetWiFiAP(node sqalx.Node, bssid string) (*WiFiAP, error)

GetWiFiAP returns the WiFiAP with the given BSSID

func GetWiFiAPs

func GetWiFiAPs(node sqalx.Node) ([]*WiFiAP, error)

GetWiFiAPs returns a slice with all registered wiFiAPs

func (*WiFiAP) Delete

func (wiFiAP *WiFiAP) Delete(node sqalx.Node) error

Delete deletes the wiFiAP

func (*WiFiAP) Stations

func (wiFiAP *WiFiAP) Stations(node sqalx.Node) ([]*Station, error)

Stations returns the stations this wiFiAP belongs to

func (*WiFiAP) Update

func (wiFiAP *WiFiAP) Update(node sqalx.Node) error

Update adds or updates the wiFiAP

Jump to

Keyboard shortcuts

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