nutrition

package module
v0.0.0-...-3e31d27 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: AGPL-3.0 Imports: 3 Imported by: 3

README

Nutrition Data

In my quest to make a meal planning program, one of the biggest obstacles has proven to be gathering the necessary data and rendering it useful. This repository holds some of the artifacts of that effort.

Each subdirectory has its own makefile for retrieving nutrition data and putting it into an SQLite database. Most of them also have their own READMEs describing the data and the rationale behind including it.

The SQLite code generated by the Go module in the db subdirectory pulls from the databases compiled in the other subdirectories to create the SQLite database meant to be used with the other parts of the project. If there is a primary "deliverable" here, it's the resulting nutrition.db file. It must be built last due to its dependency on the other databases.

Because of the large number of columns involved, main.go in the db subdirectory dynamically renders the contents of nutrition.sql from the columns maps in constants.go. The nutrition.sql file should not need to be rebuilt unless you want to change some aspect of nutrition.db's schema or the process by which it imports data from the USDA databases generated in the usda-* subdirectories.

The makefile in the current directory does not build the databases in the subdirectories. It only builds README.md and README.gmi from the README.lml source file.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ColumnToLabel map[string]string = map[string]string{}/* 148 elements not displayed */
View Source
var IdToColumn map[string]string = map[string]string{}/* 148 elements not displayed */

Functions

func Columns

func Columns() []string

func NutrientLabel

func NutrientLabel(name string) (string, bool)

func RenderGormModels

func RenderGormModels() string

func RenderQueriesSQL

func RenderQueriesSQL() string

func RenderSchemaSQL

func RenderSchemaSQL() string

func RenderSetupSQL

func RenderSetupSQL() string

func StructFieldNames

func StructFieldNames() []string

Types

type NutritionData

type NutritionData struct {
	ID                           uint
	Recipe                       bool
	Name                         string `gorm:"uniqueIndex"`
	Source                       string `gorm:"not null"`
	Units                        []Unit
	Tags                         []Tag
	TotalVitaminDIu              float64 `gorm:"column:total_vitamin_d_iu"`
	Phenylalanine                float64 `gorm:"column:phenylalanine"`
	Alanine                      float64 `gorm:"column:alanine"`
	Proline                      float64 `gorm:"column:proline"`
	Pufa182N6CC                  float64 `gorm:"column:pufa_18_2_n6_c_c"`
	Pufa203N3                    float64 `gorm:"column:pufa_20_3_n3"`
	Pufa24N6                     float64 `gorm:"column:pufa_2_4_n6"`
	Energy                       float64 `gorm:"column:energy"`
	Threonine                    float64 `gorm:"column:threonine"`
	Isoleucine                   float64 `gorm:"column:isoleucine"`
	Mufa161                      float64 `gorm:"column:mufa_16_1"`
	Sodium                       float64 `gorm:"column:sodium"`
	BetaCryptoxanthin            float64 `gorm:"column:beta_cryptoxanthin"`
	AlphaTocotrienol             float64 `gorm:"column:alpha_tocotrienol"`
	Copper                       float64 `gorm:"column:copper"`
	Manganese                    float64 `gorm:"column:manganese"`
	VitaminKPhylloquinone        float64 `gorm:"column:vitamin_k_phylloquinone"`
	Tfa182TT                     float64 `gorm:"column:tfa_18_2_t_t"`
	Sucrose                      float64 `gorm:"column:sucrose"`
	Cholesterol                  float64 `gorm:"column:cholesterol"`
	Pufa205N3Epa                 float64 `gorm:"column:pufa_20_5_n3_epa"`
	TotalTranspolyenoicFat       float64 `gorm:"column:total_transpolyenoic_fat"`
	Pufa183N3CCCAla              float64 `gorm:"column:pufa_18_3_n3_c_c_c_ala"`
	Selenium                     float64 `gorm:"column:selenium"`
	TotalFolate                  float64 `gorm:"column:total_folate"`
	Lysine                       float64 `gorm:"column:lysine"`
	Mufa181                      float64 `gorm:"column:mufa_18_1"`
	Pufa204                      float64 `gorm:"column:pufa_20_4"`
	GammaTocopherol              float64 `gorm:"column:gamma_tocopherol"`
	DeltaTocopherol              float64 `gorm:"column:delta_tocopherol"`
	Cystine                      float64 `gorm:"column:cystine"`
	Pufa224                      float64 `gorm:"column:pufa_22_4"`
	Lactose                      float64 `gorm:"column:lactose"`
	Caffeine                     float64 `gorm:"column:caffeine"`
	Niacin                       float64 `gorm:"column:niacin"`
	Leucine                      float64 `gorm:"column:leucine"`
	TotalSaturatedFat            float64 `gorm:"column:total_saturated_fat"`
	Sfa180                       float64 `gorm:"column:sfa_18_0"`
	Phosphorus                   float64 `gorm:"column:phosphorus"`
	VitaminA                     float64 `gorm:"column:vitamin_a"`
	FolicAcid                    float64 `gorm:"column:folic_acid"`
	TotalTransFat                float64 `gorm:"column:total_trans_fat"`
	Sfa40                        float64 `gorm:"column:sfa_4_0"`
	Pufa202N6CC                  float64 `gorm:"column:pufa_20_2_n6_c_c"`
	Mufa171                      float64 `gorm:"column:mufa_17_1"`
	Maltose                      float64 `gorm:"column:maltose"`
	VitaminE                     float64 `gorm:"column:vitamin_e"`
	TotalVitaminD                float64 `gorm:"column:total_vitamin_d"`
	Valine                       float64 `gorm:"column:valine"`
	Arginine                     float64 `gorm:"column:arginine"`
	AddedVitaminB12              float64 `gorm:"column:added_vitamin_b12"`
	Sfa120                       float64 `gorm:"column:sfa_12_0"`
	Galactose                    float64 `gorm:"column:galactose"`
	Fluoride                     float64 `gorm:"column:fluoride"`
	Sfa60                        float64 `gorm:"column:sfa_6_0"`
	Tfa161T                      float64 `gorm:"column:tfa_16_1_t"`
	Pufa215                      float64 `gorm:"column:pufa_21_5"`
	VitaminB6                    float64 `gorm:"column:vitamin_b6"`
	VitaminB12                   float64 `gorm:"column:vitamin_b12"`
	TotalMonounsaturatedFat      float64 `gorm:"column:total_monounsaturated_fat"`
	Mufa181C                     float64 `gorm:"column:mufa_18_1_c"`
	Mufa151                      float64 `gorm:"column:mufa_15_1"`
	Choline                      float64 `gorm:"column:choline"`
	Methionine                   float64 `gorm:"column:methionine"`
	Phytosterols                 float64 `gorm:"column:phytosterols"`
	TotalTransmonoenoicFat       float64 `gorm:"column:total_transmonoenoic_fat"`
	Betaine                      float64 `gorm:"column:betaine"`
	GammaTocotrienol             float64 `gorm:"column:gamma_tocotrienol"`
	Sfa140                       float64 `gorm:"column:sfa_14_0"`
	Pufa184                      float64 `gorm:"column:pufa_18_4"`
	Campesterol                  float64 `gorm:"column:campesterol"`
	TotalPolyunsaturatedFat      float64 `gorm:"column:total_polyunsaturated_fat"`
	Sfa170                       float64 `gorm:"column:sfa_17_0"`
	Alcohol                      float64 `gorm:"column:alcohol"`
	VitaminAIu                   float64 `gorm:"column:vitamin_a_iu"`
	DeltaTocotrienol             float64 `gorm:"column:delta_tocotrienol"`
	Thiamin                      float64 `gorm:"column:thiamin"`
	Riboflavin                   float64 `gorm:"column:riboflavin"`
	Tryptophan                   float64 `gorm:"column:tryptophan"`
	GlutamicAcid                 float64 `gorm:"column:glutamic_acid"`
	Hydroxyproline               float64 `gorm:"column:hydroxyproline"`
	Sfa80                        float64 `gorm:"column:sfa_8_0"`
	Mufa221C                     float64 `gorm:"column:mufa_22_1_c"`
	TotalSugar                   float64 `gorm:"column:total_sugar"`
	Iron                         float64 `gorm:"column:iron"`
	Pufa183                      float64 `gorm:"column:pufa_18_3"`
	BetaSitosterol               float64 `gorm:"column:beta_sitosterol"`
	Tfa181T                      float64 `gorm:"column:tfa_18_1_t"`
	Ash                          float64 `gorm:"column:ash"`
	Sfa160                       float64 `gorm:"column:sfa_16_0"`
	Protein                      float64 `gorm:"column:protein"`
	Fiber                        float64 `gorm:"column:fiber"`
	AddedVitaminE                float64 `gorm:"column:added_vitamin_e"`
	Sfa240                       float64 `gorm:"column:sfa_24_0"`
	Pufa204N6                    float64 `gorm:"column:pufa_20_4_n6"`
	Theobromine                  float64 `gorm:"column:theobromine"`
	VitaminKMenaquinone4         float64 `gorm:"column:vitamin_k_menaquinone4"`
	DfeFolate                    float64 `gorm:"column:dfe_folate"`
	Glycine                      float64 `gorm:"column:glycine"`
	AlphaCarotene                float64 `gorm:"column:alpha_carotene"`
	Tfa221T                      float64 `gorm:"column:tfa_22_1_t"`
	LuteinAndZeaxanthin          float64 `gorm:"column:lutein_and_zeaxanthin"`
	Mufa141                      float64 `gorm:"column:mufa_14_1"`
	Tfa182TNotFurtherDefined     float64 `gorm:"column:tfa_18_2_t_not_further_defined"`
	Pufa182I                     float64 `gorm:"column:pufa_18_2_i"`
	Pufa203                      float64 `gorm:"column:pufa_20_3"`
	Magnesium                    float64 `gorm:"column:magnesium"`
	FoodFolate                   float64 `gorm:"column:food_folate"`
	AsparticAcid                 float64 `gorm:"column:aspartic_acid"`
	VitaminD3                    float64 `gorm:"column:vitamin_d3"`
	Tyrosine                     float64 `gorm:"column:tyrosine"`
	Mufa201                      float64 `gorm:"column:mufa_20_1"`
	BetaTocopherol               float64 `gorm:"column:beta_tocopherol"`
	Serine                       float64 `gorm:"column:serine"`
	Sfa150                       float64 `gorm:"column:sfa_15_0"`
	Pufa183I                     float64 `gorm:"column:pufa_18_3i"`
	Potassium                    float64 `gorm:"column:potassium"`
	Pufa225N3Dpa                 float64 `gorm:"column:pufa_22_5_n3_dpa"`
	Mufa161C                     float64 `gorm:"column:mufa_16_1_c"`
	Carbohydrate                 float64 `gorm:"column:carbohydrate"`
	Glucose                      float64 `gorm:"column:glucose"`
	Calcium                      float64 `gorm:"column:calcium"`
	PantothenicAcid              float64 `gorm:"column:pantothenic_acid"`
	Pufa182                      float64 `gorm:"column:pufa_18_2"`
	Stigmasterol                 float64 `gorm:"column:stigmasterol"`
	Fructose                     float64 `gorm:"column:fructose"`
	Retinol                      float64 `gorm:"column:retinol"`
	Pufa182Clas                  float64 `gorm:"column:pufa_18_2_clas"`
	Mufa241C                     float64 `gorm:"column:mufa_24_1_c"`
	Sfa130                       float64 `gorm:"column:sfa_13_0"`
	Water                        float64 `gorm:"column:water"`
	BetaCarotene                 float64 `gorm:"column:beta_carotene"`
	VitaminD2                    float64 `gorm:"column:vitamin_d2"`
	VitaminKDihydrophylloquinone float64 `gorm:"column:vitamin_k_dihydrophylloquinone"`
	Histidine                    float64 `gorm:"column:histidine"`
	Sfa100                       float64 `gorm:"column:sfa_10_0"`
	Mufa221                      float64 `gorm:"column:mufa_22_1"`
	Lycopene                     float64 `gorm:"column:lycopene"`
	BetaTocotrienol              float64 `gorm:"column:beta_tocotrienol"`
	VitaminC                     float64 `gorm:"column:vitamin_c"`
	Sfa200                       float64 `gorm:"column:sfa_20_0"`
	Pufa226N3Dha                 float64 `gorm:"column:pufa_22_6_n3_dha"`
	Sfa220                       float64 `gorm:"column:sfa_22_0"`
	Pufa183N6CCC                 float64 `gorm:"column:pufa_18_3_n6_c_c_c"`
	TotalFat                     float64 `gorm:"column:total_fat"`
	Starch                       float64 `gorm:"column:starch"`
	Zinc                         float64 `gorm:"column:zinc"`
	Mufa18111T181TN7             float64 `gorm:"column:mufa_18_1_11_t_18_1t_n7"`
}

func (NutritionData) Add

func (NutritionData) Multiply

func (nd NutritionData) Multiply(mul float64) NutritionData

func (NutritionData) NutrientMap

func (nd NutritionData) NutrientMap() map[string]float64

func (NutritionData) TableName

func (NutritionData) TableName() string

type NutritionDataAutocomplete

type NutritionDataAutocomplete struct {
	ID   uint `gorm:"column:rowid"`
	Name string
}

func (NutritionDataAutocomplete) TableName

func (NutritionDataAutocomplete) TableName() string

type Tag

type Tag struct {
	NutritionDataID uint   `gorm:"index:tags_nutrition_data_id_index"`
	Name            string `gorm:"not null"`
}

type TagAutocomplete

type TagAutocomplete struct {
	Name string
}

func (TagAutocomplete) TableName

func (TagAutocomplete) TableName() string

type Unit

type Unit struct {
	NutritionDataID        uint   `gorm:"index:units_nutrition_data_id_index"`
	Unit                   string `gorm:"not null"`
	Modifier               string
	PercentOfNutritionData float64 `gorm:"not null"`
}

Directories

Path Synopsis
db module

Jump to

Keyboard shortcuts

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