models

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AnonymousLoginType is for anonymous login.
	AnonymousLoginType = LoginType("anonymous")

	// ProtectedLoginType is for protected login.
	ProtectedLoginType = LoginType("protected")
)
View Source
const (
	TableComponent     = ComponentType("table")
	PieChartComponent  = ComponentType("pie_chart")
	BarChartComponent  = ComponentType("bar_chart")
	LineChartComponent = ComponentType("line_chart")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Activity

type Activity struct {
	Id                   int64          `json:"id" gorm:"primaryKey;autoIncrement:false"`
	ExternalId           string         `json:"external_id"`
	UploadId             int64          `json:"upload_id"`
	Name                 string         `json:"name"`
	Distance             float64        `json:"distance"`
	MovingTime           int            `json:"moving_time"`
	ElapsedTime          int            `json:"elapsed_time"`
	TotalElevationGain   float64        `json:"total_elevation_gain"`
	Type                 string         `json:"type"`
	StartDate            time.Time      `json:"start_date"`
	StartDateLocal       time.Time      `json:"start_date_local"`
	TimeZone             string         `json:"time_zone"`
	StartLocation        datatypes.JSON `json:"start_lat_lng"`
	EndLocation          datatypes.JSON `json:"end_lat_lng"`
	City                 string         `json:"location_city"`
	State                string         `json:"location_state"`
	Country              string         `json:"location_country"`
	AchievementCount     int            `json:"achievement_count"`
	KudosCount           int            `json:"kudos_count"`
	CommentCount         int            `json:"comment_count"`
	AthleteCount         int            `json:"athlete_count"`
	PhotoCount           int            `json:"photo_count"`
	Map                  datatypes.JSON `json:"map"`
	Trainer              bool           `json:"trainer"`
	Commute              bool           `json:"commute"`
	Manual               bool           `json:"manual"`
	Private              bool           `json:"private"`
	Flagged              bool           `json:"flagged"`
	AverageSpeed         float64        `json:"average_speed"`
	MaximumSpeed         float64        `json:"max_speed"`
	AverageCadence       float64        `json:"average_cadence"`
	AverageTemperature   float64        `json:"average_temp"`
	AveragePower         float64        `json:"average_watts"`
	WeightedAveragePower int            `json:"weighted_average_watts"`
	Kilojoules           float64        `json:"kilojoules"`
	DeviceWatts          bool           `json:"device_watts"`
	AverageHeartRate     float64        `json:"average_heart_rate"`
	MaximumHeartRate     float64        `json:"max_heart_rate"`
	Truncated            int            `json:"truncated"` // only present if activity is owned by authenticated athlete, returns 0 if not truncated by privacy zones
	HasKudos             bool           `json:"has_kudos"`
	AthleteID            uint           `json:"athlete_id"`
	Athlete              Athlete        `gorm:"foreignkey:AthleteID" json:"athlete"`
	GearID               *string        `json:"gear_id"`
	Gear                 *Gear          `gorm:"foreignkey:GearID" json:"gear,omitempty"`
}

type Athlete

type Athlete struct {
	Id               int64          `json:"id" gorm:"primaryKey;autoIncrement:false"`
	FirstName        string         `json:"firstname"`
	LastName         string         `json:"lastname"`
	ProfileMedium    string         `json:"profile_medium"` // URL to a 62x62 pixel profile picture
	Profile          string         `json:"profile"`        // URL to a 124x124 pixel profile picture
	City             string         `json:"city"`
	State            string         `json:"state"`
	Country          string         `json:"country"`
	Gender           string         `json:"sex"`
	Friend           string         `json:"friend"`   // ‘pending’, ‘accepted’, ‘blocked’ or ‘null’, the authenticated athlete’s following status of this athlete
	Follower         string         `json:"follower"` // this athlete’s following status of the authenticated athlete
	Premium          bool           `json:"premium"`
	CreatedAt        time.Time      `json:"created_at"`
	UpdatedAt        time.Time      `json:"updated_at"`
	ApproveFollowers bool           `json:"approve_followers"` // if has enhanced privacy enabled
	BadgeTypeId      int            `json:"badge_type_id"`
	Stats            datatypes.JSON `json:"tx"`
}

type Component

type Component struct {
	ID        uint      `json:"id" gorm:"primarykey"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	DashboardID uint
	Dashboard   Dashboard `gorm:"foreignkey:DashboardID" json:"dashboard"`

	Name    string         `json:"name"`
	Query   string         `json:"query"`
	Type    ComponentType  `json:"type"`
	Configs datatypes.JSON `json:"configs"`
}

type ComponentType

type ComponentType string

type Config

type Config struct {
	ID        uint      `json:"-" gorm:"primarykey"`
	CreatedAt time.Time `json:"-"`
	UpdatedAt time.Time `json:"-"`

	// Strava APP Credentials
	ClientId     int    `json:"client_id"`
	ClientSecret string `json:"client_secret"`

	// App Login Details
	LoginType     LoginType `json:"-"`
	LoginUsername string    `json:"-"`
	LoginPassword string    `json:"-"`
}

func (*Config) CheckLogin added in v0.1.0

func (c *Config) CheckLogin(username, password, secretKey string) bool

CheckLogin verifies the provided username and password against the stored credentials.

func (*Config) SetPassword added in v0.1.0

func (c *Config) SetPassword(password, secretKey string)

SetPassword hashes the provided password with the given secret key and sets it to the Config's LoginPassword field

func (*Config) SetupCompleted added in v0.1.0

func (c *Config) SetupCompleted() bool

SetupCompleted checks if the configuration setup is completed

type Dashboard

type Dashboard struct {
	ID        uint      `json:"id" gorm:"primarykey"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	Name string `json:"name"`
}

type Gear

type Gear struct {
	Id          string  `json:"id" gorm:"primaryKey;autoIncrement:false"`
	Name        string  `json:"name"`
	Primary     bool    `json:"primary"`
	Distance    float64 `json:"distance"`
	BrandName   string  `json:"brand_name"`
	ModelName   string  `json:"model_name"`
	Type        string  `json:"type"`
	Description string  `json:"description"`
	AthleteID   int64
	Athlete     *Athlete `gorm:"foreignkey:AthleteID" json:"athlete"`
}

type LoginType added in v0.1.0

type LoginType string

LoginType represents the type of login, either anonymous or protected.

Jump to

Keyboard shortcuts

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