source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100428190907_create_skips_model.rb | Ruby | bsd-3-clause | 49 | master | 412 | class CreateSkipsModel < ActiveRecord::Migration
def self.up
create_table :skips do |table|
table.text :tracking
table.integer :site_id
table.integer :skipper_id
table.integer :question_id
table.integer :prompt_id
table.integer :appearance_id
table.integer :time_viewed #m... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20110120202304_add_voter_id_index_on_appearances.rb | Ruby | bsd-3-clause | 49 | master | 299 | class AddVoterIdIndexOnAppearances < ActiveRecord::Migration
def self.up
add_index :appearances, [:question_id, :voter_id], :name => 'index_appearances_on_question_id_voter_id'
end
def self.down
remove_index :appearances, :name => :index_appearances_on_question_id_voter_id
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20091203220706_add_local_identifier_to_questions.rb | Ruby | bsd-3-clause | 49 | master | 211 | class AddLocalIdentifierToQuestions < ActiveRecord::Migration
def self.up
add_column :questions, :local_identifier, :string
end
def self.down
remove_column :questions, :local_identifier
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100517153944_add_missing_response_time_exp_to_votes.rb | Ruby | bsd-3-clause | 49 | master | 869 | class AddMissingResponseTimeExpToVotes < ActiveRecord::Migration
def self.up
add_column :votes, :missing_response_time_exp, :string, :default => ""
add_column :skips, :missing_response_time_exp, :string, :default => ""
begin
recording_client_time_start_date = Vote.find(:all, :conditions => 'time_v... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20091203175954_create_votes.rb | Ruby | bsd-3-clause | 49 | master | 349 | class CreateVotes < ActiveRecord::Migration
def self.up
create_table :votes do |table|
table.text :tracking
table.integer :site_id
table.integer :voter_id
table.integer :voteable_id
table.string :voteable_type, :default => ""
table.timestamps
end
end
def self.down
... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100716121029_add_valid_flag_to_appearances.rb | Ruby | bsd-3-clause | 49 | master | 340 | class AddValidFlagToAppearances < ActiveRecord::Migration
def self.up
add_column :appearances, :valid_record, :boolean, :default => true
add_column :appearances, :validity_information, :string
end
def self.down
remove_column :appearances, :valid_record
remove_column :appearances, :validity_in... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20091203165033_create_items.rb | Ruby | bsd-3-clause | 49 | master | 392 | class CreateItems < ActiveRecord::Migration
def self.up
create_table "items", :force => true do |t|
t.text "data"
t.boolean "active"
t.text "tracking"
t.integer "creator_id"
t.integer "voter_id"
t.integer "site_id"
t.datetime "created_at"
t.datetime "upda... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100722052215_remove_unused_prompt_attributes.rb | Ruby | bsd-3-clause | 49 | master | 446 | class RemoveUnusedPromptAttributes < ActiveRecord::Migration
def self.up
remove_column :prompts, :active
remove_column :prompts, :algorithm_id
remove_column :prompts, :randomkey
remove_column :prompts, :voter_id
end
def self.down
add_column :prompts, :active, :boolean
add_column :prompts,... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20120426144214_add_version_to_choice.rb | Ruby | bsd-3-clause | 49 | master | 1,105 | class AddVersionToChoice < ActiveRecord::Migration
def self.up
# if you want to manually run the query to create
# all the initial versions in choice_versions table set this to true
run_query_manually = false
# default of 1 so all existing rows have a version of 1
add_column :choices, :version, :i... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100331180328_rename_density_type_column.rb | Ruby | bsd-3-clause | 49 | master | 202 | class RenameDensityTypeColumn < ActiveRecord::Migration
def self.up
rename_column :densities, :type, :prompt_type
end
def self.down
rename_column :denisities, :prompt_type, :type
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20091203223145_add_local_identifier_to_choices.rb | Ruby | bsd-3-clause | 49 | master | 205 | class AddLocalIdentifierToChoices < ActiveRecord::Migration
def self.up
add_column :choices, :local_identifier, :string
end
def self.down
remove_column :choices, :local_identifier
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20091204013843_add_votes_count_to_prompts.rb | Ruby | bsd-3-clause | 49 | master | 360 | class AddVotesCountToPrompts < ActiveRecord::Migration
def self.up
add_column :prompts, :votes_count, :integer, :default => 0
Prompt.reset_column_information
Prompt.find(:all).each do |p|
Prompt.update_counters p.id, :votes_count => p.votes.length
end
end
def self.down
remove_... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100505235409_add_choice_indexes_to_prompts.rb | Ruby | bsd-3-clause | 49 | master | 269 | class AddChoiceIndexesToPrompts < ActiveRecord::Migration
def self.up
add_index :prompts, :left_choice_id
add_index :prompts, :right_choice_id
end
def self.down
remove_index :prompts, :left_choice_id
remove_index :prompts, :right_choice_id
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20091204151448_add_prompts_count_to_choices.rb | Ruby | bsd-3-clause | 49 | master | 407 | class AddPromptsCountToChoices < ActiveRecord::Migration
def self.up
add_column :choices, :prompts_count, :integer, :default => 0
Choice.reset_column_information
Choice.find(:all).each do |c|
Choice.update_counters c.id, :prompts_count => c.prompts_on_the_left_count + c.prompts_on_the_right_cou... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20090702053331_create_delayed_jobs.rb | Ruby | bsd-3-clause | 49 | master | 992 | class CreateDelayedJobs < ActiveRecord::Migration
def self.up
create_table :delayed_jobs do |table|
# Allows some jobs to jump to the front of the queue
table.integer :priority, :default => 0
# Provides for retries, but still fail eventually.
table.integer :attempts, :default => 0
... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100714160406_add_polymorphic_answerable_to_appearance.rb | Ruby | bsd-3-clause | 49 | master | 325 | class AddPolymorphicAnswerableToAppearance < ActiveRecord::Migration
def self.up
add_column :appearances, :answerable_id, :integer
add_column :appearances, :answerable_type, :string
end
def self.down
remove_column :appearances, :answerable_id
remove_column :appearances, :answerable_type
end... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20091204012430_add_counter_caches_to_choices.rb | Ruby | bsd-3-clause | 49 | master | 814 | class AddCounterCachesToChoices < ActiveRecord::Migration
def self.up
add_column :choices, :prompts_on_the_left_count, :integer, :default => 0
add_column :choices, :prompts_on_the_right_count, :integer, :default => 0
add_column :choices, :votes_count, :integer, :default => 0
Choice.reset_column_i... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100420130849_add_catchup_bool_to_questions.rb | Ruby | bsd-3-clause | 49 | master | 217 | class AddCatchupBoolToQuestions < ActiveRecord::Migration
def self.up
add_column :questions, :uses_catchup, :boolean, :default => false
end
def self.down
remove_column :questions, :uses_catchup
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100423154040_add_vistor_index_to_votes_table.rb | Ruby | bsd-3-clause | 49 | master | 240 | class AddVistorIndexToVotesTable < ActiveRecord::Migration
def self.up
add_index :votes, :voter_id
add_index :items, :creator_id
end
def self.down
remove_index :votes, :voter_id
remove_index :items, :creator_id
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20091204015325_add_counter_caches_to_questions.rb | Ruby | bsd-3-clause | 49 | master | 514 | class AddCounterCachesToQuestions < ActiveRecord::Migration
def self.up
add_column :questions, :votes_count, :integer, :default => 0
Question.reset_column_information
Question.find(:all).each do |q|
Question.update_counters q.id, :choices_count => q.choices.length
Question.update_counters... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20091203164109_create_choices.rb | Ruby | bsd-3-clause | 49 | master | 561 | class CreateChoices < ActiveRecord::Migration
def self.up
create_table "choices", :force => true do |t|
t.integer "item_id"
t.integer "question_id"
t.integer "position"
t.integer "wins"
t.integer "ratings"
t.integer "losses"
t.datetime "created_at"
t.datetime ... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20091219061442_create_visitor_indexes.rb | Ruby | bsd-3-clause | 49 | master | 218 | class CreateVisitorIndexes < ActiveRecord::Migration
def self.up
add_index :visitors, [:identifier, :site_id], :unique => true
end
def self.down
remove_index :visitors, [:identifier, :site_id]
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100107200151_add_flag_for_idea_activation_to_questions.rb | Ruby | bsd-3-clause | 49 | master | 261 | class AddFlagForIdeaActivationToQuestions < ActiveRecord::Migration
def self.up
add_column :questions, :it_should_autoactivate_ideas, :boolean, :default => false
end
def self.down
remove_column :questions, :it_should_autoactivate_ideas
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20110524171217_add_version_to_question.rb | Ruby | bsd-3-clause | 49 | master | 691 | class AddVersionToQuestion < ActiveRecord::Migration
def self.up
# set default to one because we're going to create
# versions for all the existing data.
add_column :questions, :version, :integer, :default => 1
Question.create_versioned_table
Question.find(:all).each do |q|
attributes = q.at... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100621162849_add_creator_to_choices.rb | Ruby | bsd-3-clause | 49 | master | 283 | class AddCreatorToChoices < ActiveRecord::Migration
def self.up
add_column :choices, :creator_id, :integer
Choice.find(:all, :include => [:item]).each do |c|
c.creator_id = c.item.creator_id
c.save
end
end
def self.down
remove_column :choices, :creator_id
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20091204025823_add_loss_count_to_choices.rb | Ruby | bsd-3-clause | 49 | master | 203 | class AddLossCountToChoices < ActiveRecord::Migration
def self.up
add_column :choices, :loss_count, :integer, :default => 0
end
def self.down
remove_column :choices, :loss_count
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100617162132_make_catchup_default.rb | Ruby | bsd-3-clause | 49 | master | 237 | class MakeCatchupDefault < ActiveRecord::Migration
def self.up
change_column :questions, :uses_catchup, :boolean, :default => true
end
def self.down
change_column :questions, :uses_catchup, :boolean, :default => false
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20091203163251_create_visitors.rb | Ruby | bsd-3-clause | 49 | master | 352 | class CreateVisitors < ActiveRecord::Migration
def self.up
create_table :visitors do |table|
table.integer :site_id
table.string :identifier, :default => ""
table.text :tracking
table.boolean :activated
table.integer :user_id
table.timestamps
end
end
def self.down
... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20110124211740_add_show_results_to_questions.rb | Ruby | bsd-3-clause | 49 | master | 215 | class AddShowResultsToQuestions < ActiveRecord::Migration
def self.up
add_column :questions, :show_results, :boolean, :default => 1
end
def self.down
remove_column :questions, :show_results
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20110131154228_convert_last_error_to_text_in_delayed_jobs.rb | Ruby | bsd-3-clause | 49 | master | 371 | class ConvertLastErrorToTextInDelayedJobs < ActiveRecord::Migration
def self.up
change_column(:delayed_jobs, :last_error, :text)
add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority'
end
def self.down
change_column(:delayed_jobs, :last_error, :string)
remove_index :delay... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100722050746_remove_unused_question_attributes.rb | Ruby | bsd-3-clause | 49 | master | 539 | class RemoveUnusedQuestionAttributes < ActiveRecord::Migration
def self.up
remove_column :questions, :active_items_count
remove_column :questions, :bloom
remove_column :questions, :first_prompt_algorithm_id
remove_column :questions, :items_count
end
def self.down
add_column :questions, :activ... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20140327170621_create_exports.rb | Ruby | bsd-3-clause | 49 | master | 361 | class CreateExports < ActiveRecord::Migration
def self.up
create_table :exports do |table|
table.string :name, :default => ""
table.integer :question_id
table.binary :data, :limit => 16.megabyte
table.boolean :compressed, :default => 0
end
add_index :exports, :name
end
def sel... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20140609193423_add_algorithm_to_appearance.rb | Ruby | bsd-3-clause | 49 | master | 314 | class AddAlgorithmToAppearance < ActiveRecord::Migration
def self.up
add_column :appearances, :algorithm_name, :string
add_column :appearances, :algorithm_metadata, :text
end
def self.down
remove_column :appearances, :algorithm_name
remove_column :appearances, :algorithm_metadata
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100621164536_move_item_table.rb | Ruby | bsd-3-clause | 49 | master | 307 | class MoveItemTable < ActiveRecord::Migration
def self.up
# Rather than dropping the table, let's move it in case something goes wrong
# feel free to delete the table if nothing goes wrong in the future
rename_table :items, :old_items
end
def self.down
rename_table :old_items, :items
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20091219054212_create_more_prompt_indexes.rb | Ruby | bsd-3-clause | 49 | master | 296 | class CreateMorePromptIndexes < ActiveRecord::Migration
def self.up
add_index :prompts, [:left_choice_id, :right_choice_id, :question_id], :name => "a_cool_index", :unique => true
end
def self.down
remove_index :prompts, [:left_choice_id, :right_choice_id, :question_id]
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20091203173153_create_prompts.rb | Ruby | bsd-3-clause | 49 | master | 450 | class CreatePrompts < ActiveRecord::Migration
def self.up
create_table "prompts", :force => true do |t|
t.integer "algorithm_id"
t.integer "question_id"
t.integer "left_choice_id"
t.integer "right_choice_id"
t.integer "voter_id"
t.boolean "active"
t.datetime "create... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20091203185050_create_skips.rb | Ruby | bsd-3-clause | 49 | master | 317 | class CreateSkips < ActiveRecord::Migration
def self.up
create_table "skips", :force => true do |t|
t.integer "skipper_id"
t.integer "prompt_id"
t.text "tracking"
t.datetime "created_at"
t.datetime "updated_at"
end
end
def self.down
drop_table :skips
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20090701195337_clearance_create_users.rb | Ruby | bsd-3-clause | 49 | master | 600 | class ClearanceCreateUsers < ActiveRecord::Migration
def self.up
create_table(:users) do |t|
t.string :email
t.string :encrypted_password, :limit => 128
t.string :salt, :limit => 128
t.string :confirmation_token, :limit => 128
t.string :remember_token, :li... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100401230916_create_appearances.rb | Ruby | bsd-3-clause | 49 | master | 484 | class CreateAppearances < ActiveRecord::Migration
def self.up
create_table :appearances do |table|
table.integer :voter_id
table.integer :site_id
table.integer :prompt_id
table.integer :question_id
table.string :lookup
table.timestamps
end
add_column :votes, :appearanc... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20091203161430_create_questions.rb | Ruby | bsd-3-clause | 49 | master | 741 | class CreateQuestions < ActiveRecord::Migration
def self.up
create_table "questions", :force => true do |t|
t.integer "creator_id"
t.string "name", :default => ""
t.datetime "created_at"
t.datetime "updated_at"
t.integer "items_count", :default ... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20091219050747_add_index_to_prompts.rb | Ruby | bsd-3-clause | 49 | master | 220 | class AddIndexToPrompts < ActiveRecord::Migration
def self.up
add_index :prompts, [:left_choice_id, :right_choice_id]
end
def self.down
remove_index :prompts, [:left_choice_id, :right_choice_id]
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100727203816_remove_wins_losses_and_rename_counts.rb | Ruby | bsd-3-clause | 49 | master | 459 | class RemoveWinsLossesAndRenameCounts < ActiveRecord::Migration
def self.up
remove_column :choices, :wins
remove_column :choices, :losses
rename_column :choices, :votes_count, :wins
rename_column :choices, :loss_count, :losses
end
def self.down
rename_column :choices, :wins, :votes_count
... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20110628160608_add_index_for_created_at_question_id_to_votes.rb | Ruby | bsd-3-clause | 49 | master | 517 | class AddIndexForCreatedAtQuestionIdToVotes < ActiveRecord::Migration
# this is for a query in the admin area
# EXPLAIN SELECT count(*) AS count_all, votes.question_id AS votes_question_id FROM `votes` INNER JOIN `questions` ON `questions`.id = `votes`.question_id WHERE (votes.created_at > '2011-06-01') AND (votes... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100331161516_create_densities.rb | Ruby | bsd-3-clause | 49 | master | 291 | class CreateDensities < ActiveRecord::Migration
def self.up
create_table :densities do |table|
table.integer :question_id
table.float :value
table.string :type, :default => ""
table.timestamps
end
end
def self.down
drop_table :densities
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100506003102_add_indexes_to_skips.rb | Ruby | bsd-3-clause | 49 | master | 235 | class AddIndexesToSkips < ActiveRecord::Migration
def self.up
add_index :skips, :question_id
add_index :skips, :prompt_id
end
def self.down
remove_index :skips, :question_id
remove_index :skips, :prompt_id
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20101221143936_add_indexes_to_vote.rb | Ruby | bsd-3-clause | 49 | master | 450 | class AddIndexesToVote < ActiveRecord::Migration
def self.up
add_index(:votes, :loser_choice_id, :name => 'loser_choice_id_idx')
add_index(:votes, :choice_id, :name => 'choice_id_idx')
add_index(:votes, :question_id, :name => 'question_id_idx')
end
def self.down
remove_index(:votes, :name => :los... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20091203190244_create_clicks.rb | Ruby | bsd-3-clause | 49 | master | 278 | class CreateClicks < ActiveRecord::Migration
def self.up
create_table :clicks do |table|
table.integer :site_id
table.integer :visitor_id
table.text :additional_info
table.timestamps
end
end
def self.down
drop_table :clicks
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100719030739_add_valid_flags_to_votes_and_skips.rb | Ruby | bsd-3-clause | 49 | master | 514 | class AddValidFlagsToVotesAndSkips < ActiveRecord::Migration
def self.up
add_column :votes, :valid_record, :boolean, :default => true
add_column :votes, :validity_information, :string
add_column :skips, :valid_record, :boolean, :default => true
add_column :skips, :validity_information, :string
end
de... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100323180141_set_blank_score_values_to_default_fifty.rb | Ruby | bsd-3-clause | 49 | master | 202 | class SetBlankScoreValuesToDefaultFifty < ActiveRecord::Migration
def self.up
ActiveRecord::Base.connection.execute('UPDATE choices SET score=50.0 where score =0')
end
def self.down
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100331213516_add_time_viewed_to_votes.rb | Ruby | bsd-3-clause | 49 | master | 205 | class AddTimeViewedToVotes < ActiveRecord::Migration
def self.up
add_column :votes, :time_viewed, :integer #msec
end
def self.down
remove_column :votes, :time_viewed, :integer #msec
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100325155833_add_inactive_choice_count_to_questions.rb | Ruby | bsd-3-clause | 49 | master | 408 | class AddInactiveChoiceCountToQuestions < ActiveRecord::Migration
def self.up
add_column :questions, :inactive_choices_count, :integer, :default => 0
Question.reset_column_information
Question.find(:all).each do |q|
Question.update_counters(q.id, :inactive_choices_count => q.choices.inactive.size)
end... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100326153823_update_incorrect_scores.rb | Ruby | bsd-3-clause | 49 | master | 627 | class UpdateIncorrectScores < ActiveRecord::Migration
def self.up
# some scores were computed incorrectly as a result of a bug
# This only affected the cached value of the score, so we only need to recalculate the correct score
# for those choices voted on in the last few days
startDate = 2.days.ago
v... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20091203195125_add_what_was_clicked_to_clicks.rb | Ruby | bsd-3-clause | 49 | master | 201 | class AddWhatWasClickedToClicks < ActiveRecord::Migration
def self.up
add_column :clicks, :what_was_clicked, :string
end
def self.down
remove_column :clicks, :what_was_clicked
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100128031509_add_data_to_choices.rb | Ruby | bsd-3-clause | 49 | master | 292 | class AddDataToChoices < ActiveRecord::Migration
def self.up
add_column :choices, :data, :string
puts "copying existing item data into associated choices ..."
Choice.all.each {|c| c.data = c.item.data; c.save!}
end
def self.down
remove_column :choices, :data
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20111017171903_add_index_on_answerable_to_appearances.rb | Ruby | bsd-3-clause | 49 | master | 242 | class AddIndexOnAnswerableToAppearances < ActiveRecord::Migration
def self.up
add_index :appearances, [:answerable_id, :answerable_type]
end
def self.down
remove_index :appearances, [:answerable_id, :answerable_type]
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100215170926_create_refactored_vote_model.rb | Ruby | bsd-3-clause | 49 | master | 411 | class CreateRefactoredVoteModel < ActiveRecord::Migration
def self.up
create_table :votes do |table|
table.text :tracking
table.integer :site_id
table.integer :voter_id
table.integer :question_id
table.integer :prompt_id
table.integer :choice_id
table.integer :loser_choic... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | features/support/paths.rb | Ruby | bsd-3-clause | 49 | master | 448 | module NavigationHelpers
def path_to(page_name)
case page_name
when /the homepage/i
root_path
when /the sign up page/i
new_user_path
when /the sign in page/i
new_session_path
when /the password reset request page/i
new_password_path
# Add more page name => path mappin... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | features/support/env.rb | Ruby | bsd-3-clause | 49 | master | 2,648 | # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | features/step_definitions/paperclip_steps.rb | Ruby | bsd-3-clause | 49 | master | 545 | When /^I attach an? "([^\"]*)" "([^\"]*)" file to an? "([^\"]*)" on S3$/ do |filename, extension, klass|
filename = filename.to_sym
definition = klass.gsub(" ", "_").classify.constantize.attachment_definitions[filename]
path = "http://s3.amazonaws.com/:id/#{definition[:path]}"
path.gsub!(/:([^\/\.]+)/) do |m... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | features/step_definitions/webrat_steps.rb | Ruby | bsd-3-clause | 49 | master | 4,033 | require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
# Commonly used webrat steps
# http://github.com/brynary/webrat
Given /^I am on (.+)$/ do |page_name|
visit path_to(page_name)
end
When /^I go to (.+)$/ do |page_name|
visit path_to(page_name)
end
When /^I press "([^\"]*)"$/ d... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | features/step_definitions/clearance_steps.rb | Ruby | bsd-3-clause | 49 | master | 3,290 | # General
Then /^I should see error messages$/ do
assert_match /error(s)? prohibited/m, response.body
end
# Database
Given /^no user exists with an email of "(.*)"$/ do |email|
assert_nil User.find_by_email(email)
end
Given /^I signed up with "(.*)\/(.*)"$/ do |email, password|
user = Factory :user,
:emai... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | app/controllers/visitors_controller.rb | Ruby | bsd-3-clause | 49 | master | 3,991 | class VisitorsController < InheritedResources::Base
respond_to :xml, :json
before_filter :authenticate
actions :index
def index
cond = params[:question_id] ? "question_id = #{params[:question_id]}" : nil
counts = {}
if params[:votes_count]
counts[:votes_count] = Vote.count(:conditions =... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | app/controllers/exports_controller.rb | Ruby | bsd-3-clause | 49 | master | 569 | class ExportsController < InheritedResources::Base
before_filter :authenticate
def show
e = Export.find_by_name(params[:id])
if e.nil? || e.data.nil? || !current_user.question_ids.include?(e.question_id)
render :text => "Not found.", :status => 404, :content_type => 'text/html' and return
end
... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | app/controllers/prompts_controller.rb | Ruby | bsd-3-clause | 49 | master | 4,462 | class PromptsController < InheritedResources::Base
respond_to :xml, :json
actions :show
belongs_to :question
has_scope :voted_on_by
before_filter :authenticate
# To record a vote
# required parameters - prompt id, ordinality, visitor_identifer?
# optional params - visitor_identifier, appe... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | app/controllers/choices_controller.rb | Ruby | bsd-3-clause | 49 | master | 4,193 | class ChoicesController < InheritedResources::Base
respond_to :xml, :json
actions :show, :index, :create, :update, :new
belongs_to :question
has_scope :active, :type => :boolean, :only => :index
before_filter :authenticate
def index
if params[:limit]
@question = current_user.questions.find(par... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | app/controllers/densities_controller.rb | Ruby | bsd-3-clause | 49 | master | 363 | class DensitiesController < InheritedResources::Base
respond_to :xml, :json
before_filter :authenticate
actions :index
def index
if params[:question_id]
logger.info(" Got a question id")
@densities = Density.find(:all, :conditions => {:question_id => params[:question_id] }, :order => :creat... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | app/controllers/questions_controller.rb | Ruby | bsd-3-clause | 49 | master | 14,148 | class QuestionsController < InheritedResources::Base
actions :all, :except => [ :show, :edit, :delete ]
before_filter :authenticate
respond_to :xml, :json
respond_to :csv, :only => :export #leave the option for xml export here
belongs_to :site, :optional => true
def show
@question = current_user.questi... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | app/models/user.rb | Ruby | bsd-3-clause | 49 | master | 2,934 | class User < ActiveRecord::Base
include Clearance::User
has_many :visitors, :class_name => "Visitor", :foreign_key => "site_id"
has_many :questions, :class_name => "Question", :foreign_key => "site_id"
has_many :clicks, :class_name => "Click", :foreign_key => "site_id"
def default_visitor
visitors.find... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | app/models/choice.rb | Ruby | bsd-3-clause | 49 | master | 5,209 | class Choice < ActiveRecord::Base
acts_as_versioned :if_changed => [:data, :creator_id, :question_id, :active]
belongs_to :question, :counter_cache => true
belongs_to :creator, :class_name => "Visitor", :foreign_key => "creator_id"
validates_presence_of :creator, :on => :create, :message => "can't be blan... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | app/models/click.rb | Ruby | bsd-3-clause | 49 | master | 568 | class Click < ActiveRecord::Base
belongs_to :site
belongs_to :visitor
def page
ip = what_was_clicked.split('[ip: ')[1].split(']').first rescue nil
end
def geoip_link
"<a href='http://api.hostip.info/get_html.php?ip=#{ip}'>#{ip}</a>"
end
def geoip_url
"http://api.hostip.info/get_html... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | app/models/skip.rb | Ruby | bsd-3-clause | 49 | master | 265 | class Skip < ActiveRecord::Base
belongs_to :skipper, :class_name => "Visitor", :foreign_key => "skipper_id"
belongs_to :question
belongs_to :prompt
has_one :appearance, :as => :answerable
default_scope :conditions => "#{table_name}.valid_record = 1"
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | app/models/appearance.rb | Ruby | bsd-3-clause | 49 | master | 424 | class Appearance < ActiveRecord::Base
belongs_to :voter, :class_name => "Visitor", :foreign_key => 'voter_id'
belongs_to :prompt
belongs_to :question
belongs_to :answerable, :polymorphic => true
default_scope :conditions => {:valid_record => true}
def answered?
!self.answerable_id.nil?
end
def se... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | app/models/prompt.rb | Ruby | bsd-3-clause | 49 | master | 2,232 | class Prompt < ActiveRecord::Base
#has_many :choices, :order => 'position DESC'
has_many :skips
has_many :votes
has_many :appearances
belongs_to :question, :counter_cache => true
belongs_to :left_choice, :class_name => "Choice", :foreign_key => "left_choice_id", :counter_cache => :prompts_on_the_left... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | app/models/question.rb | Ruby | bsd-3-clause | 49 | master | 29,068 | class Question < ActiveRecord::Base
acts_as_versioned
require 'set'
include Utility
extend ActiveSupport::Memoizable
belongs_to :creator, :class_name => "Visitor", :foreign_key => "creator_id"
belongs_to :site, :class_name => "User", :foreign_key => "site_id"
has_many :choices, :order => 'score DES... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | app/models/visitor.rb | Ruby | bsd-3-clause | 49 | master | 5,608 | class Visitor < ActiveRecord::Base
belongs_to :site, :class_name => "User", :foreign_key => "site_id"
has_many :questions, :class_name => "Question", :foreign_key => "creator_id"
has_many :votes, :class_name => "Vote", :foreign_key => "voter_id"
has_many :skips, :class_name => "Skip", :foreign_key => "skipper_i... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | app/models/cron_mailer.rb | Ruby | bsd-3-clause | 49 | master | 371 | unless Rails.env == "development"
include SendGrid
end
class CronMailer < ActionMailer::Base
def info_message(recipients, subject, message, sent_at= Time.now)
@recipients = recipients
@from = 'cronjob@allourideas.org'
@subject ="[All Our Ideas] " + subject
@sent_on = sent_at
@body[:message] = message
... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | app/models/vote.rb | Ruby | bsd-3-clause | 49 | master | 3,069 | class Vote < ActiveRecord::Base
# belongs_to :voteable, :polymorphic => true, :counter_cache => true
validates_presence_of :question
validates_presence_of :prompt
validates_presence_of :choice
validates_presence_of :loser_choice
validates_presence_of :voter
belongs_to :voter, :class_name => "Visitor", :fo... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | config/boot.rb | Ruby | bsd-3-clause | 49 | master | 3,039 | # Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
module Rails
class << self
def boot!
unless booted?
preinitialize
pick_boot.run
end
end
def booted?
... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | config/environment.rb | Ruby | bsd-3-clause | 49 | master | 734 | # Be sure to restart your server when you modify this file
Encoding.default_external = Encoding.default_internal = Encoding::UTF_8 if defined? Encoding
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.18' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environm... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | config/routes.rb | Ruby | bsd-3-clause | 49 | master | 1,438 | ActionController::Routing::Routes.draw do |map|
map.resources :densities, :only => :index
map.resources :visitors, :only => :index,
:collection => {:objects_by_session_ids => :post},
:member => {:votes => :get}
map.resources :exports, :only => :show
map.reso... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | config/initializers/backtrace_silencers.rb | Ruby | bsd-3-clause | 49 | master | 326 | SHOULDA_NOISE = %w( shoulda )
FACTORY_GIRL_NOISE = %w( factory_girl )
THOUGHTBOT_NOISE = SHOULDA_NOISE + FACTORY_GIRL_NOISE
Rails.backtrace_cleaner.add_silencer do |line|
THOUGHTBOT_NOISE.any? { |dir| line.include?(dir) }
end
# When debugging, uncomment the next line.
# Rails.backtrace_cleaner.remove_silenc... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | config/initializers/mail.rb | Ruby | bsd-3-clause | 49 | master | 590 | # Use config vars to get your Gmail credentials onto Heroku.
# They will be automatically picked up by this file in production.
# heroku config:add GMAIL_EMAIL=dcroak@example.com GMAIL_PASSWORD=password
ActionMailer::Base.smtp_settings = {
:address => "smtp.sendgrid.net",
:port => "25",
:authen... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | config/initializers/google_analytics.rb | Ruby | bsd-3-clause | 49 | master | 266 | # Google Analytics is only available in production by default
# http://github.com/rubaidh/google_analytics
Rubaidh::GoogleAnalytics.environments = ['production', 'staging']
Rubaidh::GoogleAnalytics.tracker_id = ENV['GOOGLE_ANALYTICS_TRACKER_ID'] || "UA-11703548-1" |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | config/initializers/errors.rb | Ruby | bsd-3-clause | 49 | master | 716 | require 'net/smtp'
# Example:
# begin
# some http call
# rescue *HTTP_ERRORS => error
# notify_hoptoad error
# end
HTTP_ERRORS = [Timeout::Error,
Errno::EINVAL,
Errno::ECONNRESET,
EOFError,
Net::HTTPBadResponse,
Net::HTTPHeaderSyn... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | config/initializers/delayed_job.rb | Ruby | bsd-3-clause | 49 | master | 459 | Delayed::Worker.backend = :active_record
Delayed::Worker.destroy_failed_jobs = false
Delayed::Worker.sleep_delay = 5
Delayed::Worker.max_attempts = 5
Delayed::Worker.max_run_time = 40.minutes
Delayed::Worker.default_priority = 20
#class Delayed::Worker
# alias_method :original_handle_failed_job, :handle_failed_job
#... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | config/initializers/utf8_monkey_patches.rb | Ruby | bsd-3-clause | 49 | master | 3,180 | unless RUBY_VERSION == '1.8.7'
# Make sure the logger supports encodings properly.
module ActiveSupport
class BufferedLogger
def add(severity, message = nil, progname = nil, &block)
return if @level > severity
message = (message || (block && block.call) || progname).to_s
# If a... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | config/initializers/flutie_expansion.rb | Ruby | bsd-3-clause | 49 | master | 301 | ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion :flutie => [
'/flutie/stylesheets/reset',
'/flutie/stylesheets/defaults',
'/flutie/stylesheets/type',
'/flutie/stylesheets/forms',
'/flutie/stylesheets/tables',
'/flutie/stylesheets/lists',
'/flutie/stylesheets/screen'
] |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | config/initializers/time_formats.rb | Ruby | bsd-3-clause | 49 | master | 205 | { :short_date => "%x", # 04/13/10
:long_date => "%a, %b %d, %Y" # Tue, Apr 13, 2010
}.each do |k, v|
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.update(k => v)
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | config/initializers/session_store.rb | Ruby | bsd-3-clause | 49 | master | 700 | # Be sure to restart your server when you modify this file.
# Your secret key for verifying cookie session data integrity.
# If you change this key, all old sessions will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
Act... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | config/initializers/bigdecimal-segfault-fix.rb | Ruby | bsd-3-clause | 49 | master | 1,232 | # Copyright (c) 2009 Michael Koziarski <michael@koziarski.com>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" ... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | config/environments/development.rb | Ruby | bsd-3-clause | 49 | master | 859 | # Settings specified here will take precedence over those in config/environment.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.ca... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | config/environments/cucumber.rb | Ruby | bsd-3-clause | 49 | master | 1,039 | # Edit at your own peril - it's recommended to regenerate this file
# in the future when you upgrade to a newer version of Cucumber.
# IMPORTANT: Setting config.cache_classes to false is known to
# break Cucumber's use_transactional_fixtures method.
# For more information see https://rspec.lighthouseapp.com/projects/1... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | config/environments/test.rb | Ruby | bsd-3-clause | 49 | master | 1,222 | # Settings specified here will take precedence over those in config/environment.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | config/environments/staging.rb | Ruby | bsd-3-clause | 49 | master | 709 | # Settings specified here will take precedence over those in config/environment.rb
# We'd like to stay as close to prod as possible
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.action_controller.consider_all_requests_local = fals... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | config/environments/production.rb | Ruby | bsd-3-clause | 49 | master | 1,050 | # Settings specified here will take precedence over those in config/environment.rb
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Use a different logger for distributed setups
# config.logger = SyslogLogger.new
# Full error repor... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | lib/utility.rb | Ruby | bsd-3-clause | 49 | master | 331 | module Utility
def mean(array)
array.inject(0) { |sum, x| sum += x } / array.size.to_f
end
def median(array, already_sorted=false)
return nil if array.empty?
array = array.sort unless already_sorted
m_pos = array.size / 2
return array.size % 2 == 1 ? array[m_pos] : mean(array[m_pos-1..m_pos])... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | lib/clearance_http_auth.rb | Ruby | bsd-3-clause | 49 | master | 962 | #http://gist.github.com/159604
# Overload Clearance's `deny_access` methods to allow authentication with HTTP-Auth for eg. API access
# Modeled after technoweenie's restful_authentication
# http://github.com/technoweenie/restful-authentication/blob/7235d9150e8beb80a819923a4c871ef4069c6759/generators/authenticated/temp... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | lib/audit_logger.rb | Ruby | bsd-3-clause | 49 | master | 289 | class AuditLogger < Logger
def format_message(severity, timestamp, progname, msg)
pid, size = `ps ax -o pid,rss | grep -E "^[[:space:]]*#{Process::pid}"`.chomp.split(/\s+/).map {|s| s.strip.to_i}
"[#{timestamp.to_formatted_s(:db)}] [#{severity}] [#{size} KB] #{msg}\n"
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | lib/rails23_ruby193_fixnum_monkey_patch.rb | Ruby | bsd-3-clause | 49 | master | 333 | class Fixnum
# actionpack-2.3.18/lib/action_controller/assertions/selector_assertions.rb:276
# attempts to get encoding of Fixnum when doing has_tag "foo", :text => 3
# Example: bundle exec spec spec/integration/visitors_spec.rb -e "should return the bounces for a single question"
def encoding
Encoding::UTF... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | lib/rails23_ruby193_ar_associations_monkey_patch.rb | Ruby | bsd-3-clause | 49 | master | 601 | # Finally, we have this innocuous looking patch. Without it, queries like this: current_account.tickets.recent.count
# would instantiate AR objects all (!!) tickets in the account, not merely return a count of the recent ones.
# See https://rails.lighthouseapp.com/projects/8994/tickets/5410-multiple-database-queries-w... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.