Skip to content

Instantly share code, notes, and snippets.

View bleonard's full-sized avatar

Brian Leonard bleonard

View GitHub Profile
apps
shared
app
assets
controllers
shared
controller
authentication.rb
models
shared
apps
shared
app
assets
controllers
shared
authentication.rb
models
shared
post.rb
app
models
user.rb
post.rb
config
db
migrate
engines
customer
app
app
assets
controllers
models
user.rb
post.rb
views
layouts
admin
app
# initializer
ResqueBus.dispatch("profile") do
subscribe "rating_created" do |attributes|
rating = Rating.find(rating_id)
total = Rating.where(rabbit_id: rating.rabbit_id).count
sum = Rating.where(rabbit_id: rating.rabbit_id').sum(:value)
profile = RabbitProfile.find_by(user_id: rating.rabbit_id)
profile.ratings_total = total
profile.rating_average = sum.to_f / (5*total.to_f)
class CalculateAverageWorker
@queue = :default
def self.perform(rating_id)
rating = Rating.find(rating_id)
total = Rating.where(rabbit_id: rating.rabbit_id).count
sum = Rating.where(rabbit_id: rating.rabbit_id').sum(:value)
profile = RabbitProfile.find_by(user_id: rating.rabbit_id)
profile.ratings_total = total
config.before(:suite) do
Offshore.suite.start(:host => "localhost", :port => 4111)
end
config.before(:each) do
Offshore.test.start(example)
end
config.after(:each) do
Offshore.test.stop
group :test do
gem 'offshore'
end
namespace :offshore do
task :preload do
ENV['RAILS_ENV'] = "test"
end
task :setup => :environment
desc "seeds the db for offshore gem"
task :seed do
Rake::Task['db:migrate'].invoke
Rake::Task['db:test:prepare'].invoke
Offshore.redis = "localhost:6379"
Offshore.enable! if ENV['OFFSHORE'] == 'true'