require "./setup"
_ { Swars::User["SugarHuuko"].stat.vs_stat.to_chart } # => "214.09 ms"
s { Swars::User["SugarHuuko"].stat.vs_stat.to_chart } # => [{:grade_name=>"九段", :judge_counts=>{:lose=>2, :win=>2}, :appear_ratio=>0.08}, {:grade_name=>"八段", :judge_counts=>{:win=>2, :lose=>6}, :appear_ratio=>0.16}, {:grade_name=>"七段", :judge_counts=>{:win=>10, :lose=>2}, :appear_ratio=>0.24}, {:grade_name=>"六段", :judge_counts=>{:win=>9, :lose=>4}, :appear_ratio=>0.26}, {:grade_name=>"五段", :judge_counts=>{:win=>9, :lose=>1}, :appear_ratio=>0.2}, {:grade_name=>"三段", :judge_counts=>{:win=>2}, :appear_ratio=>0.04}, {:grade_name=>"二段", :judge_counts=>{:win=>1}, :appear_ratio=>0.02}]
tp Swars::User["SugarHuuko"].stat.vs_stat.to_chart

# >>   Swars::User Load (0.2ms)  SELECT `swars_users`.* FROM `swars_users` WHERE `swars_users`.`user_key` = 'SugarHuuko' LIMIT 1
# >>   ↳ app/models/swars/user.rb:9:in `[]'
# >>   Swars::Membership Ids (18.0ms)  SELECT `swars_memberships`.`id` FROM `swars_memberships` INNER JOIN `swars_battles` ON `swars_battles`.`id` = `swars_memberships`.`battle_id` WHERE `swars_memberships`.`op_user_id` = 17413 ORDER BY `swars_battles`.`battled_at` DESC LIMIT 50
# >>   ↳ app/models/swars/user/stat/scope_ext.rb:52:in `scope_ids'
# >>   Swars::Membership Count (0.4ms)  SELECT COUNT(*) AS `count_all`, `swars_grades`.`key` AS `swars_grades_key`, `judges`.`key` AS `judges_key` FROM `swars_memberships` INNER JOIN `swars_grades` ON `swars_grades`.`id` = `swars_memberships`.`grade_id` INNER JOIN `judges` ON `judges`.`id` = `swars_memberships`.`judge_id` WHERE `swars_memberships`.`id` IN (99322338, 99322340, 99322342, 99322344, 99049424, 99030315, 99030317, 99030320, 99030329, 99030333, 99030337, 98973485, 98973486, 98973488, 98973490, 98973492, 98973494, 98972126, 98972128, 98972129, 98972131, 98972133, 98972135, 98971213, 98969680, 98969682, 98969686, 98969690, 98969693, 98969699, 98969702, 98969705, 98969708, 98972151, 98966475, 98973060, 98964727, 98964729, 98964732, 98964734, 98964735, 98963462, 98963321, 98963323, 98962471, 98963325, 98963328, 98963334, 98962120, 98963338) GROUP BY `swars_grades`.`key`, `judges`.`key` ORDER BY `swars_grades`.`priority` ASC
# >>   ↳ app/models/swars/user/stat/vs_stat.rb:17:in `to_chart'
# >>   Swars::Membership Count (0.3ms)  SELECT COUNT(*) FROM `swars_memberships` WHERE `swars_memberships`.`id` IN (99322338, 99322340, 99322342, 99322344, 99049424, 99030315, 99030317, 99030320, 99030329, 99030333, 99030337, 98973485, 98973486, 98973488, 98973490, 98973492, 98973494, 98972126, 98972128, 98972129, 98972131, 98972133, 98972135, 98971213, 98969680, 98969682, 98969686, 98969690, 98969693, 98969699, 98969702, 98969705, 98969708, 98972151, 98966475, 98973060, 98964727, 98964729, 98964732, 98964734, 98964735, 98963462, 98963321, 98963323, 98962471, 98963325, 98963328, 98963334, 98962120, 98963338)
# >>   ↳ app/models/swars/user/stat/scope_ext.rb:62:in `ids_count'
