Skip to content

Commit

Permalink
WIP rails 5 conversion coyote-team#118
Browse files Browse the repository at this point in the history
  • Loading branch information
subelsky committed Aug 4, 2017
1 parent a18f292 commit b6385ed
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 90 deletions.
6 changes: 2 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ source 'https://rubygems.org'
ruby '2.3.4'

gem 'dotenv-rails'
gem 'rails', '4.2.9'
gem 'rails', '5.0.0.1'
gem 'language_list'
gem 'iso639-validator'
gem 'sass-rails', '~> 5.0.1' # sass and sprockets upgrades can be delicate
Expand All @@ -18,7 +18,6 @@ gem 'compass-h5bp'
gem 'modular-scale'
gem 'sass-mediaqueries-rails'
gem 'pg', '~> 0.20.0' # our version of activerecord has a bug with v0.21; see https://stackoverflow.com/questions/44607324/installing-newest-version-of-rails-4-with-postgres-the-pgconn-pgresult-and-p
gem 'actionpack-action_caching' # caching
gem 'kaminari'
gem 'ransack'
gem 'simple_form', git: 'https://github.com/plataformatec/simple_form.git'
Expand Down Expand Up @@ -48,7 +47,7 @@ gem 'simple_token_authentication' # token auth for api
gem 'jbuilder' # json builder
gem 'roo' # spreadsheet interfaces
gem 'iconv'
gem 'audited-activerecord'
gem 'audited'
gem 'easymarklet', git: 'https://github.com/seeread/easymarklet.git', ref: '53829a6'
gem 'rollbar', '~>2.11.3'
gem 'factory_girl_rails', require: false
Expand All @@ -65,7 +64,6 @@ group :development do
gem 'better_errors'
gem 'html2haml'
gem 'binding_of_caller'
gem 'quiet_assets'
gem 'rails_real_favicon'
gem 'brakeman', :require => false
gem 'spring'
Expand Down
137 changes: 67 additions & 70 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,48 +25,49 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.9)
actionpack (= 4.2.9)
actionview (= 4.2.9)
activejob (= 4.2.9)
actioncable (5.0.0.1)
actionpack (= 5.0.0.1)
nio4r (~> 1.2)
websocket-driver (~> 0.6.1)
actionmailer (5.0.0.1)
actionpack (= 5.0.0.1)
actionview (= 5.0.0.1)
activejob (= 5.0.0.1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.9)
actionview (= 4.2.9)
activesupport (= 4.2.9)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-dom-testing (~> 2.0)
actionpack (5.0.0.1)
actionview (= 5.0.0.1)
activesupport (= 5.0.0.1)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionpack-action_caching (1.1.1)
actionpack (>= 4.0.0, < 5.0)
actionview (4.2.9)
activesupport (= 4.2.9)
actionview (5.0.0.1)
activesupport (= 5.0.0.1)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (4.2.9)
activesupport (= 4.2.9)
globalid (>= 0.3.0)
activemodel (4.2.9)
activesupport (= 4.2.9)
builder (~> 3.1)
activerecord (4.2.9)
activemodel (= 4.2.9)
activesupport (= 4.2.9)
arel (~> 6.0)
activesupport (4.2.9)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (5.0.0.1)
activesupport (= 5.0.0.1)
globalid (>= 0.3.6)
activemodel (5.0.0.1)
activesupport (= 5.0.0.1)
activerecord (5.0.0.1)
activemodel (= 5.0.0.1)
activesupport (= 5.0.0.1)
arel (~> 7.0)
activesupport (5.0.0.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
acts-as-taggable-on (3.5.0)
activerecord (>= 3.2, < 5)
acts-as-taggable-on (5.0.0)
activerecord (>= 4.2.8)
addressable (2.4.0)
airborne (0.2.7)
activesupport (>= 3.0, < 5.0)
rack (< 2.0)
airborne (0.2.13)
activesupport
rack
rack-test (~> 0.6, >= 0.6.2)
rest-client (>= 1.7.3, < 3.0)
rspec (~> 3.1)
Expand All @@ -76,13 +77,10 @@ GEM
rake (>= 10.4, < 12.0)
apipie-rails (0.3.6)
json
arel (6.0.4)
arel (7.1.4)
ast (2.3.0)
audited (4.2.0)
rails-observers (~> 0.1.2)
audited-activerecord (4.2.0)
activerecord (~> 4.0)
audited (= 4.2.0)
autoprefixer-rails (6.5.0.2)
execjs
bcrypt (3.1.11)
Expand Down Expand Up @@ -150,7 +148,7 @@ GEM
warden (~> 1.2.3)
diff-lcs (1.3)
docile (1.1.5)
domain_name (0.5.20160615)
domain_name (0.5.20170404)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.1.1)
dotenv-rails (2.1.1)
Expand Down Expand Up @@ -226,7 +224,7 @@ GEM
haml (~> 4.0.0)
nokogiri (~> 1.6.0)
ruby_parser (~> 3.5)
http-cookie (1.0.2)
http-cookie (1.0.3)
domain_name (~> 0.5)
http_parser.rb (0.6.0)
i18n (0.8.6)
Expand Down Expand Up @@ -277,6 +275,7 @@ GEM
multi_json (1.12.1)
nenv (0.3.0)
netrc (0.11.0)
nio4r (1.2.1)
nokogiri (1.6.8.1)
mini_portile2 (~> 2.1.0)
notiffany (0.1.0)
Expand All @@ -296,32 +295,28 @@ GEM
method_source (~> 0.8.1)
slop (~> 3.4)
puma (3.9.1)
quiet_assets (1.1.0)
railties (>= 3.1, < 5.0)
rack (1.6.8)
rack (2.0.3)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.9)
actionmailer (= 4.2.9)
actionpack (= 4.2.9)
actionview (= 4.2.9)
activejob (= 4.2.9)
activemodel (= 4.2.9)
activerecord (= 4.2.9)
activesupport (= 4.2.9)
rails (5.0.0.1)
actioncable (= 5.0.0.1)
actionmailer (= 5.0.0.1)
actionpack (= 5.0.0.1)
actionview (= 5.0.0.1)
activejob (= 5.0.0.1)
activemodel (= 5.0.0.1)
activerecord (= 5.0.0.1)
activesupport (= 5.0.0.1)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.9)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.8)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6)
rails-deprecated_sanitizer (>= 1.0.1)
railties (= 5.0.0.1)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rails-observers (0.1.2)
activemodel (~> 4.0)
rails-observers (0.1.5)
activemodel (>= 4.0)
rails_12factor (0.0.3)
rails_serve_static_assets
rails_stdout_logging
Expand All @@ -332,9 +327,10 @@ GEM
rubyzip (~> 1)
rails_serve_static_assets (0.0.5)
rails_stdout_logging (0.0.5)
railties (4.2.9)
actionpack (= 4.2.9)
activesupport (= 4.2.9)
railties (5.0.0.1)
actionpack (= 5.0.0.1)
activesupport (= 5.0.0.1)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.2.2)
Expand All @@ -353,7 +349,7 @@ GEM
redcarpet (3.3.4)
responders (2.2.0)
railties (>= 4.2.0, < 5.1)
rest-client (2.0.0)
rest-client (2.0.2)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
Expand Down Expand Up @@ -446,7 +442,7 @@ GEM
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.2)
unf_ext (0.0.7.4)
unicode-display_width (1.3.0)
validate_url (1.0.2)
activemodel (>= 3.0.0)
Expand All @@ -459,6 +455,9 @@ GEM
crack (>= 0.3.2)
hashdiff
websocket (1.2.3)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
whenever (0.9.7)
chronic (>= 0.6.3)
xpath (2.0.0)
Expand All @@ -469,13 +468,12 @@ PLATFORMS
ruby

DEPENDENCIES
actionpack-action_caching
acts-as-taggable-on
airborne
analytical
annotate
apipie-rails
audited-activerecord
audited
autoprefixer-rails
better_errors
binding_of_caller
Expand Down Expand Up @@ -519,8 +517,7 @@ DEPENDENCIES
oj
pg (~> 0.20.0)
puma
quiet_assets
rails (= 4.2.9)
rails (= 5.0.0.1)
rails_12factor
rails_real_favicon
ransack
Expand Down
22 changes: 11 additions & 11 deletions app/controllers/websites_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ class WebsitesController < ApplicationController
before_action :set_website, only: %i[show edit update destroy check_count]
before_action :set_strategies_collection, only: %i[new edit]

caches_action :check_count, :cache_path => { :cache_path => Proc.new { |c| c.params } }, :expires_in => 5.minutes

respond_to :html, :json

# GET /websites
Expand All @@ -19,18 +17,20 @@ def show
end

def check_count
@our_count = @website.images.count
@their_count = 0
Rails.cache("website_check_count/#{c.params}",expires_in: 5.minutes) do
@our_count = @website.images.count
@their_count = 0

uniqs = @website.strategy_check_count
@their_count = uniqs.count
uniqs = @website.strategy_check_count
@their_count = uniqs.count

our_c_ids = @website.images.collect{|i| i.canonical_id}
@our_count = @website.images.count
our_c_ids = @website.images.collect{|i| i.canonical_id}
@our_count = @website.images.count

@our_matched_ids = uniqs & our_c_ids
@our_unmatched_ids = our_c_ids - uniqs
@their_unmatched_ids = uniqs - our_c_ids
@our_matched_ids = uniqs & our_c_ids
@our_unmatched_ids = our_c_ids - uniqs
@their_unmatched_ids = uniqs - our_c_ids
end
end

# GET /websites/new
Expand Down
4 changes: 4 additions & 0 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# @abstract This is the base class for all app models, required for Rails 5
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
2 changes: 1 addition & 1 deletion app/models/assignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# index_assignments_on_user_id (user_id)
#

class Assignment < ActiveRecord::Base
class Assignment < ApplicationRecord
belongs_to :user, touch: true
belongs_to :image, counter_cache: true, touch: true

Expand Down
5 changes: 4 additions & 1 deletion app/models/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# index_images_on_website_id (website_id)
#

class Image < ActiveRecord::Base
class Image < ApplicationRecord
acts_as_taggable_on :tags
before_validation :update_status_code

Expand Down Expand Up @@ -181,6 +181,8 @@ def self.to_csv(options = {})
end
end

private

def update_status_code
if begun?
if completed?
Expand All @@ -193,6 +195,7 @@ def update_status_code
else
self.status_code = 0
end

return true
end
end
2 changes: 1 addition & 1 deletion app/models/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# updated_at :datetime
#

class Status < ActiveRecord::Base
class Status < ApplicationRecord
has_many :descriptions

validates_presence_of :title
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# index_users_on_role (role)
#

class User < ActiveRecord::Base
class User < ApplicationRecord
acts_as_token_authenticatable

# Include default devise modules. Others available are:
Expand Down
2 changes: 1 addition & 1 deletion app/models/website.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# strategy :string
#

class Website < ActiveRecord::Base
class Website < ApplicationRecord
validates_presence_of :title, :url
validates_url :url
validates_uniqueness_of :url
Expand Down
3 changes: 3 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class Application < Rails::Application

config.active_record.schema_format = :sql

#config.action_controller.per_form_csrf_tokens = true
#config.action_controller.forgery_protection_origin_check = true

# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
Expand Down

0 comments on commit b6385ed

Please sign in to comment.