This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE stats ( | |
column_name text, | |
column_value int, | |
test_id uuid, | |
score int, | |
height int, | |
PRIMARY KEY (column_name, column_value, test_id) | |
); | |
-- Now let's say we have a logical row with score=20, height=150 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Silently fail instead of raising an exception when an error occurs while writing to Solr. | |
# NOTE: does not fail for reads; you should catch those exceptions, for example in a rescue_from statement. | |
# | |
# To configure, add this to an initializer: | |
# Sunspot.session = SilentFailSessionProxy.new | |
# | |
# This is for Sunspot 0.18 and would need to be changed a little bit for Sunspot 1.0. | |
# | |
class SilentFailSessionProxy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# s.query.keywords = params[:q] unless params[:q].blank? | |
# s.query.order_by(params[:order_by], params[:direction] || 'asc') if params[:order_by] && params[:order_by] != 'distance' | |
# s.query.order_by('content_score', 'desc') unless params[:order_by] && params[:order_by] == 'distance' | |
s.build do |query| | |
query.keywords(params[:q]) unless params[:q].blank? | |
query.order_by(params[:order_by], params[:direction] || 'asc') if params[:order_by] && params[:order_by] != 'distance' | |
query.order_by('content_score', 'desc') unless params[:order_by] && params[:order_by] == 'distance' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unless ENV['RAILS_ROOT'] | |
ENV['RAILS_ROOT'] = Dir.pwd | |
end | |
STDERR.puts("Loading Rails environment...") | |
require File.join(ENV['RAILS_ROOT'], 'config', 'environment') | |
groups = CharacteristicGroup.filter do | |
with(:name).in(['Gender', 'Age', 'Lifestage', 'Internal QA']) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############### Named filter issues. | |
# | |
# 1) The table aliases for explicit joins are hacky. Obviously this is an easy fix, but we should | |
# talk about the best alternative. In this example, the resulting alias should not be "posts_blogs". | |
# | |
# => Agreed, although I can't think of anything really clever at the moment... | |
Post.filter do | |
join(Blog, :left, :posts_blogs) do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Airmigo | |
include DataMapper::Resource | |
property :id, Serial | |
belongs_to :from, :class_name => 'User' | |
belongs_to :to, :class_name => 'User' | |
before :save do | |
Airmigo.first_or_create(:conditions => { :from => to, :to => from }) |
NewerOlder