models

package
v0.0.0-...-b8c8894 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *pop.Connection

DB is a connection to your database to be used throughout your application.

Functions

func IsSameActivity

func IsSameActivity(a1, a2 *Activity) bool

IsSameActivity returns true when activities' relevant fields are equal

Types

type Activities

type Activities []Activity

Activities is not required by pop and may be deleted

func (Activities) String

func (a Activities) String() string

String is not required by pop and may be deleted

type Activity

type Activity struct {
	ID          uuid.UUID `json:"id" db:"id"`
	UserID      uuid.UUID `json:"user_id" db:"user_id"`
	Provider    string    `json:"provider" db:"provider"`
	ProviderID  string    `json:"provider_id" db:"provider_id"`
	Name        string    `json:"name" db:"name"`
	Type        string    `json:"type" db:"type"`
	Datetime    time.Time `json:"datetime" db:"datetime"`
	Distance    int       `json:"distance" db:"distance"`
	MovingTime  int       `json:"moving_time" db:"moving_time"`
	ElapsedTime int       `json:"elapsed_time" db:"elapsed_time"`
	CreatedAt   time.Time `json:"created_at" db:"created_at"`
	UpdatedAt   time.Time `json:"updated_at" db:"updated_at"`
}

Activity is used by pop to map your activities database table to your go code.

func ParseStravaActivity

func ParseStravaActivity(stravaActivity swagger.SummaryActivity, user User) *Activity

ParseStravaActivity converts from swagger.SummaryActivity to models.User

func (*Activity) CreateOrUpdate

func (a *Activity) CreateOrUpdate(tx *pop.Connection) error

CreateOrUpdate will create or update the activity (based on (provider,provider_id) key)

func (Activity) String

func (a Activity) String() string

String is not required by pop and may be deleted

func (*Activity) Validate

func (a *Activity) Validate(tx *pop.Connection) (*validate.Errors, error)

Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method. This method is not required and may be deleted.

func (*Activity) ValidateCreate

func (a *Activity) ValidateCreate(tx *pop.Connection) (*validate.Errors, error)

ValidateCreate gets run every time you call "pop.ValidateAndCreate" method. This method is not required and may be deleted.

func (*Activity) ValidateUpdate

func (a *Activity) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error)

ValidateUpdate gets run every time you call "pop.ValidateAndUpdate" method. This method is not required and may be deleted.

type User

type User struct {
	ID           uuid.UUID    `json:"id" db:"id"`
	Name         string       `json:"name" db:"name"`
	Email        nulls.String `json:"email" db:"email"`
	Provider     string       `json:"provider" db:"provider"`
	ProviderID   string       `json:"provider_id" db:"provider_id"`
	AccessToken  string       `json:"access_token" db:"access_token"`
	RefreshToken string       `json:"refresh_token" db:"refresh_token"`
	AvatarURL    string       `json:"avatar_url" db:"avatar_url"`
	CreatedAt    time.Time    `json:"created_at" db:"created_at"`
	UpdatedAt    time.Time    `json:"updated_at" db:"updated_at"`
}

User is used by pop to map your users database table to your go code.

func (*User) GetStats

func (u *User) GetStats(tx *pop.Connection) (allActivitiesStats UserStats, validActivitiesStats UserStats, err error)

GetStats will return a UserStats for this User

func (*User) RefreshAccessToken

func (u *User) RefreshAccessToken(tx *pop.Connection) error

RefreshAccessToken will refresh user's accessToken and refreshToken auth

func (User) String

func (u User) String() string

String is not required by pop and may be deleted

func (*User) SyncActivities

func (u *User) SyncActivities(tx *pop.Connection, syncFunction func(stravaAccessToken string) ([]swagger.SummaryActivity, error)) error

SyncActivities will fetch provider's activities and store them on database

func (*User) Validate

func (u *User) Validate(tx *pop.Connection) (*validate.Errors, error)

Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method. This method is not required and may be deleted.

func (*User) ValidateCreate

func (u *User) ValidateCreate(tx *pop.Connection) (*validate.Errors, error)

ValidateCreate gets run every time you call "pop.ValidateAndCreate" method. This method is not required and may be deleted.

func (*User) ValidateUpdate

func (u *User) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error)

ValidateUpdate gets run every time you call "pop.ValidateAndUpdate" method. This method is not required and may be deleted.

type UserStats

type UserStats struct {
	Distance            int
	Count               int
	ElapsedDuration     int
	MovingDuration      int
	MostDistance        int
	MostElapsedDuration int
	MostMovingDuration  int
}

UserStats contains public User data with activities stats

type Users

type Users []User

Users is not required by pop and may be deleted

func (Users) String

func (u Users) String() string

String is not required by pop and may be deleted

Jump to

Keyboard shortcuts

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