app

package
v0.0.0-...-940282f Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: MPL-2.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

View Source
const APIURL string = "https://api.fitbit.com/1"
View Source
const ChatTemperature float32 = 0.4

https://ai.google.dev/models/gemini

Variables

This section is empty.

Functions

func About

func About() echo.HandlerFunc

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 Contact

func Contact() echo.HandlerFunc

func CustomDashboard

func CustomDashboard() echo.HandlerFunc

func Dump

func Dump() echo.HandlerFunc

func Error

func Error() func(echo.Context) error

func Fetch

func Fetch() 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 GetStartDayOfWeek

func GetStartDayOfWeek(tm time.Time) time.Time

func Index

func Index() echo.HandlerFunc

func MonthlyDashboard

func MonthlyDashboard() echo.HandlerFunc

func NewDumper

func NewDumper(accessToken string) (*dumper, error)

NewDumper creates a new dumper using the provided access token

func NewFetcher

func NewFetcher(user *types.User) (*fetcher, error)

NewFetcher creates a new fetcher for the provided user

func NewRouter

func NewRouter() (*echo.Echo, error)

func PredictSleepEfficiency

func PredictSleepEfficiency(user *types.User, userData []*UserData) ([]uint8, error)

func Privacy

func Privacy() echo.HandlerFunc

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 TestGET

func TestGET() echo.HandlerFunc

func TestPredictSleepEfficiency

func TestPredictSleepEfficiency() echo.HandlerFunc

func TestTrainAndDeploy

func TestTrainAndDeploy() echo.HandlerFunc

func TrainAndDeployPredictor

func TrainAndDeployPredictor(user *types.User, targetColumn string) (err error)

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 DailyStepsStats struct {
	TotalSteps   int64
	MaxSteps     int64
	MinSteps     int64
	AverageSteps float64

	TotalDistance   float64
	MaxDistance     float64
	MinDistance     float64
	AverageDistance float64

	TotalCalories   int64
	MaxCalories     int64
	MinCalories     int64
	AverageCalories float64
}

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 HealthDashboard struct {
	BreathingRate        *charts.Line
	HeartRateVariability *charts.Line
	SkinTemperature      *charts.Bar
	OxygenSaturation     *charts.Line
	RestingHeartRate     *charts.Line
	Weight               *charts.Line
	BMI                  *charts.Line
	Stats                *HealthStats
}

type HealthStats

type HealthStats struct {
	AverageStartTime time.Time
	AverageEndTime   time.Time
	AverageDuration  float64
	MaxDuration      float64
	MinDuration      float64
}

type PredictionResult

type PredictionResult struct {
	// The prediction result
	Prediction []float32 `json:"prediction"`
	Target     string    `json:"target"`
}

type Reporter

type Reporter struct {
	// contains filtered or unexported fields
}

func NewReporter

func NewReporter(user *types.User) (*Reporter, error)

NewReporter creates a new Reporter

func (*Reporter) Close

func (r *Reporter) Close()

Close closes the client

func (*Reporter) GenerateDailyReport

func (r *Reporter) GenerateDailyReport(data *UserData) (report *types.Report, err error)

GenerateDailyReport generates a daily report for the given user

func (*Reporter) GenerateEmbeddings

func (r *Reporter) GenerateEmbeddings(prompt string) (embeddings pgvector.Vector, err error)

GenerateEmbeddings uses VertexAI to generate embeddings for a given prompt

type SleepDashboard

type SleepDashboard struct {
	AggregatedStages              *charts.Bar
	Efficiency                    *charts.Line
	HeartRateVariabilityDeepSleep *charts.Line
	Stats                         *SleepStats
}

type SleepStats

type SleepStats struct {
	AverageStartTime time.Time
	AverageEndTime   time.Time
	AverageDuration  float64
	MaxDuration      float64
	MinDuration      float64
}

type UserActivityTypes

type UserActivityTypes struct {
	ID   int64
	Name string
}

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.

func (UserData) Headers

func (UserData) Headers() []string

Headers returns the headers of the CSV file The order of the headers is important as it will be used to generate the CSV file The order of the values must match the order of the headers If a value is nil, the CSV cell will be empty

func (*UserData) Values

func (u *UserData) Values() []string

Jump to

Keyboard shortcuts

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