From 134d4171f828ea1598e9d513be01927a3497d7e9 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Wed, 13 Apr 2016 17:07:21 +0800 Subject: [PATCH 1/3] alphabetize gemfile --- Gemfile | 70 +++++++++++++++++++++++++-------------------------------- 1 file changed, 30 insertions(+), 40 deletions(-) diff --git a/Gemfile b/Gemfile index 26bd64f6..90d55f04 100644 --- a/Gemfile +++ b/Gemfile @@ -3,67 +3,57 @@ ruby '2.1.3' gem 'rails', '4.2.4' +gem 'active_model_serializers', '~> 0.8.1' +gem 'aws-sdk', '< 2.0' +gem 'best_in_place' #in-place editing +gem 'delayed_job', '~> 4.0.2' +gem 'delayed_job_active_record', '~> 4.0.1' gem 'devise' -gem 'redis' +gem 'doorkeeper' +gem 'dotenv' +gem 'formtastic' +gem 'formula' +gem 'httparty' +gem 'json' +gem 'kaminari' # pagination +gem 'paperclip' gem 'pg' gem 'pundit' gem 'pundit_extra' -gem 'doorkeeper' -gem 'formula' -gem 'formtastic' -gem 'json' -gem 'rails3-jquery-autocomplete' -gem 'best_in_place' #in-place editing -gem 'kaminari' # pagination -gem 'uservoice-ruby' -gem 'dotenv' -gem 'snorlax' gem 'rack-cors' -gem 'httparty' -gem 'active_model_serializers', '~> 0.8.1' -gem 'delayed_job', '~> 4.0.2' -gem 'delayed_job_active_record', '~> 4.0.1' - -gem 'paperclip' -gem 'aws-sdk', '< 2.0' +gem 'rails3-jquery-autocomplete' +gem 'redis' +gem 'snorlax' +gem 'uservoice-ruby' gem 'jquery-rails' gem 'jquery-ui-rails' gem 'jbuilder' -#gem 'therubyracer' #optional -#gem 'rb-readline' - -# Gems used only for assets and not required -# in production environments by default. group :assets do - gem 'sass-rails' gem 'coffee-rails' - - # See https://github.com/sstephenson/execjs#readme for more supported runtimes - # gem 'therubyracer' - + gem 'sass-rails' gem 'uglifier' + # gem 'therubyracer' end -group :test do - gem 'rspec-rails' - gem 'factory_girl_rails' - gem 'shoulda-matchers' - gem 'simplecov', require: false - gem 'json-schema' -end - -group :production do #this is used on heroku - #gem 'rmagick' +group :production do gem 'rails_12factor' end +group :test do + gem 'factory_girl_rails' + gem 'json-schema' + gem 'rspec-rails' + gem 'shoulda-matchers' + gem 'simplecov', require: false +end + group :development, :test do - gem 'pry-rails' - gem 'pry-byebug' gem 'better_errors' gem 'binding_of_caller' + gem 'pry-byebug' + gem 'pry-rails' gem 'quiet_assets' gem 'tunemygc' end From fb80f56a7ddf6052c1fd2de43795e03ede34f177 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Wed, 13 Apr 2016 17:20:01 +0800 Subject: [PATCH 2/3] slack exception notifications --- .example-env | 7 +++- Gemfile | 2 + Gemfile.lock | 6 +++ config/initializers/exception_notification.rb | 37 +++++++++++++++++++ 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 config/initializers/exception_notification.rb diff --git a/.example-env b/.example-env index 54039a93..f3bace35 100644 --- a/.example-env +++ b/.example-env @@ -16,14 +16,17 @@ export DEVISE_SECRET_KEY='f71c467e526f23d614b3b08866cad4788c502bed869c282f06e73e # export AWS_ACCESS_KEY_ID # export AWS_SECRET_ACCESS_KEY # export SSO_KEY -# +# # export SMTP_DOMAIN # export SMTP_PASSWORD # export SMTP_PORT # export SMTP_SERVER # export SMTP_USERNAME + +# # send exception notifications to a slack incoming webhook +# export SLACK_EN_WEBHOOK_URL -#ruby garbage collection stuff +# ruby garbage collection stuff export RUBY_GC_TUNE=0 #set to 1 to enable GC test export RUBY_GC_TOKEN=4f4380fc9a2857d1f008005a3eb86928 diff --git a/Gemfile b/Gemfile index 90d55f04..815c5eee 100644 --- a/Gemfile +++ b/Gemfile @@ -11,6 +11,7 @@ gem 'delayed_job_active_record', '~> 4.0.1' gem 'devise' gem 'doorkeeper' gem 'dotenv' +gem 'exception_notification' gem 'formtastic' gem 'formula' gem 'httparty' @@ -23,6 +24,7 @@ gem 'pundit_extra' gem 'rack-cors' gem 'rails3-jquery-autocomplete' gem 'redis' +gem 'slack-notifier' gem 'snorlax' gem 'uservoice-ruby' diff --git a/Gemfile.lock b/Gemfile.lock index 44873eda..59a2e295 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -89,6 +89,9 @@ GEM railties (>= 3.2) dotenv (2.1.0) erubis (2.7.0) + exception_notification (4.1.4) + actionmailer (~> 4.0) + activesupport (~> 4.0) execjs (2.6.0) ezcrypto (0.7.2) factory_girl (4.5.0) @@ -229,6 +232,7 @@ GEM json (~> 1.8) simplecov-html (~> 0.10.0) simplecov-html (0.10.0) + slack-notifier (1.5.1) slop (3.6.0) snorlax (0.1.5) rails (> 4.1) @@ -270,6 +274,7 @@ DEPENDENCIES devise doorkeeper dotenv + exception_notification factory_girl_rails formtastic formula @@ -296,6 +301,7 @@ DEPENDENCIES sass-rails shoulda-matchers simplecov + slack-notifier snorlax tunemygc uglifier diff --git a/config/initializers/exception_notification.rb b/config/initializers/exception_notification.rb new file mode 100644 index 00000000..5423334e --- /dev/null +++ b/config/initializers/exception_notification.rb @@ -0,0 +1,37 @@ +require 'exception_notification/rails' + +ExceptionNotification.configure do |config| + # Ignore additional exception types. + # ActiveRecord::RecordNotFound, AbstractController::ActionNotFound and + # ActionController::RoutingError are already added. + config.ignored_exceptions += %w( + ActionView::TemplateError CustomError UnauthorizedException + InvalidArgumentException InvalidEntityException InvalidRequestException + NotFoundException ValidationException + ) + + # Adds a condition to decide when an exception must be ignored or not. + # The ignore_if method can be invoked multiple times to add extra conditions. + config.ignore_if do |_exception, _options| + !Rails.env.production? + end + + # Notifiers ###### + + if ENV['SLACK_EN_WEBHOOK_URL'] + config.add_notifier :slack, webhook_url: ENV['SLACK_EN_WEBHOOK_URL'] + end + + # Email notifier sends notifications by email. + # config.add_notifier :email, { + # :email_prefix => "[ERROR] ", + # :sender_address => %{"Notifier" }, + # :exception_recipients => %w{exceptions@example.com} + # } + + # Webhook notifier sends notifications over HTTP protocol. Requires 'httparty' gem. + # config.add_notifier :webhook, { + # :url => 'http://example.com:5555/hubot/path', + # :http_method => :post + # } +end From 837e4bde1b9aba76a244f101483d6c730bb987ab Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Wed, 20 Apr 2016 08:51:38 +0800 Subject: [PATCH 3/3] fix map forking (fix #540) --- app/controllers/maps_controller.rb | 51 +++++++++++++++--------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/app/controllers/maps_controller.rb b/app/controllers/maps_controller.rb index 82b87ffb..91eb97e1 100644 --- a/app/controllers/maps_controller.rb +++ b/app/controllers/maps_controller.rb @@ -158,35 +158,34 @@ class MapsController < ApplicationController @map.arranged = false if params[:topicsToMap] - @all = params[:topicsToMap] - @all = @all.split(',') - @all.each do |topic| - topic = topic.split('/') - mapping = Mapping.new() - mapping.user = @user - mapping.mappable = Topic.find(topic[0]) - mapping.xloc = topic[1] - mapping.yloc = topic[2] - @map.topicmappings << mapping - authorize mapping, :create - mapping.save - end + @all = params[:topicsToMap] + @all = @all.split(',') + @all.each do |topic| + topic = topic.split('/') + mapping = Mapping.new + mapping.map = @map + mapping.user = @user + mapping.mappable = Topic.find(topic[0]) + mapping.xloc = topic[1] + mapping.yloc = topic[2] + authorize mapping, :create? + mapping.save + end - if params[:synapsesToMap] - @synAll = params[:synapsesToMap] - @synAll = @synAll.split(',') - @synAll.each do |synapse_id| - mapping = Mapping.new() - mapping.user = @user - mapping.map = @map - mapping.mappable = Synapse.find(synapse_id) - @map.synapsemappings << mapping - authorize mapping, :create - mapping.save - end + if params[:synapsesToMap] + @synAll = params[:synapsesToMap] + @synAll = @synAll.split(',') + @synAll.each do |synapse_id| + mapping = Mapping.new + mapping.map = @map + mapping.user = @user + mapping.mappable = Synapse.find(synapse_id) + authorize mapping, :create? + mapping.save end + end - @map.arranged = true + @map.arranged = true end authorize @map