Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrRoomNotFound when room does not exist ErrRoomNotFound = errors.New("room not found") // ErrRoomStopped when room is stopped ErrRoomStopped = errors.New("room stopped") )
View Source
var ( // Db saves database Db *gorm.DB )
Functions ¶
func RestartAllRooms ¶ added in v0.1.1
func RestartAllRooms()
RestartAllRooms restart all not disabled rooms
func RoomUntilNextTick ¶
RoomUntilNextTick return time until next tick if room open; if room is stopped, 0, ErrRoomStopped will be returned; if room not found, 0, ErrRoomNotFound will be returned
func UserPassValidate ¶
UserPassValidate validate user password
func UserSubmitValidate ¶
UserSubmitValidate validate user submit
Types ¶
type Room ¶
type Room struct { ID uint `gorm:"primary_key"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt *time.Time `sql:"index" json:"-"` Users []User RoomHistorys []RoomHistory `json:",omitempty"` Interval int RoundNow int RoundTotal int Status int }
Room hold user info
func (*Room) GetHistory ¶
func (r *Room) GetHistory() (history []RoomHistory)
GetHistory return room's history
func (*Room) GetUsersWithCache ¶ added in v0.1.2
GetUsersWithCache return room's users from room cache
type RoomHistory ¶
type RoomHistory struct { ID uint `gorm:"primary_key" json:"-"` CreatedAt time.Time `json:"-"` DeletedAt *time.Time `sql:"index" json:"-"` RoomID uint Round int GoldenNum float64 }
RoomHistory holds room history
type User ¶
type User struct { ID uint `gorm:"primary_key"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt *time.Time `sql:"index" json:"-"` RoomID uint UserHistorys []UserHistory `json:",omitempty"` Name string Score int Hashed string `json:"-"` Submit1 float64 `gorm:"-" json:"-"` Submit2 float64 `gorm:"-" json:"-"` }
User hold user info
func (*User) GetHistory ¶
func (u *User) GetHistory() (history []UserHistory)
GetHistory return user's history
Click to show internal directories.
Click to hide internal directories.