Skip to content

Commit

Permalink
Strip out solr usage
Browse files Browse the repository at this point in the history
This is to replace solr with a simpler postgres-based search system
to reduce costs, which will allow me to improve the performance of
other parts of the site
  • Loading branch information
Robert May committed Feb 27, 2014
1 parent eb1aa98 commit 72ff26d
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 87 deletions.
4 changes: 0 additions & 4 deletions Gemfile
Expand Up @@ -36,10 +36,6 @@ gem 'pg'
# search # search
gem 'pg_search' gem 'pg_search'
gem 'pg_array_parser' gem 'pg_array_parser'
gem 'sunspot_rails'
gem 'sunspot_solr'
gem 'sunspot-queue', github: 'robotmay/sunspot-queue'
gem 'sunspot_with_kaminari'


# redis # redis
gem 'redis-objects' gem 'redis-objects'
Expand Down
26 changes: 0 additions & 26 deletions Gemfile.lock
Expand Up @@ -6,13 +6,6 @@ GIT
omniauth (~> 1.0) omniauth (~> 1.0)
omniauth-oauth2 omniauth-oauth2


GIT
remote: git://github.com/robotmay/sunspot-queue.git
revision: 32e922edb103a867507e7935065d90ebec2278de
specs:
sunspot-queue (0.10.0)
sunspot_rails (>= 1.3.0)

GIT GIT
remote: git://github.com/sporkrb/spork-rails.git remote: git://github.com/sporkrb/spork-rails.git
revision: 0dd45e59d3237b4c8f9efc215b46d9c07072a95e revision: 0dd45e59d3237b4c8f9efc215b46d9c07072a95e
Expand Down Expand Up @@ -265,7 +258,6 @@ GEM
postmark-rails (0.6.0) postmark-rails (0.6.0)
actionmailer (>= 3.0.0) actionmailer (>= 3.0.0)
postmark (~> 1.1.0) postmark (~> 1.1.0)
pr_geohash (1.0.0)
proxies (0.2.1) proxies (0.2.1)
pry (0.9.12.6) pry (0.9.12.6)
coderay (~> 1.0) coderay (~> 1.0)
Expand Down Expand Up @@ -315,8 +307,6 @@ GEM
redis (>= 3.0.2) redis (>= 3.0.2)
rest-client (1.6.7) rest-client (1.6.7)
mime-types (>= 1.16) mime-types (>= 1.16)
rsolr (1.0.9)
builder (>= 2.1.2)
rspec (2.14.1) rspec (2.14.1)
rspec-core (~> 2.14.0) rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0) rspec-expectations (~> 2.14.0)
Expand Down Expand Up @@ -393,18 +383,6 @@ GEM
json (~> 1.8.1) json (~> 1.8.1)
mime-types (~> 1.25) mime-types (~> 1.25)
rest-client (~> 1.4) rest-client (~> 1.4)
sunspot (2.1.0)
pr_geohash (~> 1.0)
rsolr (~> 1.0.7)
sunspot_rails (2.1.0)
nokogiri
rails (>= 3)
sunspot (= 2.1.0)
sunspot_solr (2.1.0)
sunspot_with_kaminari (0.2.0)
kaminari (>= 0.14.0)
sunspot
sunspot_rails
temple (0.6.7) temple (0.6.7)
term-ansicolor (1.3.0) term-ansicolor (1.3.0)
tins (~> 1.0) tins (~> 1.0)
Expand Down Expand Up @@ -509,10 +487,6 @@ DEPENDENCIES
slim (>= 1.3.0) slim (>= 1.3.0)
spork-rails! spork-rails!
stripe stripe
sunspot-queue!
sunspot_rails
sunspot_solr
sunspot_with_kaminari
thread thread
timecop timecop
turbolinks turbolinks
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/photographs_controller.rb
Expand Up @@ -100,6 +100,8 @@ def seeking_feedback
end end


def search def search
redirect_to photographs_path

if search_params[:q].blank? && search_params[:keyword].blank? if search_params[:q].blank? && search_params[:keyword].blank?
redirect_to(photographs_path) and return redirect_to(photographs_path) and return
end end
Expand Down
30 changes: 0 additions & 30 deletions app/models/photograph.rb
Expand Up @@ -106,36 +106,6 @@ class Photograph < ActiveRecord::Base
scope :for_month, -> (date_range) { scope :for_month, -> (date_range) {
where(created_at: date_range) where(created_at: date_range)
} }

searchable do
text :title do |photo|
photo.metadata.title
end

text :description do |photo|
photo.metadata.description
end

string :keywords, multiple: true do |photo|
photo.metadata.keywords
end

text :creator_name do |photo|
photo.user.name
end

integer :user_id, references: User
integer :license_id, references: License
integer :category_id, references: Category
integer :collection_ids, references: Collection, multiple: true do |photo|
photo.collections.pluck(:id)
end
float :score
time :created_at
boolean :public, using: :public?
boolean :safe_for_work
boolean :ghost
end


def favourites_count def favourites_count
super || 0 super || 0
Expand Down
12 changes: 0 additions & 12 deletions app/views/shared/_anon_nav.html.slim
Expand Up @@ -30,18 +30,6 @@ nav id="layout-nav" class="top-bar"


= link_to t("nav.seeking_feedback"), seeking_feedback_photographs_path, active_on: true, active_wrapper: :li = link_to t("nav.seeking_feedback"), seeking_feedback_photographs_path, active_on: true, active_wrapper: :li


div class="row"
div class="large-12 columns"
label= t("nav.search")
= form_tag search_photographs_path, method: :get do
div class="row collapse"
div class="small-8 columns"
= text_field_tag :q, params[:q]

div class="small-4 columns"
= submit_tag t("nav.search"), class: "button secondary"
.clear

div class="row" div class="row"
div class="large-12 columns" div class="large-12 columns"
label= t("nav.categories") label= t("nav.categories")
Expand Down
12 changes: 0 additions & 12 deletions app/views/shared/_nav.html.slim
Expand Up @@ -30,18 +30,6 @@ nav id="layout-nav" class="top-bar"


= link_to t("nav.seeking_feedback"), seeking_feedback_photographs_path, active_on: true, active_wrapper: :li = link_to t("nav.seeking_feedback"), seeking_feedback_photographs_path, active_on: true, active_wrapper: :li


div class="row"
div class="large-12 columns"
label= t("nav.search")
= form_tag search_photographs_path, method: :get do
div class="row collapse"
div class="small-8 columns"
= text_field_tag :q, params[:q]

div class="small-4 columns"
= submit_tag t("nav.search"), class: "button secondary"
.clear

div class="row" div class="row"
div class="large-12 columns" div class="large-12 columns"
label= t("nav.categories") label= t("nav.categories")
Expand Down
3 changes: 0 additions & 3 deletions config/initializers/sunspot.rb

This file was deleted.

0 comments on commit 72ff26d

Please sign in to comment.