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.
42 lines
772 B
42 lines
772 B
1 year ago
|
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: :Item
|
||
|
many_to_one :loser, class: :Item
|
||
|
end
|
||
|
end
|