Documentation ¶
Index ¶
- Variables
- func IsSameActivity(a1, a2 *Activity) bool
- type Activities
- type Activity
- func (a *Activity) CreateOrUpdate(tx *pop.Connection) error
- func (a Activity) String() string
- func (a *Activity) Validate(tx *pop.Connection) (*validate.Errors, error)
- func (a *Activity) ValidateCreate(tx *pop.Connection) (*validate.Errors, error)
- func (a *Activity) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error)
- type User
- func (u *User) GetStats(tx *pop.Connection) (allActivitiesStats UserStats, validActivitiesStats UserStats, err error)
- func (u *User) RefreshAccessToken(tx *pop.Connection) error
- func (u User) String() string
- func (u *User) SyncActivities(tx *pop.Connection, ...) error
- func (u *User) Validate(tx *pop.Connection) (*validate.Errors, error)
- func (u *User) ValidateCreate(tx *pop.Connection) (*validate.Errors, error)
- func (u *User) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error)
- type UserStats
- type Users
Constants ¶
This section is empty.
Variables ¶
var DB *pop.Connection
DB is a connection to your database to be used throughout your application.
Functions ¶
func IsSameActivity ¶
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 ¶
CreateOrUpdate will create or update the activity (based on (provider,provider_id) key)
func (*Activity) Validate ¶
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 ¶
ValidateCreate gets run every time you call "pop.ValidateAndCreate" method. This method is not required and may be deleted.
func (*Activity) ValidateUpdate ¶
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 ¶
RefreshAccessToken will refresh user's accessToken and refreshToken auth
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 ¶
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 ¶
ValidateCreate gets run every time you call "pop.ValidateAndCreate" method. This method is not required and may be deleted.
func (*User) ValidateUpdate ¶
ValidateUpdate gets run every time you call "pop.ValidateAndUpdate" method. This method is not required and may be deleted.