Sha256: 96a23deb019814dafcbcdc11c5524f95708b025fc7eb80133bdc3c3fc45bce09
Contents?: true
Size: 1.01 KB
Versions: 4
Compression:
Stored size: 1.01 KB
Contents
require 'sequel' require 'sequel/extensions/migration' Sequel::Model.plugin(:schema) # for table_exists? $db = Sequel.sqlite(Tickets::Config::DB_PATH) class Ticket < Sequel::Model(:tickets) @@last_shook = Time.now def self.needs_shaking? (Time.now - @@last_shook) > Tickets::Config::SHAKE_INTERVAL*60*60 end def self.shake! Ticket.each do |ticket| pos = ticket.emergency dir = (ticket.importance < 0 ? 1 : -1) newpos = pos + Tickets::Config::SHAKE_DISTANCE * dir if newpos > (Tickets::Config::BOARD_WIDTH / 2) newpos = (Tickets::Config::BOARD_WIDTH / 2) end ticket.update(:emergency => newpos) if newpos != pos if newpos < -(Tickets::Config::BOARD_WIDTH / 2) ticket.update(:deleted => true, :timeouted => true) end end @@last_shook = Time.now end end unless Ticket.table_exists? migration_dir = File.expand_path("../db/migrate/", File.dirname(__FILE__)) Sequel::Migrator.apply($db, migration_dir) end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
yhara-tickets-0.1.0.1 | model/ticket.rb |
yhara-tickets-0.1.0.2 | model/ticket.rb |
yhara-tickets-0.1.0.3 | model/ticket.rb |
yhara-tickets-0.1.0 | model/ticket.rb |