models

package
v0.0.0-...-d45180c Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const FETCH_SCHEDULE_EVENTS_BY_STATION_REALTIME string = `` /* 280-byte string literal not displayed */
View Source
const FETCH_SCHEDULE_EVENTS_BY_STATION_STATIC string = ""

Variables

This section is empty.

Functions

func DBMigrate

func DBMigrate(db *gorm.DB, log *log.Logger) error

func GetScheduleEventsByStationRealTime

func GetScheduleEventsByStationRealTime(stationId int, db *gorm.DB) (scheduleEvents []ScheduleEvent, realTimeDetails []RealTimeEventDetail, err error)

func ImportLiveEvents

func ImportLiveEvents(db *gorm.DB, events []gomarta.Train)

Types

type Alias

type Alias struct {
	ID               uint   `json:"-" gorm:"primary_key"`
	NamedElementType string `gorm:"not null"`
	NamedElementID   uint   `json:"-" gorm:"not null"`
	Alias            string
	Description      string
	CreatedAt        time.Time  `json:"-"`
	UpdatedAt        time.Time  `json:"-"`
	DeletedAt        *time.Time `json:"-" sql:"index"`
}

type Aliases

type Aliases []Alias

func (Aliases) Len

func (a Aliases) Len() int

func (Aliases) String

func (a Aliases) String(i int) string

type Direction

type Direction struct {
	ID        uint       `json:"-" gorm:"primary_key"`
	Feedback  []Feedback `json:",omitempty"`
	Lines     []Line     `json:",omitempty" gorm:"many2many:line_directions"`
	Name      string     `gorm:"not null"`
	Aliases   []Alias    `json:",omitempty" gorm:"polymorphic:NamedElement;"`
	CreatedAt time.Time  `json:"-"`
	UpdatedAt time.Time  `json:"-"`
	DeletedAt *time.Time `json:"-" sql:"index"`
}

func FindDirectionByName

func FindDirectionByName(name string, db *gorm.DB) (Direction, error)

type Directions

type Directions []Direction

func (Directions) Len

func (d Directions) Len() int

func (Directions) String

func (d Directions) String(i int) string

type Feedback

type Feedback struct {
	gorm.Model
	StationID   int
	LineID      int
	DirectionID int
	SourceID    int
	Source      FeedbackSource
	TypeID      int
	Type        FeedbackType
	Description string `gorm:"not null"`
	ThumbsUp    int
	ThumbsDown  int
	ExpiresAt   time.Time
}

type FeedbackSource

type FeedbackSource struct {
	gorm.Model
	SourceID   string
	SourceType string
}

type FeedbackType

type FeedbackType struct {
	gorm.Model
	Description string `gorm:"not null"`
}

type Line

type Line struct {
	ID         uint        `json:"-" gorm:"primary_key"`
	Feedback   []Feedback  `json:",omitempty"`
	Directions []Direction `json:",omitempty" gorm:"many2many:line_directions"`
	Stations   []Station   `json:",omitempty" gorm:"many2man:station_lines"`
	Name       string      `gorm:"not null"`
	Aliases    []Alias     `json:",omitempty" gorm:"polymorphic:NamedElement;"`
	CreatedAt  time.Time   `json:"-"`
	UpdatedAt  time.Time   `json:"-"`
	DeletedAt  *time.Time  `json:"-" sql:"index"`
}

func FindLineByName

func FindLineByName(name string, db *gorm.DB) (Line, error)

type Lines

type Lines []Line

func (Lines) Len

func (l Lines) Len() int

func (Lines) String

func (l Lines) String(i int) string

type RealTimeEventDetail

type RealTimeEventDetail struct {
	ID              uint          `json:"-" gorm:"primary_key"`
	ScheduleEventID uint          `json:"-"`
	ScheduleEvent   ScheduleEvent `json:"-"`
	EventTime       time.Time
	TrainID         uint `json:"-"`
	Train           Train
	WaitingSeconds  int    `gorm:"not null"`
	WaitingTime     string `gorm:"not null"`

	CreatedAt time.Time  `json:"-"`
	UpdatedAt time.Time  `json:"-"`
	DeletedAt *time.Time `json:"-" sql:"index"`
}

type ScheduleEvent

type ScheduleEvent struct {
	ID            uint `json:"-" gorm:"primary_key"`
	EventTypeID   uint `json:"-"`
	EventType     ScheduleEventSource
	DestinationID uint `json:"-"`
	Destination   Station
	NextArrival   time.Time
	NextStationID uint `json:"-"`
	NextStation   Station
	DirectionID   uint `json:"-"`
	Direction     Direction
	ExpiresAt     time.Time

	CreatedAt time.Time  `json:"-"`
	UpdatedAt time.Time  `json:"-"`
	DeletedAt *time.Time `json:"-" sql:"index"`
}

func (ScheduleEvent) LoadFromGoMartaEvent

func (se ScheduleEvent) LoadFromGoMartaEvent(gmTrain gomarta.Train, db *gorm.DB)

type ScheduleEventSource

type ScheduleEventSource struct {
	ID          uint       `json:"-" gorm:"primary_key"`
	Name        string     `gorm:"not null"`
	Description string     `gorm:"not null"`
	CreatedAt   time.Time  `json:"-"`
	UpdatedAt   time.Time  `json:"-"`
	DeletedAt   *time.Time `json:"-" sql:"index"`
}

type StaticEventDetail

type StaticEventDetail struct {
	gorm.Model
	ScheduleEventID    int
	ScheduleEvent      ScheduleEvent
	ScheduledTime      time.Time
	StaticScheduleType string `gorm:"not null"`
}

type Station

type Station struct {
	ID        uint          `gorm:"primary_key"`
	Feedback  []Feedback    `json:",omitempty"`
	Detail    StationDetail `json:",omitempty"`
	Aliases   []Alias       `gorm:"polymorphic:NamedElement;"`
	Lines     []Line        `gorm:"many2many:station_lines;not null;"`
	Name      string        `gorm:"unique;not null"`
	CreatedAt time.Time     `json:"-"`
	UpdatedAt time.Time     `json:"-"`
	DeletedAt *time.Time    `json:"-" sql:"index"`
}

func FindStationByName

func FindStationByName(name string, db *gorm.DB) (Station, error)

type StationDetail

type StationDetail struct {
	ID          uint       `json:"-" gorm:"primary_key"`
	StationID   uint       `json:"-" gorm:"not null"`
	Description string     `gorm:"not null"`
	Location    string     `gorm:"unique;not null"`
	Distance    float64    `json:",omitempty" gorm:"-"`
	CreatedAt   time.Time  `json:"-"`
	UpdatedAt   time.Time  `json:"-"`
	DeletedAt   *time.Time `json:"-" sql:"index"`
}

type Stations

type Stations []Station

func (Stations) Len

func (s Stations) Len() int

func (Stations) String

func (s Stations) String(i int) string

type Train

type Train struct {
	ID        uint       `gorm:"primary_key:true"`
	CreatedAt time.Time  `json:"-"`
	UpdatedAt time.Time  `json:"-"`
	DeletedAt *time.Time `json:"-" sql:"index"`
}

Jump to

Keyboard shortcuts

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