Sha256: 6837a4409d20ee3b76bff60e607e805145afb5d2f566e59a307011bda7a2008b
Contents?: true
Size: 1.69 KB
Versions: 61
Compression:
Stored size: 1.69 KB
Contents
def puts! a, b='' puts "+++ +++ #{b}" puts a.inspect end namespace :ish_manager do desc "every user needs a user_profile" task :generate_user_profiles => :environment do User.all.map do |u| unless u.profile p = ::Ish::UserProfile.new :email => u.email, :user => u, :role_name => :guy u.profile = p u.save && p.save && print('.') end end puts 'OK' end desc 'assign my creator_profile to Gameui::Marker where missing' task :gameui_markers_creator_profile => :environment do ms = Gameui::Marker.where( creator_profile_id: nil ) profile = User.find_by( email: 'piousbox@gmail.com' ).profile ms.update_all( creator_profile_id: profile.id ) end desc 'watch the stocks, and trigger actions - not alphavantage, tda now. 2021-08-08' task watch_stocks: :environment do while true stocks = Warbler::StockWatch.where( notification_type: :EMAIL ) stocks.each do |stock| begin Timeout::timeout( 10 ) do out = Warbler::Ameritrade::Api.get_quote({ symbol: stock.ticker }) r = out[:lastPrice] if stock.direction == :ABOVE && r >= stock.price || stock.direction == :BELOW && r <= stock.price IshManager::ApplicationMailer.stock_alert( stock ).deliver end end rescue Exception => e puts! e, 'Error in ish_manager:watch_stocks :' end end sleep Warbler::StockWatch::SLEEP_TIME_SECONDS end end desc 'watch condors' task watch_condors: :environment do watcher = ::Ish::IronCondorWatcher.new while true watcher.watch_once print '.' sleep 60 # seconds end end end
Version data entries
61 entries across 61 versions & 1 rubygems