models

package
v0.0.169 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountDevices

func CountDevices(db *gorm.DB) (int, error)

func CountUsers

func CountUsers(db *gorm.DB) (int, error)

func DeleteDevice

func DeleteDevice(db *gorm.DB, id uint) error

func DeleteUser

func DeleteUser(db *gorm.DB, id uint) error

func DeviceIDExists

func DeviceIDExists(db *gorm.DB, id uint) (bool, error)

func GenerateDongleID

func GenerateDongleID(db *gorm.DB) (string, error)

GenerateDognleID generates a unique random dongle ID

func UpdateAthenaPingTimestamp

func UpdateAthenaPingTimestamp(db *gorm.DB, id uint) error

func UserIDExists

func UserIDExists(db *gorm.DB, id uint) (bool, error)

Types

type BootLog

type BootLog struct {
	ID       uint   `json:"-" gorm:"primaryKey"`
	DeviceID uint   `json:"-" binding:"required" gorm:"uniqueIndex,OnUpdate:CASCADE,OnDelete:SET NULL"`
	FileName string `json:"file_name" binding:"required"`
}

type CrashLog

type CrashLog struct {
	ID       uint   `json:"-" gorm:"primaryKey"`
	DeviceID uint   `json:"-" binding:"required" gorm:"uniqueIndex,OnUpdate:CASCADE,OnDelete:SET NULL"`
	FileName string `json:"file_name" binding:"required"`
}

type Device

type Device struct {
	ID        uint                `json:"-" gorm:"primaryKey" binding:"required"`
	Alias     nulltype.NullString `json:"alias,omitempty"`
	DongleID  string              `json:"dongle_id" gorm:"uniqueIndex" binding:"required"`
	Serial    string              `json:"serial" gorm:"uniqueIndex" binding:"required"`
	PublicKey string              `json:"public_key" gorm:"uniqueIndex" binding:"required"`
	IsPaired  bool                `json:"is_paired" gorm:"default:false"`
	// Prime defaults to true
	Prime bool `json:"prime" gorm:"default:true"`
	// PrimeType defaults to 1 for "standard prime"
	PrimeType uint `json:"prime_type" gorm:"default:1"`
	// TrialClaimed defaults to true
	TrialClaimed            bool                 `json:"trial_claimed" gorm:"default:true"`
	DeviceType              DeviceType           `json:"device_type"`
	LastGPSTime             nulltype.NullTime    `json:"last_gps_time,omitempty"`
	LastGPSLat              nulltype.NullFloat64 `json:"last_gps_lat,omitempty"`
	LastGPSLng              nulltype.NullFloat64 `json:"last_gps_lng,omitempty"`
	LastGPSAccuracy         nulltype.NullFloat64 `json:"last_gps_accuracy,omitempty"`
	LastGPSSpeed            nulltype.NullFloat64 `json:"last_gps_speed,omitempty"`
	LastGPSBearing          nulltype.NullFloat64 `json:"last_gps_bearing,omitempty"`
	OpenPilotVersion        string               `json:"openpilot_version"`
	LastAthenaPing          int64                `json:"last_athena_ping"`
	DestinationSet          bool                 `json:"-"`
	DestinationLatitude     float64              `json:"-"`
	DestinationLongitude    float64              `json:"-"`
	DestinationPlaceDetails string               `json:"-"`
	DestinationPlaceName    string               `json:"-"`

	OwnerID uint `json:"-"`

	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"-"`
	DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
}

func FindDeviceByDongleID

func FindDeviceByDongleID(db *gorm.DB, id string) (Device, error)

func FindDeviceByID

func FindDeviceByID(db *gorm.DB, id uint) (Device, error)

func FindDeviceBySerial

func FindDeviceBySerial(db *gorm.DB, serial string) (Device, error)

func GetDevicesOwnedByUser

func GetDevicesOwnedByUser(db *gorm.DB, userID uint) ([]Device, error)

func ListDevices

func ListDevices(db *gorm.DB) ([]Device, error)

func (Device) TableName

func (u Device) TableName() string

type DeviceShare

type DeviceShare struct {
	ID             uint `json:"-" gorm:"primaryKey" binding:"required"`
	DeviceID       uint `json:"-" binding:"required" gorm:"uniqueIndex,OnUpdate:CASCADE,OnDelete:SET NULL"`
	OwnerID        uint `json:"-" binding:"required" gorm:"uniqueIndex,OnUpdate:CASCADE,OnDelete:SET NULL"`
	SharedToUserID uint `json:"-" binding:"required" gorm:"uniqueIndex,OnUpdate:CASCADE,OnDelete:SET NULL"`
}

func ListSharedByOwnerID

func ListSharedByOwnerID(db *gorm.DB, ownerID uint) ([]DeviceShare, error)

func ListSharedToByUserID

func ListSharedToByUserID(db *gorm.DB, sharedToID uint) ([]DeviceShare, error)

func (DeviceShare) TableName

func (u DeviceShare) TableName() string

type DeviceType

type DeviceType string
const (
	DeviceTypeNeo    DeviceType = "neo"
	DeviceTypePanda  DeviceType = "panda"
	DeviceTypeApp    DeviceType = "app"
	DeviceTypeThreeX DeviceType = "threex"
)

type Location

type Location struct {
	ID           uint                `json:"id" gorm:"primaryKey" binding:"required"`
	DeviceID     uint                `json:"device_id" binding:"required" gorm:"uniqueIndex,OnUpdate:CASCADE,OnDelete:SET NULL"`
	Latitude     float64             `json:"latitude" binding:"required"`
	Longitude    float64             `json:"longitude" binding:"required"`
	Label        nulltype.NullString `json:"label,omitempty"`
	Modified     time.Time           `json:"modified" gorm:"autoUpdateTime:milli,default:current_timestamp"`
	PlaceDetails string              `json:"place_details,omitempty"`
	PlaceName    string              `json:"place_name,omitempty"`
	SaveType     SaveType            `json:"save_type" binding:"required"`

	CreatedAt time.Time      `json:"created_at"`
	DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
}

func FindLocationsByDeviceID

func FindLocationsByDeviceID(db *gorm.DB, deviceID uint) ([]Location, error)

func (Location) TableName

func (u Location) TableName() string

type SaveType

type SaveType string
const (
	Favorite SaveType = "favorite"
	Recent   SaveType = "recent"
)

type User

type User struct {
	ID           uint                `json:"-" gorm:"primaryKey" binding:"required"`
	GitHubUserID nulltype.NullInt64  `json:"github_user_id,omitempty" gorm:"uniqueIndex"`
	GoogleUserID nulltype.NullString `json:"google_user_id,omitempty" gorm:"uniqueIndex"`
	CustomUserID nulltype.NullInt64  `json:"custom_user_id,omitempty" gorm:"uniqueIndex"`
	Superuser    bool                `json:"superuser" gorm:"default:false"`
	CreatedAt    time.Time           `json:"created_at"`
	UpdatedAt    time.Time           `json:"-"`
	DeletedAt    gorm.DeletedAt      `json:"-" gorm:"index"`
}

func FindUserByCustomID added in v0.0.158

func FindUserByCustomID(db *gorm.DB, id int) (User, error)

func FindUserByGitHubID

func FindUserByGitHubID(db *gorm.DB, id int) (User, error)

func FindUserByGoogleID

func FindUserByGoogleID(db *gorm.DB, id string) (User, error)

func FindUserByID

func FindUserByID(db *gorm.DB, id uint) (User, error)

func ListUsers

func ListUsers(db *gorm.DB) ([]User, error)

func (User) TableName

func (u User) TableName() string

Jump to

Keyboard shortcuts

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