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

Version Path
ish_manager-0.1.8.350 lib/tasks/ish_manager_tasks.rake
ish_manager-0.1.8.349 lib/tasks/ish_manager_tasks.rake
ish_manager-0.1.8.348 lib/tasks/ish_manager_tasks.rake
ish_manager-0.1.8.347 lib/tasks/ish_manager_tasks.rake
ish_manager-0.1.8.346 lib/tasks/ish_manager_tasks.rake
ish_manager-0.1.8.345 lib/tasks/ish_manager_tasks.rake
ish_manager-0.1.8.344 lib/tasks/ish_manager_tasks.rake
ish_manager-0.1.8.343 lib/tasks/ish_manager_tasks.rake
ish_manager-0.1.8.342 lib/tasks/ish_manager_tasks.rake
ish_manager-0.1.8.341 lib/tasks/ish_manager_tasks.rake
ish_manager-0.1.8.340 lib/tasks/ish_manager_tasks.rake
ish_manager-0.1.8.339 lib/tasks/ish_manager_tasks.rake
ish_manager-0.1.8.338 lib/tasks/ish_manager_tasks.rake
ish_manager-0.1.8.337 lib/tasks/ish_manager_tasks.rake
ish_manager-0.1.8.336 lib/tasks/ish_manager_tasks.rake
ish_manager-0.1.8.335 lib/tasks/ish_manager_tasks.rake
ish_manager-0.1.8.334 lib/tasks/ish_manager_tasks.rake
ish_manager-0.1.8.333 lib/tasks/ish_manager_tasks.rake
ish_manager-0.1.8.332 lib/tasks/ish_manager_tasks.rake
ish_manager-0.1.8.331 lib/tasks/ish_manager_tasks.rake