Documentation ¶
Index ¶
- func Close()
- func CreateChallenge(c Challenge) error
- func GetActiveChallenges(userID int64) (*[]Challenge, error)
- func GetAllChallenges(userID int64) (*[]Challenge, error)
- func GetCompletedChallenges(userID int64) (*[]Challenge, error)
- func GetExpiredChallenges() (*[]Challenge, error)
- func GetPendingChallenges(userID int64) (*[]Challenge, error)
- func RemoveChallenge(id bson.ObjectId) error
- func RemoveSegment(ID int64) error
- func RemoveUser(ID int64) error
- func UpdateChallengeStatus(id bson.ObjectId, status string, updateTime time.Time) error
- type Challenge
- type Friend
- type Map
- type Opponent
- type Segment
- type User
- func (u *User) IncrementLosses(id int64) error
- func (u *User) IncrementSegments(id int64) error
- func (u *User) IncrementWins(id int64) error
- func (u User) RemoveFriendsSegmentsFromUser() error
- func (u User) SaveUserFriends(friends []*Friend) error
- func (u User) SaveUserSegments(segments []*UserSegment) error
- func (u User) UpdateAthlete(athlete *strava.AthleteDetailed) (*User, error)
- func (u User) UpdateUser(auth *strava.AuthorizationResponse) (*User, error)
- type UserSegment
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateChallenge ¶
CreateChallenge creates a new challenge in database
func GetActiveChallenges ¶
GetActiveChallenges get active challenges by user ID from database
func GetAllChallenges ¶
GetAllChallenges get all challenges for a user from database
func GetCompletedChallenges ¶
GetCompletedChallenges get completed challenges by user ID from database
func GetExpiredChallenges ¶
GetExpiredChallenges get expired challenges from database
func GetPendingChallenges ¶
GetPendingChallenges get pending challenges by user ID from database
func RemoveChallenge ¶
RemoveChallenge removes a challenge from database
Types ¶
type Challenge ¶
type Challenge struct { ID bson.ObjectId `bson:"_id,omitempty" json:"id"` Segment *Segment `bson:"segment" json:"segment"` Challenger *Opponent `bson:"challenger" json:"challenger"` Challengee *Opponent `bson:"challengee" json:"challengee"` Status string `bson:"status" json:"status"` Created *time.Time `bson:"created" json:"created,omitempty"` Expires *time.Time `bson:"expires" json:"expires,omitempty"` Completed *time.Time `bson:"completed" json:"completed,omitempty"` Expired bool `bson:"expired" json:"expired"` WinnerID *int64 `bson:"winnerId" json:"winnerId,omitempty"` WinnerName *string `bson:"winnerName" json:"winnerName,omitempty"` LoserID *int64 `bson:"loserId" json:"loserId,omitempty"` LoserName *string `bson:"loserName" json:"loserName,omitempty"` CreatedAt time.Time `bson:"createdAt" json:"createdAt"` UpdatedAt time.Time `bson:"updatedAt" json:"updatedAt"` DeletedAt *time.Time `bson:"deletedAt" json:"deletedAt,omitempty"` }
Challenge struct handles the database schema for a challenge
func GetChallengeByID ¶
GetChallengeByID gets a single stored challenge from database
func (Challenge) UpdateChallenge ¶
UpdateChallenge updates a challenge from database
type Friend ¶
type Friend struct { ID int64 `bson:"_id" json:"id"` FirstName string `bson:"firstname" json:"firstName"` LastName string `bson:"lastname" json:"lastName"` FullName string `bson:"fullName" json:"fullName"` Photo string `bson:"photo" json:"photo"` ChallengeCount int `bson:"challengeCount" json:"challengeCount"` Wins int `bson:"wins" json:"wins"` Losses int `bson:"losses" json:"losses"` }
Friend struct handles the MongoDB schema for each users friends
type Map ¶
type Map struct { ID string `bson:"id" json:"id"` Polyline string `bson:"polyline" json:"polyline"` }
Map struct handles the MongoDB schema for each segments map
type Opponent ¶
type Opponent struct { ID int64 `json:"id"` Name string `json:"name"` Photo string `json:"photo"` Completed bool `json:"completed"` Time *int `json:"time,omitempty"` AverageCadence *float64 `json:"averageCadence,omitempty"` AverageWatts *float64 `json:"averageWatts,omitempty"` AverageHeartRate *float64 `json:"averageHeartRate,omitempty"` MaxHeartRate *float64 `json:"maxHeartRate,omitempty"` }
Opponent struct handles the database schema for each users challenge effort
type Segment ¶
type Segment struct { ID int64 `bson:"_id" json:"id"` Name string `bson:"name" json:"name"` ActivityType string `bson:"activityType" json:"activityType"` Distance float64 `bson:"distance" json:"distance"` AverageGrade float64 `bson:"averageGrade" json:"averageGrade"` MaximumGrade float64 `bson:"maximumGrade" json:"maximumGrade"` ElevationHigh float64 `bson:"elevationHigh" json:"elevationHigh"` ElevationLow float64 `bson:"elevationLow" json:"elevationLow"` ClimbCategory int `bson:"climbCategory" json:"climbCategory"` City string `bson:"city" json:"city"` State string `bson:"state" json:"state"` Country string `bson:"country" json:"country"` TotalElevationGain float64 `bson:"totalElevationGain" json:"totalElevationGain"` StartLocation [2]float64 `bson:"startLocation" json:"startLocation"` EndLocation [2]float64 `bson:"endLocation" json:"endLocation"` Map Map `bson:"map" json:"map"` CreatedAt time.Time `bson:"createdAt" json:"createdAt"` UpdatedAt time.Time `bson:"updatedAt" json:"updatedAt"` }
Segment struct handles the MongoDB schema for a segment
func GetSegmentByID ¶
GetSegmentByID gets a single stored segment from MongoDB
func SaveSegment ¶
SaveSegment stores a cached segment this prevents strava api rate limiting
func (Segment) UpdateSegment ¶
UpdateSegment stores a cached segment this prevents stale data from strava api rate limiting
type User ¶
type User struct { ID int64 `bson:"_id" json:"id"` FirstName string `bson:"firstname" json:"firstName"` LastName string `bson:"lastname" json:"lastName"` FullName string `bson:"fullname" json:"fullName"` City string `bson:"city" json:"city"` State string `bson:"state" json:"state"` Country string `bson:"country" json:"country"` Gender string `bson:"gender" json:"gender"` Token string `bson:"token" json:"token"` Photo string `bson:"photo" json:"photo"` Email string `bson:"email" json:"email"` Friends []*Friend `bson:"friends" json:"friends"` Segments []*UserSegment `bson:"segments" json:"segments"` Wins int `bson:"wins" json:"wins"` Losses int `bson:"losses" json:"losses"` ChallengeCount int `bson:"challengeCount" json:"challengeCount"` CreatedAt time.Time `bson:"createdAt" json:"createdAt,omitempty"` UpdatedAt time.Time `bson:"updatedAt" json:"updatedAt,omitempty"` DeletedAt *time.Time `bson:"deletedAt" json:"deletedAt,omitempty"` }
User struct handles the MongoDB schema for a user
func CreateUser ¶
CreateUser creates user in MongoDB
func GetUserByID ¶
GetUserByID gets a single stored user from MongoDB
func RegisterUser ¶
RegisterUser creates a user in MongoDB
func (*User) IncrementLosses ¶
IncrementLosses increment losses and challenge count for a particular user by id
func (*User) IncrementSegments ¶
IncrementSegments increment segment count for a particular user by id
func (*User) IncrementWins ¶
IncrementWins increment wins and challenge count for a particular user by id
func (User) RemoveFriendsSegmentsFromUser ¶
RemoveFriendsSegmentsFromUser modifies user in MongoDB
func (User) SaveUserFriends ¶
SaveUserFriends save user friends
func (User) SaveUserSegments ¶
func (u User) SaveUserSegments(segments []*UserSegment) error
SaveUserSegments save user segments
func (User) UpdateAthlete ¶
UpdateAthlete updates user in MongoDB
func (User) UpdateUser ¶
UpdateUser updates user in MongoDB