Skip to content

Commit

Permalink
minor perf tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Ch4s3 committed Oct 24, 2017
1 parent ea1a069 commit b818722
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Expand Up @@ -11,9 +11,11 @@ gem 'rails', '~> 5.1.4'

gem 'browser'
gem 'devise'
gem 'escape_utils'
gem 'fast_blank'
gem 'httparty'
gem 'nokogiri'
gem 'oj'
gem 'pg', '~> 0.18'
gem 'pg_query', '>= 0.9.0'
gem 'pghero'
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Expand Up @@ -107,6 +107,7 @@ GEM
equalizer (0.0.11)
erubi (1.7.0)
erubis (2.7.0)
escape_utils (1.2.1)
faker (1.8.4)
i18n (~> 0.5)
fakeredis (0.6.0)
Expand Down Expand Up @@ -219,6 +220,7 @@ GEM
shellany (~> 0.0)
octokit (4.7.0)
sawyer (~> 0.8.0, >= 0.5.3)
oj (3.3.8)
orm_adapter (0.5.0)
parallel (1.12.0)
parser (2.4.0.0)
Expand Down Expand Up @@ -464,6 +466,7 @@ DEPENDENCIES
byebug
coveralls
devise
escape_utils
faker
fakeredis
fast_blank
Expand All @@ -478,6 +481,7 @@ DEPENDENCIES
memory_profiler
mutant-rspec
nokogiri
oj
pg (~> 0.18)
pg_query (>= 0.9.0)
pghero
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/annotations_controller.rb
Expand Up @@ -8,7 +8,7 @@ def create
user = User.find(article_and_user[:user_id].to_i)
annotation = Annotation.new(annotation_params.merge(user: user, article: article))
if annotation.save
render json: { success: 'annotation saved' }, status: 200
render json: { success: 'annotation saved' }, status: 201
else
render json: { failure: annotation.errors }, status: 400
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/articles_controller.rb
Expand Up @@ -49,7 +49,7 @@ def validate_search

def find_article_and_annotations
@article ||= Article.find_by(uuid: show_params['id'])
@annotations ||= Annotation.where(article: @article)
@annotations = Annotation.where(article: @article)
end

def article_params
Expand Down
7 changes: 7 additions & 0 deletions config/initializers/escapes.rb
@@ -0,0 +1,7 @@
begin
require 'escape_utils/html/rack' # to patch Rack::Utils
require 'escape_utils/html/erb' # to patch ERB::Util
require 'escape_utils/html/cgi' # to patch CGI
rescue LoadError
Rails.logger.info 'Escape_utils is not in the gemfile'
end
1 change: 1 addition & 0 deletions config/initializers/oj.rb
@@ -0,0 +1 @@
Oj.optimize_rails()

0 comments on commit b818722

Please sign in to comment.