Documentation
¶
Index ¶
- Constants
- func About() echo.HandlerFunc
- func Auth() func(echo.Context) error
- func ChatWithData() echo.HandlerFunc
- func Contact() echo.HandlerFunc
- func CustomDashboard() echo.HandlerFunc
- func Dump() echo.HandlerFunc
- func Error() func(echo.Context) error
- func Fetch() echo.HandlerFunc
- func GenerateTypes() echo.HandlerFunc
- func GetStartDayOfWeek(tm time.Time) time.Time
- func Index() echo.HandlerFunc
- func MonthlyDashboard() echo.HandlerFunc
- func NewDumper(accessToken string) (*dumper, error)
- func NewFetcher(user *types.User) (*fetcher, error)
- func NewRouter() (*echo.Echo, error)
- func PredictSleepEfficiency(user *types.User, userData []*UserData) ([]uint8, error)
- func Privacy() echo.HandlerFunc
- func Redirect() func(echo.Context) error
- func RequireFitbit() echo.MiddlewareFunc
- func TestGET() echo.HandlerFunc
- func TestPredictSleepEfficiency() echo.HandlerFunc
- func TestTrainAndDeploy() echo.HandlerFunc
- func TrainAndDeployPredictor(user *types.User, targetColumn string) (err error)
- func UserDataToPredictionInstance(userData []*UserData, skipColumns []string) ([]*structpb.Value, error)
- func WeeklyDashboard() echo.HandlerFunc
- func YearlyDashboard() echo.HandlerFunc
- type ActivityStats
- type CalendarType
- type DailyActivities
- type DailyStepsStats
- type FetchStrategy
- type FetcherError
- type HealthDashboard
- type HealthStats
- type PredictionResult
- type Reporter
- type SleepDashboard
- type SleepStats
- type UserActivityTypes
- type UserData
Constants ¶
const APIURL string = "https://api.fitbit.com/1"
const ChatTemperature float32 = 0.4
Variables ¶
This section is empty.
Functions ¶
func Auth ¶
func Auth() func(echo.Context) error
Auth redirects the user to the fitbit authorization page It sets a cookie the univocally identifies the user because the authorizer.Exchange (used in Redirect) needs to check the `code` and CSRF tokens - and these tokens are attributes of the fitbit client that needs to persist from Auth() to Redirect(). NOTE: it uses the environment variables: - FITBIT_CLIENT_ID - FITBIT_CLIENT_SECRET - FITBIT_REDIRECT_URL Loaded from a .env file - if any.
func ChatWithData ¶
func ChatWithData() echo.HandlerFunc
func CustomDashboard ¶
func CustomDashboard() echo.HandlerFunc
func GenerateTypes ¶
func GenerateTypes() echo.HandlerFunc
GenerateTypes is an internal use endpoint That allows to have a Go representation of the JSON responses for all the GET endpoints of the Fitbit API. It doesn't use the authorizer methods, because it has been used to create the types used by the authorizer itself.
func MonthlyDashboard ¶
func MonthlyDashboard() echo.HandlerFunc
func NewFetcher ¶
NewFetcher creates a new fetcher for the provided user
func PredictSleepEfficiency ¶
func Redirect ¶
func Redirect() func(echo.Context) error
Redirect handles the redirect from the Fitbit API to our redirect URI. Sets the "token" cookie for the whole domain, containing the access token The access token univocally identifies the user. The token expires when the access token expires.
func RequireFitbit ¶
func RequireFitbit() echo.MiddlewareFunc
RequireFitbit is the middleware to use when a route requires to interact with the fitbit API. The middleware uses the cookies to identify the user and understand in which phase of the oauth2 authorization flows we are and set the context's fitbit variable (c.Get("fitbit")) to a valid authorizer If and only if the required cookies have been previously set.
func TestPredictSleepEfficiency ¶
func TestPredictSleepEfficiency() echo.HandlerFunc
func TestTrainAndDeploy ¶
func TestTrainAndDeploy() echo.HandlerFunc
func TrainAndDeployPredictor ¶
func UserDataToPredictionInstance ¶
func UserDataToPredictionInstance(userData []*UserData, skipColumns []string) ([]*structpb.Value, error)
UserDataToPredictionInstance converts a slice of UserData to a slice of structpb.Value. It skips all the columns that are not used for training, that you should pass in the skipColumns parameter.
func WeeklyDashboard ¶
func WeeklyDashboard() echo.HandlerFunc
func YearlyDashboard ¶
func YearlyDashboard() echo.HandlerFunc
Types ¶
type ActivityStats ¶
type ActivityStats struct {
// Totals
TotalTime float64
TotalDistance float64
TotalCalories int64
TotalSteps int64
TotalActiveTime float64
TotalActiveZoneMinutes int64
TotalMinutesInFatBurn int64
TotalMinutesInCardio int64
TotalMinutesInPeak int64
// Averages
AverageTime float64
AverageHeartRate float64
AveragePace float64
AverageSpeed float64
AverageDistance float64
AverageCalories float64
AverageSteps float64
// Max
MaxElevationGain int64
MaxPace float64
MaxSpeed float64
}
type CalendarType ¶
type CalendarType int
const ( WeeklyCalendar CalendarType = iota MonthlyCalendar BiMonthlyCalendar TriMonthlyCalendar QuadriMonthlyCalendar PentaMonthlyCalendar HexaMonthlyCalendar YearlyCalendar )
type DailyActivities ¶
type DailyActivities []types.ActivityLog
func (DailyActivities) Headers ¶
func (DailyActivities) Headers() []string
Headers returns the headers of the CSV file. For the DailyActivities type, the headers are only the column names that can be aggregated using a sum (e.g. no activityID, no activityParentID, etc.)
func (*DailyActivities) Values ¶
func (f *DailyActivities) Values() []string
type DailyStepsStats ¶
type FetchStrategy ¶
type FetchStrategy int
const ( FetchAllWithSleepLog FetchStrategy = iota FetchAllWithActivityLog FetchAll )
type FetcherError ¶
type FetcherError struct {
// contains filtered or unexported fields
}
func (*FetcherError) Error ¶
func (e *FetcherError) Error() string
type HealthDashboard ¶
type HealthStats ¶
type PredictionResult ¶
type Reporter ¶
type Reporter struct {
// contains filtered or unexported fields
}
func NewReporter ¶
NewReporter creates a new Reporter
func (*Reporter) GenerateDailyReport ¶
GenerateDailyReport generates a daily report for the given user
func (*Reporter) GenerateEmbeddings ¶
GenerateEmbeddings uses VertexAI to generate embeddings for a given prompt
type SleepDashboard ¶
type SleepStats ¶
type UserActivityTypes ¶
type UserData ¶
type UserData struct {
Date time.Time
Activities *DailyActivities
ActivityCalories *types.ActivityCaloriesSeries
BMI *types.BMISeries
BodyFat *types.BodyFatSeries
BodyWeight *types.BodyWeightSeries
BreathingRate *types.BreathingRate
CaloriesBMR *types.CaloriesBMRSeries
Calories *types.CaloriesSeries
Distance *types.DistanceSeries
Floors *types.FloorsSeries
MinutesFairlyActive *types.MinutesFairlyActiveSeries
MinutesLightlyActive *types.MinutesLightlyActiveSeries
MinutesSedentary *types.MinutesSedentarySeries
MinutesVeryActive *types.MinutesVeryActiveSeries
Steps *types.StepsSeries
HeartRate *types.HeartRateActivities
Elevation *types.ElevationSeries
SkinTemperature *types.SkinTemperature
CoreTemperature *types.CoreTemperature
OxygenSaturation *types.OxygenSaturation
CardioFitnessScore *types.CardioFitnessScore
HeartRateVariability *types.HeartRateVariabilityTimeSeries
SleepLog *types.SleepLog
}
Create a struct that given all the return types of the methods used inside the Fetch method, is able to hold them all.