You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
require "forwardable"
|
|
|
|
|
|
|
|
require "sequel"
|
|
|
|
|
|
|
|
require_relative "db"
|
|
|
|
require_relative "open_skill"
|
|
|
|
|
|
|
|
module RankKing
|
|
|
|
class Pool < Sequel::Model
|
|
|
|
one_to_many :items
|
|
|
|
one_to_many :axes, class: "RankKing::Axis"
|
|
|
|
end
|
|
|
|
|
|
|
|
class Item < Sequel::Model
|
|
|
|
many_to_one :pool
|
|
|
|
one_to_many :ratings
|
|
|
|
end
|
|
|
|
|
|
|
|
class Axis < Sequel::Model(DB[:axes])
|
|
|
|
many_to_one :pool
|
|
|
|
one_to_many :ratings
|
|
|
|
end
|
|
|
|
|
|
|
|
class Rating < Sequel::Model
|
|
|
|
many_to_one :item
|
|
|
|
many_to_one :axis
|
|
|
|
|
|
|
|
extend Forwardable
|
|
|
|
def_delegators :openskill, :ordinal, :with
|
|
|
|
|
|
|
|
def openskill
|
|
|
|
OpenSkill::Rating.new(mu: self.mu, sigma: self.sigma)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Ranking < Sequel::Model
|
|
|
|
many_to_one :axis
|
|
|
|
many_to_one :winner, class: "RankKing::Item"
|
|
|
|
many_to_one :loser, class: "RankKing::Item"
|
|
|
|
end
|
|
|
|
end
|