From f366d52c3d10693f634c569516969e5907c9485a Mon Sep 17 00:00:00 2001 From: Daniel Y Date: Thu, 16 Oct 2014 04:54:09 +0800 Subject: [PATCH 1/5] Add Twitter Card markup to Individual team pages --- app/views/layouts/application.html.haml | 1 + app/views/teams/premium.html.haml | 9 +++++++++ 2 files changed, 10 insertions(+) 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' From b1bcbcade29943ddbb577608d415d951c4314ac4 Mon Sep 17 00:00:00 2001 From: Mike Hall Date: Mon, 13 Oct 2014 15:11:30 -0500 Subject: [PATCH 2/5] Restored the IndexProtipJob --- app/jobs/index_protip_job.rb | 10 ++++++++++ app/jobs/search_sync_job.rb | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 app/jobs/index_protip_job.rb 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..40b9953c 100644 --- a/app/jobs/search_sync_job.rb +++ b/app/jobs/search_sync_job.rb @@ -24,7 +24,7 @@ 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" From 6d8f79812f3d6e8d8565568842fd2965691fc454 Mon Sep 17 00:00:00 2001 From: Abdelkader Boudih Date: Wed, 15 Oct 2014 15:37:21 +0000 Subject: [PATCH 3/5] Skip search indexation if another job is enqueued. --- app/jobs/search_sync_job.rb | 14 +++++++++----- config/sidekiq.yml | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/jobs/search_sync_job.rb b/app/jobs/search_sync_job.rb index 40b9953c..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) @@ -26,8 +28,10 @@ def perform unindexed_protips.each do |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/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] From 8868d173c283df828231a0b50f2484353a6b0942 Mon Sep 17 00:00:00 2001 From: Abdelkader Boudih Date: Wed, 15 Oct 2014 15:59:25 +0000 Subject: [PATCH 4/5] Fix Travis build --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2ad5847d..39e18c2f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ services: - 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 From d15e899bea435f235ca1f76aa39371f2f2c5b363 Mon Sep 17 00:00:00 2001 From: Abdelkader Boudih Date: Thu, 16 Oct 2014 08:11:18 +0000 Subject: [PATCH 5/5] use ruby 2.1.3 for travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 39e18c2f..0515500c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: ruby rvm: -- 2.1.2 +- 2.1.3 bundler_args: "--without development production autotest" services: - mongodb