From 8bfd17db38b5148748db5f6b5fe6258d027a7f20 Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Fri, 23 Jun 2023 19:39:58 -0700 Subject: [PATCH] mu --- lib/rank_king/models.rb | 4 ++-- lib/web.rb | 28 ++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/lib/rank_king/models.rb b/lib/rank_king/models.rb index c706bfb..e882c62 100644 --- a/lib/rank_king/models.rb +++ b/lib/rank_king/models.rb @@ -35,7 +35,7 @@ module RankKing class Ranking < Sequel::Model many_to_one :axis - many_to_one :winner, class: :Item - many_to_one :loser, class: :Item + many_to_one :winner, class: "RankKing::Item" + many_to_one :loser, class: "RankKing::Item" end end diff --git a/lib/web.rb b/lib/web.rb index 499085b..e200823 100644 --- a/lib/web.rb +++ b/lib/web.rb @@ -55,6 +55,18 @@ module RankKing <% end %> + +
+ <% @game.each.with_index do |item, i| %> + + + <% end %> + +
ERB route do |r| @@ -76,10 +88,22 @@ module RankKing end r.on "axes" do - r.is Integer do |id| + r.on Integer do |id| @axis = Axis[id] - view :axis + r.is "rank" do + items = r.params.values_at("item_0", "item_1").map { Item[_1] } + winner, loser = items.partition { _1.id == r.params.fetch("winner").to_i }.flatten + RankKing.rank(@axis, winner:, loser:) + + r.redirect "/pools/#{@pool.id}/axes/#{@axis.id}" + end + + r.is do + @game = RankKing.suggest_game(@axis).shuffle + + view :axis + end end end end