db

package
v0.0.0-...-64e57e2 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddCarbonFootprintGoalParams

type AddCarbonFootprintGoalParams struct {
	UserID                int32
	Description           string
	StartDate             pgtype.Date
	EndDate               pgtype.Date
	StartCarbonFootprint  decimal.Decimal
	TargetCarbonFootprint decimal.Decimal
}

type AddDeviceParams

type AddDeviceParams struct {
	UserID   int32
	FcmToken string
}

type AddFoodItemToLogParams

type AddFoodItemToLogParams struct {
	FoodItemID      int32
	Quantity        decimal.Decimal
	UserID          int32
	LogDate         pgtype.Date
	Unit            int32
	Region          int32
	CarbonFootprint decimal.Decimal
	Meal            int32
}

type AggregateFoodItem

type AggregateFoodItem struct {
	FoodItemID            int32
	N                     int64
	MedianCarbonFootprint decimal.Decimal
}

type CarbonFootprintGoal

type CarbonFootprintGoal struct {
	ID                    int32
	UserID                int32
	Description           string
	StartDate             pgtype.Date
	EndDate               pgtype.Date
	StartCarbonFootprint  decimal.Decimal
	TargetCarbonFootprint decimal.Decimal
	Completed             bool
}

type CfTypes

type CfTypes string
const (
	CfTypesTypology    CfTypes = "typology"
	CfTypesSubTypology CfTypes = "sub_typology"
	CfTypesItem        CfTypes = "item"
)

func (*CfTypes) Scan

func (e *CfTypes) Scan(src interface{}) error

type CreateFoodItemParams

type CreateFoodItemParams struct {
	Name        string
	TypologyID  int32
	SuggestedCf CfTypes
}

type CreateLifeCycleParams

type CreateLifeCycleParams struct {
	CarbonFootprint decimal.Decimal
	FoodItemID      int32
	SourceID        int32
}

type CreateSourceParams

type CreateSourceParams struct {
	Reference string
	Year      int32
	Region    int32
}

type CreateTypologyParams

type CreateTypologyParams struct {
	Name          string
	SubTypologyID *int32
}

type CreateUserParams

type CreateUserParams struct {
	FirebaseUid        string
	Region             int32
	CfLimit            decimal.Decimal
	DietaryRequirement int32
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
	SendBatch(context.Context, *pgx.Batch) pgx.BatchResults
}

type DailyUserAverage

type DailyUserAverage struct {
	AverageCarbonFootprint decimal.Decimal
}

type DailyUserAverageByDietaryRequirement

type DailyUserAverageByDietaryRequirement struct {
	AverageCarbonFootprint decimal.Decimal
	DietaryRequirement     int32
}

type DeleteCarbonFootprintGoalParams

type DeleteCarbonFootprintGoalParams struct {
	UserID int32
	ID     int32
}

type DeleteDeviceBatchResults

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

func (*DeleteDeviceBatchResults) Close

func (b *DeleteDeviceBatchResults) Close() error

func (*DeleteDeviceBatchResults) Exec

func (b *DeleteDeviceBatchResults) Exec(f func(int, error))

type DeleteFoodItemFromLogParams

type DeleteFoodItemFromLogParams struct {
	UserID int32
	ID     int32
}

type Device

type Device struct {
	ID        int32
	UserID    int32
	FcmToken  string
	CreatedAt pgtype.Timestamptz
	UpdatedAt pgtype.Timestamptz
}

type FoodItem

type FoodItem struct {
	ID          int32
	Name        string
	TypologyID  int32
	SuggestedCf CfTypes
}

type FoodItemLog

type FoodItemLog struct {
	ID              int32
	FoodItemID      int32
	Quantity        decimal.Decimal
	CreatedAt       pgtype.Timestamptz
	UpdatedAt       pgtype.Timestamptz
	UserID          int32
	LogDate         pgtype.Date
	Unit            int32
	Region          int32
	CarbonFootprint decimal.Decimal
	Meal            int32
}

type GetDailyCarbonFootprintByDateRangeParams

type GetDailyCarbonFootprintByDateRangeParams struct {
	UserID    int32
	StartDate pgtype.Date
	EndDate   pgtype.Date
}

type GetDailyCarbonFootprintByDateRangeRow

type GetDailyCarbonFootprintByDateRangeRow struct {
	CarbonFootprint decimal.Decimal
	LogDate         pgtype.Date
	Meal            int32
}

type GetFoodItemInfoByRegionParams

type GetFoodItemInfoByRegionParams struct {
	FoodItemID int32
	Region     int32
}

type GetFoodItemInfoByRegionRow

type GetFoodItemInfoByRegionRow struct {
	TypologyName    string
	SubTypologyName pgtype.Text
	N               int64
}

type GetFoodItemInfoRow

type GetFoodItemInfoRow struct {
	TypologyName    string
	SubTypologyName pgtype.Text
	N               int64
}

type GetFoodItemLogByDateParams

type GetFoodItemLogByDateParams struct {
	UserID  int32
	LogDate pgtype.Date
}

type GetFoodItemLogByDateRow

type GetFoodItemLogByDateRow struct {
	ID              int32
	Name            string
	FoodItemID      int32
	Region          int32
	Quantity        decimal.Decimal
	Unit            int32
	LogDate         pgtype.Date
	Meal            int32
	CarbonFootprint decimal.Decimal
}

type GetFoodItemLogStreakRow

type GetFoodItemLogStreakRow struct {
	ConsecutiveDates int64
	StartDate        pgtype.Date
	EndDate          pgtype.Date
	Active           bool
}

type GetLoggedDaysInMonthParams

type GetLoggedDaysInMonthParams struct {
	UserID int32
	Month  int32
	Year   int32
}

type GetRegionalAggregateFoodItemParams

type GetRegionalAggregateFoodItemParams struct {
	FoodItemID int32
	Region     int32
}

type LifeCycle

type LifeCycle struct {
	ID              int32
	CarbonFootprint decimal.Decimal
	FoodItemID      int32
	SourceID        int32
}

type ListAggregateFoodItemsByRegionRow

type ListAggregateFoodItemsByRegionRow struct {
	ID                    int32
	FoodName              string
	TypologyName          string
	SubTypologyName       pgtype.Text
	N                     int64
	MedianCarbonFootprint decimal.Decimal
}

type ListAggregateFoodItemsRow

type ListAggregateFoodItemsRow struct {
	ID                    int32
	FoodName              string
	TypologyName          string
	SubTypologyName       pgtype.Text
	N                     int64
	MedianCarbonFootprint decimal.Decimal
}

type ListAggregateSubTypologiesByRegionRow

type ListAggregateSubTypologiesByRegionRow struct {
	SubTypologyID         int32
	N                     int64
	MedianCarbonFootprint decimal.Decimal
}

type ListAggregateTypologiesByRegionRow

type ListAggregateTypologiesByRegionRow struct {
	TypologyID            int32
	N                     int64
	MedianCarbonFootprint decimal.Decimal
}

type ListSourcesByFoodItemAndRegionParams

type ListSourcesByFoodItemAndRegionParams struct {
	FoodItemID int32
	Region     int32
}

type ListSourcesByFoodItemAndRegionRow

type ListSourcesByFoodItemAndRegionRow struct {
	Reference string
	Year      int32
	Region    int32
}

type ListSourcesByFoodItemRow

type ListSourcesByFoodItemRow struct {
	Reference string
	Year      int32
	Region    int32
}

type NullCfTypes

type NullCfTypes struct {
	CfTypes CfTypes
	Valid   bool // Valid is true if CfTypes is not NULL
}

func (*NullCfTypes) Scan

func (ns *NullCfTypes) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullCfTypes) Value

func (ns NullCfTypes) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) AddCarbonFootprintGoal

func (q *Queries) AddCarbonFootprintGoal(ctx context.Context, arg AddCarbonFootprintGoalParams) (int32, error)

func (*Queries) AddDevice

func (q *Queries) AddDevice(ctx context.Context, arg AddDeviceParams) error

func (*Queries) AddFoodItemToLog

func (q *Queries) AddFoodItemToLog(ctx context.Context, arg AddFoodItemToLogParams) (int32, error)

func (*Queries) CreateFoodItem

func (q *Queries) CreateFoodItem(ctx context.Context, arg CreateFoodItemParams) (int32, error)

func (*Queries) CreateLifeCycle

func (q *Queries) CreateLifeCycle(ctx context.Context, arg CreateLifeCycleParams) (int32, error)

func (*Queries) CreateSource

func (q *Queries) CreateSource(ctx context.Context, arg CreateSourceParams) (int32, error)

func (*Queries) CreateSubTypology

func (q *Queries) CreateSubTypology(ctx context.Context, name string) (int32, error)

func (*Queries) CreateTypology

func (q *Queries) CreateTypology(ctx context.Context, arg CreateTypologyParams) (int32, error)

func (*Queries) CreateUser

func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (int32, error)

func (*Queries) DeleteCarbonFootprintGoal

func (q *Queries) DeleteCarbonFootprintGoal(ctx context.Context, arg DeleteCarbonFootprintGoalParams) error

func (*Queries) DeleteDevice

func (q *Queries) DeleteDevice(ctx context.Context, id []int32) *DeleteDeviceBatchResults

func (*Queries) DeleteDeviceByUser

func (q *Queries) DeleteDeviceByUser(ctx context.Context, userID int32) error

func (*Queries) DeleteFoodItemFromLog

func (q *Queries) DeleteFoodItemFromLog(ctx context.Context, arg DeleteFoodItemFromLogParams) error

func (*Queries) DeleteUserByFirebaseUID

func (q *Queries) DeleteUserByFirebaseUID(ctx context.Context, firebaseUid string) error

func (*Queries) GetActiveCarbonFootprintGoals

func (q *Queries) GetActiveCarbonFootprintGoals(ctx context.Context, userID int32) ([]CarbonFootprintGoal, error)

func (*Queries) GetAggregateFoodItem

func (q *Queries) GetAggregateFoodItem(ctx context.Context, foodItemID int32) (AggregateFoodItem, error)

func (*Queries) GetCarbonFootprintGoals

func (q *Queries) GetCarbonFootprintGoals(ctx context.Context, userID int32) ([]CarbonFootprintGoal, error)

func (*Queries) GetDailyAverageCarbonFootprint

func (q *Queries) GetDailyAverageCarbonFootprint(ctx context.Context) (decimal.Decimal, error)

func (*Queries) GetDailyAverageCarbonFootprintByDietaryRequirement

func (q *Queries) GetDailyAverageCarbonFootprintByDietaryRequirement(ctx context.Context, dietaryRequirement int32) (decimal.Decimal, error)

func (*Queries) GetDevices

func (q *Queries) GetDevices(ctx context.Context) ([]Device, error)

func (*Queries) GetFoodItemIdByLogId

func (q *Queries) GetFoodItemIdByLogId(ctx context.Context, id int32) (int32, error)

func (*Queries) GetFoodItemInfo

func (q *Queries) GetFoodItemInfo(ctx context.Context, foodItemID int32) (GetFoodItemInfoRow, error)

func (*Queries) GetFoodItemInfoByRegion

func (q *Queries) GetFoodItemInfoByRegion(ctx context.Context, arg GetFoodItemInfoByRegionParams) (GetFoodItemInfoByRegionRow, error)

func (*Queries) GetFoodItemLogByDate

func (q *Queries) GetFoodItemLogByDate(ctx context.Context, arg GetFoodItemLogByDateParams) ([]GetFoodItemLogByDateRow, error)

func (*Queries) GetFoodItemLogStreak

func (q *Queries) GetFoodItemLogStreak(ctx context.Context, userID int32) (GetFoodItemLogStreakRow, error)

Generate "groups" of dates by subtracting the date's row number (no gaps) from the date itself (with potential gaps). Whenever there is a gap, there will be a new group

func (*Queries) GetLoggedDaysInMonth

func (q *Queries) GetLoggedDaysInMonth(ctx context.Context, arg GetLoggedDaysInMonthParams) ([]int32, error)

func (*Queries) GetRegionalAggregateFoodItem

func (q *Queries) GetRegionalAggregateFoodItem(ctx context.Context, arg GetRegionalAggregateFoodItemParams) (RegionalAggregateFoodItem, error)

func (*Queries) GetUserByFirebaseUID

func (q *Queries) GetUserByFirebaseUID(ctx context.Context, firebaseUid string) (User, error)

func (*Queries) GetUserDailyAverageCarbonFootprint

func (q *Queries) GetUserDailyAverageCarbonFootprint(ctx context.Context, userID int32) (decimal.Decimal, error)

func (*Queries) GetUserIDs

func (q *Queries) GetUserIDs(ctx context.Context) ([]int32, error)

func (*Queries) ListAggregateFoodItems

func (q *Queries) ListAggregateFoodItems(ctx context.Context) ([]ListAggregateFoodItemsRow, error)

func (*Queries) ListAggregateFoodItemsByRegion

func (q *Queries) ListAggregateFoodItemsByRegion(ctx context.Context, region int32) ([]ListAggregateFoodItemsByRegionRow, error)

func (*Queries) ListAggregateSubTypologiesByRegion

func (q *Queries) ListAggregateSubTypologiesByRegion(ctx context.Context, region int32) ([]ListAggregateSubTypologiesByRegionRow, error)

func (*Queries) ListAggregateTypologiesByRegion

func (q *Queries) ListAggregateTypologiesByRegion(ctx context.Context, region int32) ([]ListAggregateTypologiesByRegionRow, error)

func (*Queries) ListSourcesByFoodItem

func (q *Queries) ListSourcesByFoodItem(ctx context.Context, foodItemID int32) ([]ListSourcesByFoodItemRow, error)

func (*Queries) ListSubTypologyNames

func (q *Queries) ListSubTypologyNames(ctx context.Context) ([]string, error)

func (*Queries) ListTypologyNames

func (q *Queries) ListTypologyNames(ctx context.Context) ([]string, error)

func (*Queries) UpdateCarbonFootprintGoal

func (q *Queries) UpdateCarbonFootprintGoal(ctx context.Context, arg UpdateCarbonFootprintGoalParams) error

func (*Queries) UpdateFoodItemFromLog

func (q *Queries) UpdateFoodItemFromLog(ctx context.Context, arg UpdateFoodItemFromLogParams) error

func (*Queries) UpdateUserSettings

func (q *Queries) UpdateUserSettings(ctx context.Context, arg UpdateUserSettingsParams) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type RegionalAggregateFoodItem

type RegionalAggregateFoodItem struct {
	FoodItemID            int32
	Region                int32
	N                     int64
	MedianCarbonFootprint decimal.Decimal
}

type Source

type Source struct {
	ID        int32
	Reference string
	Year      int32
	Region    int32
}

type SubTypology

type SubTypology struct {
	ID   int32
	Name string
}

type Typology

type Typology struct {
	ID            int32
	Name          string
	SubTypologyID *int32
}

type UpdateCarbonFootprintGoalParams

type UpdateCarbonFootprintGoalParams struct {
	UserID    int32
	ID        int32
	Completed bool
}

type UpdateFoodItemFromLogParams

type UpdateFoodItemFromLogParams struct {
	UserID          int32
	ID              int32
	Quantity        decimal.Decimal
	Unit            int32
	CarbonFootprint decimal.Decimal
	Meal            int32
}

type UpdateUserSettingsParams

type UpdateUserSettingsParams struct {
	FirebaseUid        string
	Region             int32
	CfLimit            decimal.Decimal
	DietaryRequirement int32
}

type User

type User struct {
	ID                 int32
	FirebaseUid        string
	Region             int32
	CfLimit            decimal.Decimal
	CreatedAt          pgtype.Timestamptz
	UpdatedAt          pgtype.Timestamptz
	DietaryRequirement int32
}

Jump to

Keyboard shortcuts

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