Cron jobs - IvanAlvarezEnri/dragon-squad-api GitHub Wiki

  • Room on fire feature
    • Restart every hour the status "on fire" of a room
    • This enum status indicates if the Room was visited last hour or not
    • This feature makes the user more interested and increases the possibility of the objective
    • It's based on Ebay 'being watched' products
      # Clears Rooms on fire (visited on last hour)
      scheduler.cron '0 * * * *' do
        Room.onfire.each do |room|
          room.irrelevant!
        end
      end
    
  • Motivational sentences for the developer
    • We tested the cron function with some puts to the server, so we decided to make a simple 'Motivational sentences' Gem to use with it to help us on development process.
    require 'be_a_dragon'
    
    scheduler = Rufus::Scheduler.new
    motivation = BeADragon::MotivateMePls
    
    scheduler.cron '30 * * * *' do
      motivation.random_sentence('Eric')
    end