Documentation ¶
Overview ¶
This package provides the interface and functions to deal with the storage of data.
Index ¶
- Constants
- Variables
- func FindSteadySailor(context context.Context, recipientEmail string) (sailorProfile *model.GlukitUser, key *datastore.Key, upperBound time.Time, ...)
- func GetA1CEstimates(context context.Context, email string, scanQuery ScoreScanQuery) (scores []model.A1CEstimate, err error)
- func GetCalibrations(context context.Context, email string, lowerBound time.Time, ...) (meals []apimodel.CalibrationRead, err error)
- func GetExercises(context context.Context, email string, lowerBound time.Time, ...) (exercises []apimodel.Exercise, err error)
- func GetFileImportLog(context context.Context, userProfileKey *datastore.Key, fileId string) (fileImport *model.FileImportLog, err error)
- func GetGlucoseReads(context context.Context, email string, lowerBound time.Time, ...) (reads []apimodel.GlucoseRead, err error)
- func GetGlukitScores(context context.Context, email string, scanQuery ScoreScanQuery) (scores []model.GlukitScore, err error)
- func GetGlukitUser(context context.Context, email string) (key *datastore.Key, userProfile *model.GlukitUser, err error)
- func GetGlukitUserWithKey(context context.Context, key *datastore.Key) (userProfile *model.GlukitUser, err error)
- func GetInjections(context context.Context, email string, lowerBound time.Time, ...) (meals []apimodel.Injection, err error)
- func GetMeals(context context.Context, email string, lowerBound time.Time, ...) (carbs []apimodel.Meal, err error)
- func GetUserData(context context.Context, email string) (userProfile *model.GlukitUser, key *datastore.Key, upperBound time.Time, ...)
- func GetUserKey(context context.Context, email string) (key *datastore.Key)
- func GetUserProfile(context context.Context, key *datastore.Key) (userProfile *model.GlukitUser, err error)
- func LogFileImport(context context.Context, userProfileKey *datastore.Key, ...) (key *datastore.Key, err error)
- func StoreA1CBatch(context context.Context, userEmail string, a1cs []model.A1CEstimate) error
- func StoreCalibrationReads(context context.Context, userProfileKey *datastore.Key, ...) (keys []*datastore.Key, err error)
- func StoreDaysOfExercises(context context.Context, userProfileKey *datastore.Key, ...) (keys []*datastore.Key, err error)
- func StoreDaysOfInjections(context context.Context, userProfileKey *datastore.Key, ...) (keys []*datastore.Key, err error)
- func StoreDaysOfMeals(context context.Context, userProfileKey *datastore.Key, ...) (keys []*datastore.Key, err error)
- func StoreDaysOfReads(context context.Context, userProfileKey *datastore.Key, ...) (keys []*datastore.Key, err error)
- func StoreGlukitScoreBatch(context context.Context, userEmail string, glukitScores []model.GlukitScore) error
- func StoreUserProfile(context context.Context, updatedAt time.Time, userProfile model.GlukitUser) (key *datastore.Key, err error)
- type DataStoreCalibrationBatchWriter
- func (w *DataStoreCalibrationBatchWriter) Flush() (glukitio.CalibrationBatchWriter, error)
- func (w *DataStoreCalibrationBatchWriter) WriteCalibrationBatch(p []apimodel.CalibrationRead) (glukitio.CalibrationBatchWriter, error)
- func (w *DataStoreCalibrationBatchWriter) WriteCalibrationBatches(p []apimodel.DayOfCalibrationReads) (glukitio.CalibrationBatchWriter, error)
- type DataStoreExerciseBatchWriter
- func (w *DataStoreExerciseBatchWriter) Flush() (glukitio.ExerciseBatchWriter, error)
- func (w *DataStoreExerciseBatchWriter) WriteExerciseBatch(p []apimodel.Exercise) (glukitio.ExerciseBatchWriter, error)
- func (w *DataStoreExerciseBatchWriter) WriteExerciseBatches(p []apimodel.DayOfExercises) (glukitio.ExerciseBatchWriter, error)
- type DataStoreGlucoseReadBatchWriter
- func (w *DataStoreGlucoseReadBatchWriter) Flush() (glukitio.GlucoseReadBatchWriter, error)
- func (w *DataStoreGlucoseReadBatchWriter) WriteGlucoseReadBatch(p []apimodel.GlucoseRead) (glukitio.GlucoseReadBatchWriter, error)
- func (w *DataStoreGlucoseReadBatchWriter) WriteGlucoseReadBatches(p []apimodel.DayOfGlucoseReads) (glukitio.GlucoseReadBatchWriter, error)
- type DataStoreInjectionBatchWriter
- func (w *DataStoreInjectionBatchWriter) Flush() (glukitio.InjectionBatchWriter, error)
- func (w *DataStoreInjectionBatchWriter) WriteInjectionBatch(p []apimodel.Injection) (glukitio.InjectionBatchWriter, error)
- func (w *DataStoreInjectionBatchWriter) WriteInjectionBatches(p []apimodel.DayOfInjections) (glukitio.InjectionBatchWriter, error)
- type DataStoreMealBatchWriter
- type OsinAppEngineStore
- func (s *OsinAppEngineStore) GetClient(id string, r *http.Request) (*osin.Client, error)
- func (s *OsinAppEngineStore) GetClientWithContext(id string, context context.Context) (*osin.Client, error)
- func (s *OsinAppEngineStore) LoadAccess(code string, r *http.Request) (*osin.AccessData, error)
- func (s *OsinAppEngineStore) LoadAccessWithContext(code string, context context.Context) (*osin.AccessData, error)
- func (s *OsinAppEngineStore) LoadAuthorize(code string, r *http.Request) (*osin.AuthorizeData, error)
- func (s *OsinAppEngineStore) LoadAuthorizeWithContext(code string, context context.Context) (*osin.AuthorizeData, error)
- func (s *OsinAppEngineStore) LoadRefresh(code string, r *http.Request) (*osin.AccessData, error)
- func (s *OsinAppEngineStore) LoadRefreshWithContext(code string, context context.Context) (*osin.AccessData, error)
- func (s *OsinAppEngineStore) RemoveAccess(code string, r *http.Request) error
- func (s *OsinAppEngineStore) RemoveAccessWithContext(code string, context context.Context) error
- func (s *OsinAppEngineStore) RemoveAuthorize(code string, r *http.Request) error
- func (s *OsinAppEngineStore) RemoveAuthorizeWithContext(code string, context context.Context) error
- func (s *OsinAppEngineStore) RemoveRefresh(code string, r *http.Request) error
- func (s *OsinAppEngineStore) RemoveRefreshWithContext(code string, context context.Context) error
- func (s *OsinAppEngineStore) SaveAccess(data *osin.AccessData, r *http.Request) error
- func (s *OsinAppEngineStore) SaveAccessWithContext(data *osin.AccessData, context context.Context) error
- func (s *OsinAppEngineStore) SaveAuthorize(data *osin.AuthorizeData, r *http.Request) error
- func (s *OsinAppEngineStore) SaveAuthorizeWithContext(data *osin.AuthorizeData, context context.Context) error
- type ScoreScanQuery
- type StoreError
Constants ¶
const (
// Number of GlukitScores to batch in a single PutMulti
GLUKIT_SCORE_PUT_MULTI_SIZE = 10
)
Variables ¶
var ( // ErrNoImportedDataFound is returned when the user doesn't have data imported yet. ErrNoImportedDataFound = StoreError{"store: no imported data found", true} // ErrNoSteadySailorMatchFound is returned when the user doesn't have any steady sailor matching his profile ErrNoSteadySailorMatchFound = StoreError{"store: no match for a steady sailor found", true} )
Functions ¶
func FindSteadySailor ¶
func FindSteadySailor(context context.Context, recipientEmail string) (sailorProfile *model.GlukitUser, key *datastore.Key, upperBound time.Time, err error)
FindSteadySailor queries the datastore for others users of the same type of diabetes. It will then select the match that has a top glukit score and return that user profile along with the upper boundary for its most recent day of reads. The steps involved are:
- Find the user profile of the recipient
- Query the data store for profile data that matches (using the type of diabetes) in ascending order of score value
- A first time for users that are NOT internal
- A second time including internal users (if the first one returns no match)
- Filter out the recipient profile that could be returned in the search
- If match found, get the profile of the steady sailor
func GetA1CEstimates ¶
func GetA1CEstimates(context context.Context, email string, scanQuery ScoreScanQuery) (scores []model.A1CEstimate, err error)
GetA1CEstimates returns all a1c calculations for the given email address and matching the query parameters
func GetCalibrations ¶
func GetCalibrations(context context.Context, email string, lowerBound time.Time, upperBound time.Time) (meals []apimodel.CalibrationRead, err error)
GetCalibrations returns all Calibration entries given a user's email address and the time boundaries. Not that the boundaries are both inclusive.
func GetExercises ¶
func GetExercises(context context.Context, email string, lowerBound time.Time, upperBound time.Time) (exercises []apimodel.Exercise, err error)
GetExercises returns all Exercise entries given a user's email address and the time boundaries. Not that the boundaries are both inclusive.
func GetFileImportLog ¶
func GetFileImportLog(context context.Context, userProfileKey *datastore.Key, fileId string) (fileImport *model.FileImportLog, err error)
GetFileImportLog retrieves a FileImportLog entry for a given file id. If it's the first time we import this file id, a zeroed FileImportLog element is returned
func GetGlucoseReads ¶
func GetGlucoseReads(context context.Context, email string, lowerBound time.Time, upperBound time.Time) (reads []apimodel.GlucoseRead, err error)
GetGlucoseReads returns all GlucoseReads given a user's email address and the time boundaries. Not that the boundaries are both inclusive.
func GetGlukitScores ¶
func GetGlukitScores(context context.Context, email string, scanQuery ScoreScanQuery) (scores []model.GlukitScore, err error)
GetGlukitScores returns all GlukitScores for the given email address and matching the query parameters
func GetGlukitUser ¶
func GetGlukitUserWithKey ¶
func GetInjections ¶
func GetInjections(context context.Context, email string, lowerBound time.Time, upperBound time.Time) (meals []apimodel.Injection, err error)
GetInjections returns all Injection entries given a user's email address and the time boundaries. Not that the boundaries are both inclusive.
func GetMeals ¶
func GetMeals(context context.Context, email string, lowerBound time.Time, upperBound time.Time) (carbs []apimodel.Meal, err error)
GetMeals returns all Meal entries given a user's email address and the time boundaries. Not that the boundaries are both inclusive.
func GetUserData ¶
func GetUserData(context context.Context, email string) (userProfile *model.GlukitUser, key *datastore.Key, upperBound time.Time, err error)
GetUserData returns a GlukitUser entry and the boundaries of its most recent complete reads. If the user doesn't have any imported data yet, GetUserData returns ErrNoImportedDataFound
func GetUserKey ¶
GetUserKey returns the GlukitUser datastore key given its email address.
func GetUserProfile ¶
func GetUserProfile(context context.Context, key *datastore.Key) (userProfile *model.GlukitUser, err error)
GetUserProfile returns the GlukitUser entry associated with the given datastore key. This can be obtained by calling GetUserKey.
func LogFileImport ¶
func LogFileImport(context context.Context, userProfileKey *datastore.Key, fileImport model.FileImportLog) (key *datastore.Key, err error)
LogFileImport persist a log of a file import operation. A log entry is actually kept for each distinct file and NOT for every log import operation. That is, if we re-import and updated file, we should update the FileImportLog for that file but not create a new one. This is used to optimize and not reimport a file that hasn't been updated.
func StoreA1CBatch ¶
StoreA1CBatch stores a batch of A1C calculations. The array could be of any size. A large batch of A1CEstimates will be internally split into multiple PutMultis.
func StoreCalibrationReads ¶
func StoreCalibrationReads(context context.Context, userProfileKey *datastore.Key, daysOfCalibrationReads []apimodel.DayOfCalibrationReads) (keys []*datastore.Key, err error)
StoreCalibrationReads stores a batch of DayOfCalibrations elements. It is a optimized operation in that:
- One element represents a relatively short-and-wide entry of all calibration reads for a single day.
- We have multiple DayOfReads elements and we use a PutMulti to make this faster.
For details of how a single element of DayOfReads is physically stored, see the implementation of apimodel.Store and apimodel.Load.
func StoreDaysOfExercises ¶
func StoreDaysOfExercises(context context.Context, userProfileKey *datastore.Key, daysOfExercises []apimodel.DayOfExercises) (keys []*datastore.Key, err error)
StoreDaysOfExercises stores a batch of DayOfExercises elements. It is a optimized operation in that:
- One element represents a relatively short-and-wide entry of all Exercises for a single day.
- We have multiple DayOfExercises elements and we use a PutMulti to make this faster.
For details of how a single element of DayOfExercises is physically stored, see the implementation of apimodel.Store and apimodel.Load.
func StoreDaysOfInjections ¶
func StoreDaysOfInjections(context context.Context, userProfileKey *datastore.Key, daysOfInjections []apimodel.DayOfInjections) (keys []*datastore.Key, err error)
StoreDaysOfInjections stores a batch of DayOfInjections elements. It is a optimized operation in that:
- One element represents a relatively short-and-wide entry of all meals for a single day.
- We have multiple DayOfInjections elements and we use a PutMulti to make this faster.
For details of how a single element of DayOfInjections is physically stored, see the implementation of apimodel.Store and apimodel.Load.
func StoreDaysOfMeals ¶
func StoreDaysOfMeals(context context.Context, userProfileKey *datastore.Key, daysOfMeals []apimodel.DayOfMeals) (keys []*datastore.Key, err error)
StoreDaysOfMeals stores a batch of DayOfMeals elements. It is a optimized operation in that:
- One element represents a relatively short-and-wide entry of all Meals for a single day.
- We have multiple DayOfMeals elements and we use a PutMulti to make this faster.
For details of how a single element of DayOfMeals is physically stored, see the implementation of apimodel.Store and apimodel.Load.
func StoreDaysOfReads ¶
func StoreDaysOfReads(context context.Context, userProfileKey *datastore.Key, daysOfReads []apimodel.DayOfGlucoseReads) (keys []*datastore.Key, err error)
StoreDaysOfReads stores a batch of DayOfReads elements. It is a optimized operation in that:
- One element represents a relatively short-and-wide entry of all reads for a single day.
- We have multiple DayOfReads elements and we use a PutMulti to make this faster.
For details of how a single element of DayOfReads is physically stored, see the implementation of apimodel.Store and apimodel.Load. Also important to note, this store operation also handles updating the GlukitUser entry with the most recent read, if applicable.
func StoreGlukitScoreBatch ¶
func StoreGlukitScoreBatch(context context.Context, userEmail string, glukitScores []model.GlukitScore) error
StoreGlukitScoreBatch stores a batch of GlukitScores. The array could be of any size. A large batch of GlukitScores will be internally split into multiple PutMultis.
Types ¶
type DataStoreCalibrationBatchWriter ¶
type DataStoreCalibrationBatchWriter struct {
// contains filtered or unexported fields
}
func NewDataStoreCalibrationBatchWriter ¶
func NewDataStoreCalibrationBatchWriter(context context.Context, userProfileKey *datastore.Key) *DataStoreCalibrationBatchWriter
NewDataStoreCalibrationBatchWriter creates a new CalibrationBatchWriter that persists to the datastore
func (*DataStoreCalibrationBatchWriter) Flush ¶
func (w *DataStoreCalibrationBatchWriter) Flush() (glukitio.CalibrationBatchWriter, error)
func (*DataStoreCalibrationBatchWriter) WriteCalibrationBatch ¶
func (w *DataStoreCalibrationBatchWriter) WriteCalibrationBatch(p []apimodel.CalibrationRead) (glukitio.CalibrationBatchWriter, error)
func (*DataStoreCalibrationBatchWriter) WriteCalibrationBatches ¶
func (w *DataStoreCalibrationBatchWriter) WriteCalibrationBatches(p []apimodel.DayOfCalibrationReads) (glukitio.CalibrationBatchWriter, error)
type DataStoreExerciseBatchWriter ¶
type DataStoreExerciseBatchWriter struct {
// contains filtered or unexported fields
}
func NewDataStoreExerciseBatchWriter ¶
func NewDataStoreExerciseBatchWriter(context context.Context, userProfileKey *datastore.Key) *DataStoreExerciseBatchWriter
NewDataStoreExerciseBatchWriter creates a new ExerciseBatchWriter that persists to the datastore
func (*DataStoreExerciseBatchWriter) Flush ¶
func (w *DataStoreExerciseBatchWriter) Flush() (glukitio.ExerciseBatchWriter, error)
func (*DataStoreExerciseBatchWriter) WriteExerciseBatch ¶
func (w *DataStoreExerciseBatchWriter) WriteExerciseBatch(p []apimodel.Exercise) (glukitio.ExerciseBatchWriter, error)
func (*DataStoreExerciseBatchWriter) WriteExerciseBatches ¶
func (w *DataStoreExerciseBatchWriter) WriteExerciseBatches(p []apimodel.DayOfExercises) (glukitio.ExerciseBatchWriter, error)
type DataStoreGlucoseReadBatchWriter ¶
type DataStoreGlucoseReadBatchWriter struct {
// contains filtered or unexported fields
}
func NewDataStoreGlucoseReadBatchWriter ¶
func NewDataStoreGlucoseReadBatchWriter(context context.Context, userProfileKey *datastore.Key) *DataStoreGlucoseReadBatchWriter
NewDataStoreGlucoseReadBatchWriter creates a new GlucoseReadBatchWriter that persists to the datastore
func (*DataStoreGlucoseReadBatchWriter) Flush ¶
func (w *DataStoreGlucoseReadBatchWriter) Flush() (glukitio.GlucoseReadBatchWriter, error)
func (*DataStoreGlucoseReadBatchWriter) WriteGlucoseReadBatch ¶
func (w *DataStoreGlucoseReadBatchWriter) WriteGlucoseReadBatch(p []apimodel.GlucoseRead) (glukitio.GlucoseReadBatchWriter, error)
func (*DataStoreGlucoseReadBatchWriter) WriteGlucoseReadBatches ¶
func (w *DataStoreGlucoseReadBatchWriter) WriteGlucoseReadBatches(p []apimodel.DayOfGlucoseReads) (glukitio.GlucoseReadBatchWriter, error)
type DataStoreInjectionBatchWriter ¶
type DataStoreInjectionBatchWriter struct {
// contains filtered or unexported fields
}
func NewDataStoreInjectionBatchWriter ¶
func NewDataStoreInjectionBatchWriter(context context.Context, userProfileKey *datastore.Key) *DataStoreInjectionBatchWriter
NewDataStoreInjectionBatchWriter creates a new InjectionBatchWriter that persists to the datastore
func (*DataStoreInjectionBatchWriter) Flush ¶
func (w *DataStoreInjectionBatchWriter) Flush() (glukitio.InjectionBatchWriter, error)
func (*DataStoreInjectionBatchWriter) WriteInjectionBatch ¶
func (w *DataStoreInjectionBatchWriter) WriteInjectionBatch(p []apimodel.Injection) (glukitio.InjectionBatchWriter, error)
func (*DataStoreInjectionBatchWriter) WriteInjectionBatches ¶
func (w *DataStoreInjectionBatchWriter) WriteInjectionBatches(p []apimodel.DayOfInjections) (glukitio.InjectionBatchWriter, error)
type DataStoreMealBatchWriter ¶
type DataStoreMealBatchWriter struct {
// contains filtered or unexported fields
}
func NewDataStoreMealBatchWriter ¶
func NewDataStoreMealBatchWriter(context context.Context, userProfileKey *datastore.Key) *DataStoreMealBatchWriter
NewDataStoreMealBatchWriter creates a new MealBatchWriter that persists to the datastore
func (*DataStoreMealBatchWriter) Flush ¶
func (w *DataStoreMealBatchWriter) Flush() (glukitio.MealBatchWriter, error)
func (*DataStoreMealBatchWriter) WriteMealBatch ¶
func (w *DataStoreMealBatchWriter) WriteMealBatch(p []apimodel.Meal) (glukitio.MealBatchWriter, error)
func (*DataStoreMealBatchWriter) WriteMealBatches ¶
func (w *DataStoreMealBatchWriter) WriteMealBatches(p []apimodel.DayOfMeals) (glukitio.MealBatchWriter, error)
type OsinAppEngineStore ¶
type OsinAppEngineStore struct { }
func NewOsinAppEngineStoreWithContext ¶
func NewOsinAppEngineStoreWithContext(c context.Context) *OsinAppEngineStore
func NewOsinAppEngineStoreWithRequest ¶
func NewOsinAppEngineStoreWithRequest(r *http.Request) *OsinAppEngineStore
func (*OsinAppEngineStore) GetClientWithContext ¶
func (*OsinAppEngineStore) LoadAccess ¶
func (s *OsinAppEngineStore) LoadAccess(code string, r *http.Request) (*osin.AccessData, error)
func (*OsinAppEngineStore) LoadAccessWithContext ¶
func (s *OsinAppEngineStore) LoadAccessWithContext(code string, context context.Context) (*osin.AccessData, error)
func (*OsinAppEngineStore) LoadAuthorize ¶
func (s *OsinAppEngineStore) LoadAuthorize(code string, r *http.Request) (*osin.AuthorizeData, error)
func (*OsinAppEngineStore) LoadAuthorizeWithContext ¶
func (s *OsinAppEngineStore) LoadAuthorizeWithContext(code string, context context.Context) (*osin.AuthorizeData, error)
func (*OsinAppEngineStore) LoadRefresh ¶
func (s *OsinAppEngineStore) LoadRefresh(code string, r *http.Request) (*osin.AccessData, error)
func (*OsinAppEngineStore) LoadRefreshWithContext ¶
func (s *OsinAppEngineStore) LoadRefreshWithContext(code string, context context.Context) (*osin.AccessData, error)
func (*OsinAppEngineStore) RemoveAccess ¶
func (s *OsinAppEngineStore) RemoveAccess(code string, r *http.Request) error
func (*OsinAppEngineStore) RemoveAccessWithContext ¶
func (s *OsinAppEngineStore) RemoveAccessWithContext(code string, context context.Context) error
func (*OsinAppEngineStore) RemoveAuthorize ¶
func (s *OsinAppEngineStore) RemoveAuthorize(code string, r *http.Request) error
func (*OsinAppEngineStore) RemoveAuthorizeWithContext ¶
func (s *OsinAppEngineStore) RemoveAuthorizeWithContext(code string, context context.Context) error
func (*OsinAppEngineStore) RemoveRefresh ¶
func (s *OsinAppEngineStore) RemoveRefresh(code string, r *http.Request) error
func (*OsinAppEngineStore) RemoveRefreshWithContext ¶
func (s *OsinAppEngineStore) RemoveRefreshWithContext(code string, context context.Context) error
func (*OsinAppEngineStore) SaveAccess ¶
func (s *OsinAppEngineStore) SaveAccess(data *osin.AccessData, r *http.Request) error
func (*OsinAppEngineStore) SaveAccessWithContext ¶
func (s *OsinAppEngineStore) SaveAccessWithContext(data *osin.AccessData, context context.Context) error
func (*OsinAppEngineStore) SaveAuthorize ¶
func (s *OsinAppEngineStore) SaveAuthorize(data *osin.AuthorizeData, r *http.Request) error
func (*OsinAppEngineStore) SaveAuthorizeWithContext ¶
func (s *OsinAppEngineStore) SaveAuthorizeWithContext(data *osin.AuthorizeData, context context.Context) error
type StoreError ¶
type StoreError struct { Temporary bool // Is the error temporary? // contains filtered or unexported fields }
Error interface to distinguish between temporary errors from permanent ones
func (StoreError) Error ¶
func (e StoreError) Error() string