diff --git a/.travis.yml b/.travis.yml index 2ad5847d..0515500c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,13 @@ language: ruby rvm: -- 2.1.2 +- 2.1.3 bundler_args: "--without development production autotest" services: - mongodb - redis-server before_install: - wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.13.deb +- sudo dpkg --purge elasticsearch - sudo dpkg -i elasticsearch-0.90.13.deb - sudo service elasticsearch start - gem update --system diff --git a/app/jobs/index_protip_job.rb b/app/jobs/index_protip_job.rb new file mode 100644 index 00000000..b3ee8fa5 --- /dev/null +++ b/app/jobs/index_protip_job.rb @@ -0,0 +1,10 @@ +class IndexProtipJob + include Sidekiq::Worker + + sidekiq_options queue: :high + + def perform(protip_id) + protip = Protip.find(protip_id) + protip.tire.update_index unless protip.user.banned? + end +end diff --git a/app/jobs/search_sync_job.rb b/app/jobs/search_sync_job.rb index d907808d..351d5d37 100644 --- a/app/jobs/search_sync_job.rb +++ b/app/jobs/search_sync_job.rb @@ -1,9 +1,11 @@ class SearchSyncJob include Sidekiq::Worker + sidekiq_options queue: :search_sync - sidekiq_options queue: :medium - + # TODO refactor this, when we drop Tire. def perform + return if duplicate_job? # Skip if there is more enqueued jobs + number_of_protips_in_index = Protip.tire.search { query { all } }.total number_of_protips_in_database = Protip.count @@ -13,7 +15,7 @@ def perform query { all } end.map { |protip| protip.id.to_i } - protips_in_database = Protip.select(:id).map(&:id) + protips_in_database = Protip.pluck(:id) #now that we know the sets in db and index, calculate the missing records nonexistent_protips = (protips_in_index - protips_in_database) @@ -24,10 +26,12 @@ def perform end unindexed_protips.each do |unindexed_protip_id| - IndexProtip.perform_async(unindexed_protip_id) + IndexProtipJob.perform_async(unindexed_protip_id) end - - puts "removed #{nonexistent_protips.count} protips and added #{unindexed_protips.count} protips" end end + + def duplicate_job? + Sidekiq::Queue.new('search_sync').size > 2 + end end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 79d7dfcc..291aafb4 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -1,6 +1,7 @@ !!! 5 %html.no-js{lang: 'en'} %head + =metamagic /[if IE] %meta{ content: 'text/html; charset=UTF-8', 'http-equiv' => 'Content-Type' } %title= page_title(yield(:page_title)) diff --git a/app/views/teams/premium.html.haml b/app/views/teams/premium.html.haml index 792d03e6..b80c3210 100644 --- a/app/views/teams/premium.html.haml +++ b/app/views/teams/premium.html.haml @@ -1,3 +1,12 @@ +- if ENV['ENABLE_TWITTER_CARDS'] + - meta twitter: {card: "summary"} + - meta twitter: {site: "@coderwall"} + - meta twitter: {title: sanitize(@team.name)} + - meta twitter: {url: teamname_path(@team.slug)} + - meta twitter: {description: @team.about} + - meta twitter: {image: @team.avatar_url} + - meta twitter: {creator: {id: @team.twitter}} + -content_for :head do =stylesheet_link_tag 'premium-teams' diff --git a/config/sidekiq.yml b/config/sidekiq.yml index 2d33e2bd..588a75bb 100644 --- a/config/sidekiq.yml +++ b/config/sidekiq.yml @@ -7,6 +7,7 @@ production: :queues: - [low, 1] - [default, 2] + - [search_sync, 2] - [medium, 3] - [high, 4] - [urgent, 5]