diff --git a/Gemfile b/Gemfile index d0eed19..a7fa499 100644 --- a/Gemfile +++ b/Gemfile @@ -23,6 +23,8 @@ gem 'unitwise', '~> 2.0.0' # Use ActiveModel has_secure_password gem 'bcrypt', '~> 3.1.7' +gem 'usda-nutrient-database', path: '/Users/delbert/Development/usda-nutrient-database-fork' + # Use Unicorn as the app server # gem 'unicorn' diff --git a/Gemfile.lock b/Gemfile.lock index 7323d14..791a899 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,12 @@ +PATH + remote: /Users/delbert/Development/usda-nutrient-database-fork + specs: + usda-nutrient-database (1.3.0) + activerecord (>= 4.0.0) + activerecord-import (~> 0.10.0) + faraday + rubyzip + GEM remote: https://rubygems.org/ specs: @@ -30,6 +39,8 @@ GEM activemodel (= 4.2.5) activesupport (= 4.2.5) arel (~> 6.0) + activerecord-import (0.10.0) + activerecord (>= 3.0) activesupport (4.2.5) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) @@ -68,6 +79,8 @@ GEM factory_girl_rails (4.5.0) factory_girl (~> 4.5.0) railties (>= 3.0.0) + faraday (0.9.2) + multipart-post (>= 1.2, < 3) globalid (0.3.6) activesupport (>= 4.1.0) i18n (0.7.0) @@ -91,6 +104,7 @@ GEM mini_portile2 (2.0.0) minitest (5.8.3) multi_json (1.11.2) + multipart-post (2.0.0) mysql2 (0.3.20) nokogiri (1.6.7.1) mini_portile2 (~> 2.0.0.rc2) @@ -142,6 +156,7 @@ GEM rspec-mocks (~> 3.4.0) rspec-support (~> 3.4.0) rspec-support (3.4.1) + rubyzip (1.1.7) sass (3.4.21) sass-rails (5.0.4) railties (>= 4.0.0, < 5.0) @@ -203,6 +218,7 @@ DEPENDENCIES turbolinks uglifier (>= 1.3.0) unitwise (~> 2.0.0) + usda-nutrient-database! web-console (~> 2.0) BUNDLED WITH diff --git a/db/migrate/20160122223816_create_usda_food_groups.usda_nutrient_database_engine.rb b/db/migrate/20160122223816_create_usda_food_groups.usda_nutrient_database_engine.rb new file mode 100644 index 0000000..0d24b84 --- /dev/null +++ b/db/migrate/20160122223816_create_usda_food_groups.usda_nutrient_database_engine.rb @@ -0,0 +1,9 @@ +# This migration comes from usda_nutrient_database_engine (originally 1) +class CreateUsdaFoodGroups < ActiveRecord::Migration + def change + create_table :usda_food_groups, id: false, primary_key: :code do |t| + t.string :code, null: false, index: true, uniq: true + t.string :description, null: false + end + end +end \ No newline at end of file diff --git a/db/migrate/20160122223817_create_usda_foods.usda_nutrient_database_engine.rb b/db/migrate/20160122223817_create_usda_foods.usda_nutrient_database_engine.rb new file mode 100644 index 0000000..6876e48 --- /dev/null +++ b/db/migrate/20160122223817_create_usda_foods.usda_nutrient_database_engine.rb @@ -0,0 +1,20 @@ +# This migration comes from usda_nutrient_database_engine (originally 2) +class CreateUsdaFoods < ActiveRecord::Migration + def change + create_table :usda_foods, id: false, primary_key: :nutrient_databank_number do |t| + t.string :nutrient_databank_number, null: false, index: true + t.string :food_group_code, index: true + t.string :long_description, null: false + t.string :short_description, null: false + t.string :common_names + t.string :manufacturer_name + t.boolean :survey + t.string :refuse_description + t.integer :percentage_refuse + t.float :nitrogen_factor + t.float :protein_factor + t.float :fat_factor + t.float :carbohydrate_factor + end + end +end diff --git a/db/migrate/20160122223818_create_usda_foods_nutrients.usda_nutrient_database_engine.rb b/db/migrate/20160122223818_create_usda_foods_nutrients.usda_nutrient_database_engine.rb new file mode 100644 index 0000000..20c71f9 --- /dev/null +++ b/db/migrate/20160122223818_create_usda_foods_nutrients.usda_nutrient_database_engine.rb @@ -0,0 +1,29 @@ +# This migration comes from usda_nutrient_database_engine (originally 3) +class CreateUsdaFoodsNutrients < ActiveRecord::Migration + def change + create_table :usda_foods_nutrients do |t| + t.string :nutrient_databank_number, null: false + t.string :nutrient_number, null: false + t.float :nutrient_value, null: false + t.integer :num_data_points, null: false + t.float :standard_error + t.string :src_code, null: false + t.string :derivation_code + t.string :ref_nutrient_databank_number + t.boolean :add_nutrient_mark + t.integer :num_studies + t.float :min + t.float :max + t.integer :degrees_of_freedom + t.float :lower_error_bound + t.float :upper_error_bound + t.string :statistical_comments + t.string :add_mod_date + t.string :confidence_code + end + + add_index :usda_foods_nutrients, + [:nutrient_databank_number, :nutrient_number], + name: 'foods_nutrients_index' + end +end diff --git a/db/migrate/20160122223819_create_usda_nutrients.usda_nutrient_database_engine.rb b/db/migrate/20160122223819_create_usda_nutrients.usda_nutrient_database_engine.rb new file mode 100644 index 0000000..24ef515 --- /dev/null +++ b/db/migrate/20160122223819_create_usda_nutrients.usda_nutrient_database_engine.rb @@ -0,0 +1,13 @@ +# This migration comes from usda_nutrient_database_engine (originally 4) +class CreateUsdaNutrients < ActiveRecord::Migration + def change + create_table :usda_nutrients, id: false, primary_key: :nutrient_number do |t| + t.string :nutrient_number, null: false, index: true + t.string :units, null: false + t.string :tagname + t.string :nutrient_description, null: false + t.string :number_decimal_places, null: false + t.integer :sort_record_order, null: false + end + end +end \ No newline at end of file diff --git a/db/migrate/20160122223820_create_usda_weights.usda_nutrient_database_engine.rb b/db/migrate/20160122223820_create_usda_weights.usda_nutrient_database_engine.rb new file mode 100644 index 0000000..75aed60 --- /dev/null +++ b/db/migrate/20160122223820_create_usda_weights.usda_nutrient_database_engine.rb @@ -0,0 +1,14 @@ +# This migration comes from usda_nutrient_database_engine (originally 5) +class CreateUsdaWeights < ActiveRecord::Migration + def change + create_table :usda_weights do |t| + t.string :nutrient_databank_number, null: false, index: true + t.string :sequence_number, null: false + t.float :amount, null: false + t.string :measurement_description, null: false + t.float :gram_weight, null: false + t.integer :num_data_points + t.float :standard_deviation + end + end +end diff --git a/db/migrate/20160122223821_create_usda_footnotes.usda_nutrient_database_engine.rb b/db/migrate/20160122223821_create_usda_footnotes.usda_nutrient_database_engine.rb new file mode 100644 index 0000000..8a72f5c --- /dev/null +++ b/db/migrate/20160122223821_create_usda_footnotes.usda_nutrient_database_engine.rb @@ -0,0 +1,12 @@ +# This migration comes from usda_nutrient_database_engine (originally 6) +class CreateUsdaFootnotes < ActiveRecord::Migration + def change + create_table :usda_footnotes do |t| + t.string :nutrient_databank_number, null: false, index: true + t.string :footnote_number, null: false, index: true + t.string :footnote_type, null: false, index: true + t.string :nutrient_number, index: true + t.string :footnote_text, null: false + end + end +end diff --git a/db/migrate/20160122223822_create_usda_source_codes.usda_nutrient_database_engine.rb b/db/migrate/20160122223822_create_usda_source_codes.usda_nutrient_database_engine.rb new file mode 100644 index 0000000..93a87da --- /dev/null +++ b/db/migrate/20160122223822_create_usda_source_codes.usda_nutrient_database_engine.rb @@ -0,0 +1,9 @@ +# This migration comes from usda_nutrient_database_engine (originally 7) +class CreateUsdaSourceCodes < ActiveRecord::Migration + def change + create_table :usda_source_codes do |t| + t.string :code, null: false, index: true + t.string :description, null: false + end + end +end diff --git a/db/migrate/20160122223823_add_timestamps_to_all_tables.usda_nutrient_database_engine.rb b/db/migrate/20160122223823_add_timestamps_to_all_tables.usda_nutrient_database_engine.rb new file mode 100644 index 0000000..68a3778 --- /dev/null +++ b/db/migrate/20160122223823_add_timestamps_to_all_tables.usda_nutrient_database_engine.rb @@ -0,0 +1,13 @@ +# This migration comes from usda_nutrient_database_engine (originally 8) +class AddTimestampsToAllTables < ActiveRecord::Migration + def change + [ + :usda_food_groups, :usda_foods, :usda_foods_nutrients, + :usda_weights, :usda_footnotes, :usda_source_codes, + :usda_nutrients + ].each do |table_name| + add_column table_name, :created_at, :datetime + add_column table_name, :updated_at, :datetime + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 6bc89ae..8f827bc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160119212055) do +ActiveRecord::Schema.define(version: 20160122223823) do create_table "ingredients", force: :cascade do |t| t.string "name" @@ -58,6 +58,112 @@ ActiveRecord::Schema.define(version: 20160119212055) do t.integer "user_id" end + create_table "usda_food_groups", id: false, force: :cascade do |t| + t.string "code", null: false + t.string "description", null: false + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "usda_food_groups", ["code"], name: "index_usda_food_groups_on_code" + + create_table "usda_foods", id: false, force: :cascade do |t| + t.string "nutrient_databank_number", null: false + t.string "food_group_code" + t.string "long_description", null: false + t.string "short_description", null: false + t.string "common_names" + t.string "manufacturer_name" + t.boolean "survey" + t.string "refuse_description" + t.integer "percentage_refuse" + t.float "nitrogen_factor" + t.float "protein_factor" + t.float "fat_factor" + t.float "carbohydrate_factor" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "usda_foods", ["food_group_code"], name: "index_usda_foods_on_food_group_code" + add_index "usda_foods", ["nutrient_databank_number"], name: "index_usda_foods_on_nutrient_databank_number" + + create_table "usda_foods_nutrients", force: :cascade do |t| + t.string "nutrient_databank_number", null: false + t.string "nutrient_number", null: false + t.float "nutrient_value", null: false + t.integer "num_data_points", null: false + t.float "standard_error" + t.string "src_code", null: false + t.string "derivation_code" + t.string "ref_nutrient_databank_number" + t.boolean "add_nutrient_mark" + t.integer "num_studies" + t.float "min" + t.float "max" + t.integer "degrees_of_freedom" + t.float "lower_error_bound" + t.float "upper_error_bound" + t.string "statistical_comments" + t.string "add_mod_date" + t.string "confidence_code" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "usda_foods_nutrients", ["nutrient_databank_number", "nutrient_number"], name: "foods_nutrients_index" + + create_table "usda_footnotes", force: :cascade do |t| + t.string "nutrient_databank_number", null: false + t.string "footnote_number", null: false + t.string "footnote_type", null: false + t.string "nutrient_number" + t.string "footnote_text", null: false + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "usda_footnotes", ["footnote_number"], name: "index_usda_footnotes_on_footnote_number" + add_index "usda_footnotes", ["footnote_type"], name: "index_usda_footnotes_on_footnote_type" + add_index "usda_footnotes", ["nutrient_databank_number"], name: "index_usda_footnotes_on_nutrient_databank_number" + add_index "usda_footnotes", ["nutrient_number"], name: "index_usda_footnotes_on_nutrient_number" + + create_table "usda_nutrients", id: false, force: :cascade do |t| + t.string "nutrient_number", null: false + t.string "units", null: false + t.string "tagname" + t.string "nutrient_description", null: false + t.string "number_decimal_places", null: false + t.integer "sort_record_order", null: false + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "usda_nutrients", ["nutrient_number"], name: "index_usda_nutrients_on_nutrient_number" + + create_table "usda_source_codes", force: :cascade do |t| + t.string "code", null: false + t.string "description", null: false + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "usda_source_codes", ["code"], name: "index_usda_source_codes_on_code" + + create_table "usda_weights", force: :cascade do |t| + t.string "nutrient_databank_number", null: false + t.string "sequence_number", null: false + t.float "amount", null: false + t.string "measurement_description", null: false + t.float "gram_weight", null: false + t.integer "num_data_points" + t.float "standard_deviation" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "usda_weights", ["nutrient_databank_number"], name: "index_usda_weights_on_nutrient_databank_number" + create_table "users", force: :cascade do |t| t.string "username" t.string "email"