This commit is contained in:
Dan Elbert 2018-04-02 11:21:35 -05:00
parent d587ed58b7
commit 1154da1fd1
12 changed files with 92 additions and 50 deletions

View File

@ -1 +1 @@
2.5.0 2.4.3

View File

@ -1,4 +1,4 @@
FROM phusion/passenger-ruby25:latest FROM phusion/passenger-ruby24:latest
# Use baseimage-docker's init process. # Use baseimage-docker's init process.
CMD ["/sbin/my_init"] CMD ["/sbin/my_init"]

View File

@ -5,7 +5,9 @@ gem 'pg', '~> 0.21.0'
gem 'webpacker', '3.4.1' gem 'webpacker', '3.4.1'
gem 'bootsnap', '>= 1.1.0', require: false gem 'bootsnap', '>= 1.1.0', require: false
gem 'jbuilder', '~> 2.7'
#gem 'jbuilder', '~> 2.7'
gem 'jbuilder', git: 'https://github.com/rails/jbuilder', branch: 'master'
gem 'oj', '~> 3.5.0' gem 'oj', '~> 3.5.0'
@ -13,6 +15,8 @@ gem 'kaminari', '~> 1.1.1'
gem 'unitwise', '~> 2.2.0' gem 'unitwise', '~> 2.2.0'
gem 'redcarpet', '~> 3.4.0' gem 'redcarpet', '~> 3.4.0'
gem 'dalli', '~> 2.7.6'
# Use ActiveModel has_secure_password # Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.11' gem 'bcrypt', '~> 3.1.11'

View File

@ -1,3 +1,12 @@
GIT
remote: https://github.com/rails/jbuilder
revision: a0dc0bd42737aaef3dd622d8338a816aed03c8ff
branch: master
specs:
jbuilder (2.7.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
@ -50,6 +59,7 @@ GEM
coderay (1.1.2) coderay (1.1.2)
concurrent-ruby (1.0.5) concurrent-ruby (1.0.5)
crass (1.0.3) crass (1.0.3)
dalli (2.7.7)
database_cleaner (1.6.2) database_cleaner (1.6.2)
diff-lcs (1.3) diff-lcs (1.3)
erubi (1.7.1) erubi (1.7.1)
@ -78,9 +88,6 @@ GEM
rspec (>= 2.99.0, < 4.0) rspec (>= 2.99.0, < 4.0)
i18n (1.0.0) i18n (1.0.0)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
jbuilder (2.7.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
kaminari (1.1.1) kaminari (1.1.1)
activesupport (>= 4.1.0) activesupport (>= 4.1.0)
kaminari-actionview (= 1.1.1) kaminari-actionview (= 1.1.1)
@ -224,11 +231,12 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
bcrypt (~> 3.1.11) bcrypt (~> 3.1.11)
bootsnap (>= 1.1.0) bootsnap (>= 1.1.0)
dalli (~> 2.7.6)
database_cleaner (~> 1.6.2) database_cleaner (~> 1.6.2)
factory_bot_rails (~> 4.8.2) factory_bot_rails (~> 4.8.2)
guard (~> 2.14.0) guard (~> 2.14.0)
guard-rspec guard-rspec
jbuilder (~> 2.7) jbuilder!
kaminari (~> 1.1.1) kaminari (~> 1.1.1)
oj (~> 3.5.0) oj (~> 3.5.0)
pg (~> 0.21.0) pg (~> 0.21.0)

View File

@ -1,7 +1,7 @@
class RecipeIngredient < ApplicationRecord class RecipeIngredient < ApplicationRecord
belongs_to :ingredient, optional: true belongs_to :ingredient, optional: true
belongs_to :recipe, inverse_of: :recipe_ingredients belongs_to :recipe, inverse_of: :recipe_ingredients, touch: true
validates :sort_order, presence: true validates :sort_order, presence: true

View File

@ -1,8 +1,10 @@
json.extract! @ingredients, :total_count, :total_pages, :current_page json.cache_root! [Ingredient.all, @ingredients] do
json.page_size @ingredients.limit_value
json.ingredients @ingredients do |i| json.extract! @ingredients, :total_count, :total_pages, :current_page
json.page_size @ingredients.limit_value
json.ingredients @ingredients do |i|
json.extract! i, :id, :name, :ndbn, :kcal json.extract! i, :id, :name, :ndbn, :kcal
json.usda i.ndbn.present? json.usda i.ndbn.present?
@ -13,5 +15,6 @@ json.ingredients @ingredients do |i|
json.density nil json.density nil
end end
end end
end

View File

@ -1,10 +1,13 @@
json.extract! @recipes, :total_count, :total_pages, :current_page json.cache_root! [Recipe.all, @recipes] do
json.page_size @recipes.limit_value
json.recipes @recipes do |r| json.extract! @recipes, :total_count, :total_pages, :current_page
json.page_size @recipes.limit_value
json.recipes @recipes do |r|
json.extract! r, :id, :name, :rating, :yields, :total_time, :active_time, :created_at, :updated_at json.extract! r, :id, :name, :rating, :yields, :total_time, :active_time, :created_at, :updated_at
json.tags r.tag_names json.tags r.tag_names
end end
end

View File

@ -1,11 +1,12 @@
json.cache_root! [@recipe] do
json.extract! @recipe, :id, :name, :rating, :yields, :total_time, :active_time, :created_at, :updated_at, :step_text json.extract! @recipe, :id, :name, :rating, :yields, :total_time, :active_time, :created_at, :updated_at, :step_text
json.rendered_steps MarkdownProcessor.render(@recipe.step_text) json.rendered_steps MarkdownProcessor.render(@recipe.step_text)
json.tags @recipe.tag_names json.tags @recipe.tag_names
json.ingredients @recipe.recipe_ingredients do |ri| json.ingredients @recipe.recipe_ingredients do |ri|
json.extract! ri, :id, :ingredient_id, :display_name, :name, :quantity, :units, :preparation, :sort_order json.extract! ri, :id, :ingredient_id, :display_name, :name, :quantity, :units, :preparation, :sort_order
json.ingredient do json.ingredient do
@ -17,9 +18,9 @@ json.ingredients @recipe.recipe_ingredients do |ri|
end end
json._destroy false json._destroy false
end end
json.nutrition_data do json.nutrition_data do
json.errors @recipe.nutrition_data.errors json.errors @recipe.nutrition_data.errors
json.nutrients NutritionData::NUTRIENTS.select { |_, v| v.present? } do |name, label| json.nutrients NutritionData::NUTRIENTS.select { |_, v| v.present? } do |name, label|
@ -28,4 +29,6 @@ json.nutrition_data do
json.value @recipe.nutrition_data.send(name) json.value @recipe.nutrition_data.send(name)
end end
end
end end

View File

@ -24,6 +24,10 @@ module Parsley
# -- all .rb files in that directory are automatically loaded. # -- all .rb files in that directory are automatically loaded.
config.load_defaults 5.2 config.load_defaults 5.2
if ENV['RAILS_USE_MEMCACHE'] == 'true'
config.cache_store = :mem_cache_store, ENV['RAILS_MEMCACHE_HOST'] || 'memcache'
end
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
config.time_zone = 'Central Time (US & Canada)' config.time_zone = 'Central Time (US & Canada)'

View File

@ -14,11 +14,16 @@ Rails.application.configure do
# Show full error reports. # Show full error reports.
config.consider_all_requests_local = true config.consider_all_requests_local = true
memcache_enabled = ENV['RAILS_USE_MEMCACHE'] == 'true'
# Enable/disable caching. By default caching is disabled. # Enable/disable caching. By default caching is disabled.
if Rails.root.join('tmp/caching-dev.txt').exist? if Rails.root.join('tmp/caching-dev.txt').exist? || memcache_enabled
config.action_controller.perform_caching = true config.action_controller.perform_caching = true
unless memcache_enabled
config.cache_store = :memory_store config.cache_store = :memory_store
end
config.public_file_server.headers = { config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=172800' 'Cache-Control' => 'public, max-age=172800'
} }

View File

@ -8,12 +8,21 @@ services:
- POSTGRES_USER=parsley - POSTGRES_USER=parsley
volumes: volumes:
- sql-data:/var/lib/postgresql/data - sql-data:/var/lib/postgresql/data
memcache:
image: memcached:1.5.4-alpine
command: memcached -m 512
web: web:
build: . build: .
environment:
- RAILS_USE_MEMCACHE=true
- RAILS_LOG_TO_STDOUT=true
ports: ports:
- "3000:80" - "3000:80"
links: links:
- postgres - postgres
volumes: volumes:
sql-data: sql-data:
driver: local driver: local

View File

@ -1,3 +1,6 @@
env RAILS_LOG_TO_STDOUT;
env RAILS_USE_MEMCACHE;
env RAILS_MEMCACHE_HOST;
env PARSLEY_DB_HOST; env PARSLEY_DB_HOST;
env PARSLEY_DB_USER; env PARSLEY_DB_USER;
env PARSLEY_DB_PASSWORD; env PARSLEY_DB_PASSWORD;