require "#{__dir__}/../setup"
scope = Swars::Membership.where(id: Swars::Membership.last(1000).collect(&:id))
base = QuickScript::Swars::RuleWiseWinRateScript.new(scope: scope)
base.cache_write
s { base.sprintha_gotegatuyoi_noka.aggregate_now }
pp base.sprintha_gotegatuyoi_noka.aggregate_now
tp base.sprintha_gotegatuyoi_noka.call
# >> 2025-04-07T12:49:03.705Z pid=50366 tid=14nq INFO: Sidekiq 7.3.9 connecting to Redis with options {size: 10, pool_name: "internal", url: "redis://localhost:6379/4"}
# >>   Judge Load (0.2ms)  SELECT `judges`.* FROM `judges` WHERE `judges`.`key` = 'win' ORDER BY `judges`.`position` ASC LIMIT 1 /*application='ShogiWeb'*/
# >>   ↳ app/models/application_memory_record.rb:36:in 'ApplicationMemoryRecord#db_record!'
# >>   Swars::Xmode Load (0.2ms)  SELECT `swars_xmodes`.* FROM `swars_xmodes` WHERE `swars_xmodes`.`key` = '野良' ORDER BY `swars_xmodes`.`position` ASC LIMIT 1 /*application='ShogiWeb'*/
# >>   ↳ app/models/application_memory_record.rb:36:in 'ApplicationMemoryRecord#db_record!'
# >>   Swars::Xmode Load (0.2ms)  SELECT `swars_xmodes`.* FROM `swars_xmodes` WHERE `swars_xmodes`.`key` = '大会' ORDER BY `swars_xmodes`.`position` ASC LIMIT 1 /*application='ShogiWeb'*/
# >>   ↳ app/models/application_memory_record.rb:36:in 'ApplicationMemoryRecord#db_record!'
# >>   Swars::Membership Count (16.1ms)  SELECT COUNT(*) AS `count_all`, `swars_imodes`.`key` AS `swars_imodes_key`, `swars_rules`.`key` AS `swars_rules_key`, `locations`.`key` AS `locations_key`, `judges`.`key` AS `judges_key` FROM `swars_memberships` INNER JOIN `swars_battles` ON `swars_battles`.`id` = `swars_memberships`.`battle_id` INNER JOIN `swars_imodes` ON `swars_imodes`.`id` = `swars_battles`.`imode_id` INNER JOIN `swars_xmodes` ON `swars_xmodes`.`id` = `swars_battles`.`xmode_id` INNER JOIN `swars_rules` ON `swars_rules`.`id` = `swars_battles`.`rule_id` INNER JOIN `locations` ON `locations`.`id` = `swars_memberships`.`location_id` INNER JOIN `judges` ON `judges`.`id` = `swars_memberships`.`judge_id` WHERE `swars_memberships`.`id` IN (118845799, 118845800, 118845801, 118845802, 118845803, 118845804, 118845805, 118845806, 118845807, 118845808, 118845809, 118845810, 118845811, 118845812, 118845813, 118845814, 118845815, 118845816, 118845817, 118845818, 118845819, 118845820, 118845821, 118845822, 118845823, 118845824, 118845825, 118845826, 118845827, 118845828, 118845829, 118845830, 118845831, 118845832, 118845833, 118845834, 118845835, 118845836, 118845837, 118845838, 118845839, 118845840, 118845841, 118845842, 118845843, 118845844, 118845845, 118845846, 118845847, 118845848, 118845849, 118845850, 118845851, 118845852, 118845853, 118845854, 118845855, 118845856, 118845857, 118845858, 118845859, 118845861, 118845862, 118845863, 118845864, 118845865, 118845866, 118845867, 118845868, 118845869, 118845870, 118845871, 118845872, 118845873, 118845874, 118845875, 118845876, 118845877, 118845878, 118845879, 118845880, 118845881, 118845882, 118845883, 118845884, 118845885, 118845886, 118845887, 118845888, 118845889, 118845890, 118845891, 118845892, 118845893, 118845894, 118845895, 118845896, 118845897, 118845898, 118845899, 118845900, 118845901, 118845902, 118845903, 118845904, 118845905, 118845906, 118845907, 118845908, 118845909, 118845910, 118845911, 118845912, 118845913, 118845914, 118845915, 118845916, 118845917, 118845918, 118845919, 118845920, 118845921, 118845922, 118845923, 118845924, 118845925, 118845926, 118845927, 118845928, 118845930, 118845931, 118845932, 118845933, 118845934, 118845935, 118845936, 118845937, 118845938, 118845939, 118845940, 118845941, 118845942, 118845943, 118845944, 118845945, 118845946, 118845947, 118845948, 118845949, 118845950, 118845951, 118845952, 118845953, 118845954, 118845955, 118845956, 118845957, 118845958, 118845959, 118845960, 118845961, 118845962, 118845963, 118845964, 118845965, 118845966, 118845967, 118845968, 118845969, 118845970, 118845971, 118845972, 118845973, 118845974, 118845975, 118845977, 118845978, 118845979, 118845980, 118845981, 118845982, 118845983, 118845984, 118845985, 118845986, 118845987, 118845988, 118845989, 118845990, 118845991, 118845992, 118845993, 118845994, 118845995, 118845996, 118845997, 118845998, 118845999, 118846000, 118846001, 118846002, 118846003, 118846004, 118846005, 118846006, 118846007, 118846008, 118846009, 118846010, 118846011, 118846012, 118846013, 118846014, 118846015, 118846016, 118846017, 118846018, 118846019, 118846020, 118846021, 118846022, 118846023, 118846024, 118846025, 118846026, 118846027, 118846028, 118846029, 118846030, 118846031, 118846032, 118846033, 118846034, 118846035, 118846036, 118846037, 118846038, 118846039, 118846040, 118846041, 118846042, 118846043, 118846044, 118846045, 118846046, 118846047, 118846048, 118846049, 118846050, 118846051, 118846052, 118846053, 118846054, 118846055, 118846056, 118846057, 118846058, 118846059, 118846060, 118846061, 118846062, 118846063, 118846064, 118846065, 118846066, 118846067, 118846068, 118846069, 118846070, 118846071, 118846072, 118846073, 118846074, 118846075, 118846076, 118846077, 118846078, 118846079, 118846080, 118846081, 118846082, 118846083, 118846084, 118846085, 118846086, 118846087, 118846088, 118846089, 118846090, 118846091, 118846092, 118846093, 118846094, 118846095, 118846096, 118846097, 118846098, 118846099, 118846100, 118846101, 118846102, 118846103, 118846104, 118846105, 118846106, 118846107, 118846108, 118846109, 118846110, 118846111, 118846112, 118846113, 118846114, 118846115, 118846116, 118846117, 118846118, 118846119, 118846120, 118846121, 118846122, 118846123, 118846124, 118846125, 118846126, 118846127, 118846128, 118846129, 118846130, 118846131, 118846132, 118846133, 118846134, 118846135, 118846136, 118846137, 118846138, 118846139, 118846140, 118846141, 118846142, 118846143, 118846144, 118846145, 118846146, 118846147, 118846148, 118846149, 118846150, 118846151, 118846152, 118846153, 118846154, 118846155, 118846156, 118846157, 118846158, 118846159, 118846160, 118846161, 118846162, 118846163, 118846164, 118846165, 118846166, 118846167, 118846168, 118846169, 118846170, 118846171, 118846172, 118846173, 118846174, 118846175, 118846176, 118846177, 118846178, 118846179, 118846180, 118846181, 118846182, 118846183, 118846184, 118846185, 118846186, 118846187, 118846188, 118846189, 118846190, 118846191, 118846192, 118846193, 118846194, 118846195, 118846196, 118846197, 118846198, 118846199, 118846200, 118846201, 118846202, 118846203, 118846204, 118846205, 118846206, 118846207, 118846208, 118846209, 118846210, 118846211, 118846212, 118846213, 118846214, 118846215, 118846216, 118846217, 118846218, 118846219, 118846220, 118846221, 118846222, 118846223, 118846224, 118846225, 118846226, 118846227, 118846228, 118846229, 118846230, 118846231, 118846232, 118846233, 118846234, 118846235, 118846236, 118846237, 118846238, 118846239, 118846240, 118846241, 118846242, 118846243, 118846244, 118846246, 118846247, 118846248, 118846249, 118846250, 118846251, 118846253, 118846254, 118846255, 118846256, 118846257, 118846258, 118846261, 118846262, 118846263, 118846264, 118846265, 118846266, 118846268, 118846269, 118846270, 118846271, 118846272, 118846273, 118846274, 118846275, 118846276, 118846277, 118846279, 118846280, 118846281, 118846282, 118846283, 118846284, 118846285, 118846286, 118846287, 118846288, 118846289, 118846290, 118846291, 118846292, 118846293, 118846294, 118846295, 118846296, 118846297, 118846298, 118846299, 118846300, 118846301, 118846302, 118846303, 118846304, 118846305, 118846306, 118846307, 118846308, 118846309, 118846310, 118846311, 118846312, 118846313, 118846314, 118846315, 118846316, 118846317, 118846318, 118846319, 118846320, 118846321, 118846322, 118846323, 118846324, 118846325, 118846326, 118846328, 118846329, 118846330, 118846331, 118846332, 118846333, 118846334, 118846335, 118846336, 118846337, 118846338, 118846339, 118846340, 118846341, 118846342, 118846343, 118846344, 118846345, 118846346, 118846347, 118846348, 118846349, 118846350, 118846351, 118846352, 118846353, 118846354, 118846355, 118846356, 118846357, 118846358, 118846359, 118846360, 118846361, 118846362, 118846363, 118846364, 118846365, 118846366, 118846367, 118846368, 118846369, 118846370, 118846371, 118846372, 118846373, 118846374, 118846375, 118846376, 118846377, 118846378, 118846379, 118846380, 118846381, 118846382, 118846383, 118846384, 118846385, 118846387, 118846388, 118846389, 118846390, 118846391, 118846392, 118846393, 118846394, 118846395, 118846396, 118846397, 118846398, 118846399, 118846400, 118846402, 118846403, 118846404, 118846405, 118846406, 118846407, 118846408, 118846409, 118846412, 118846413, 118846414, 118846415, 118846417, 118846418, 118846419, 118846420, 118846421, 118846422, 118846423, 118846424, 118846425, 118846426, 118846427, 118846428, 118846429, 118846430, 118846431, 118846432, 118846433, 118846434, 118846435, 118846436, 118846437, 118846438, 118846439, 118846440, 118846441, 118846442, 118846443, 118846444, 118846445, 118846446, 118846447, 118846448, 118846449, 118846450, 118846452, 118846453, 118846454, 118846455, 118846456, 118846457, 118846458, 118846460, 118846462, 118846463, 118846464, 118846465, 118846466, 118846467, 118846468, 118846469, 118846470, 118846471, 118846472, 118846473, 118846474, 118846475, 118846476, 118846477, 118846478, 118846479, 118846480, 118846481, 118846482, 118846483, 118846484, 118846485, 118846486, 118846487, 118846488, 118846489, 118846491, 118846492, 118846493, 118846494, 118846495, 118846496, 118846497, 118846498, 118846499, 118846500, 118846501, 118846502, 118846503, 118846504, 118846505, 118846506, 118846507, 118846508, 118846509, 118846510, 118846511, 118846512, 118846513, 118846514, 118846515, 118846516, 118846517, 118846518, 118846519, 118846520, 118846521, 118846522, 118846524, 118846525, 118846526, 118846527, 118846528, 118846529, 118846530, 118846531, 118846532, 118846533, 118846534, 118846535, 118846536, 118846537, 118846538, 118846539, 118846540, 118846541, 118846542, 118846543, 118846544, 118846545, 118846546, 118846547, 118846548, 118846549, 118846550, 118846551, 118846552, 118846553, 118846554, 118846555, 118846556, 118846557, 118846558, 118846559, 118846560, 118846561, 118846562, 118846563, 118846564, 118846565, 118846566, 118846567, 118846568, 118846569, 118846570, 118846571, 118846572, 118846573, 118846574, 118846575, 118846576, 118846577, 118846578, 118846579, 118846580, 118846581, 118846582, 118846583, 118846584, 118846585, 118846586, 118846587, 118846588, 118846589, 118846591, 118846592, 118846593, 118846594, 118846595, 118846596, 118846597, 118846598, 118846599, 118846600, 118846601, 118846602, 118846603, 118846604, 118846605, 118846606, 118846607, 118846608, 118846609, 118846610, 118846611, 118846612, 118846613, 118846614, 118846615, 118846616, 118846617, 118846618, 118846619, 118846620, 118846621, 118846622, 118846623, 118846624, 118846625, 118846626, 118846627, 118846628, 118846629, 118846630, 118846632, 118846633, 118846634, 118846635, 118846636, 118846637, 118846638, 118846639, 118846640, 118846641, 118846642, 118846643, 118846644, 118846645, 118846646, 118846647, 118846648, 118846649, 118846650, 118846651, 118846652, 118846653, 118846654, 118846655, 118846656, 118846657, 118846658, 118846659, 118846660, 118846661, 118846662, 118846663, 118846664, 118846666, 118846667, 118846668, 118846669, 118846671, 118846672, 118846673, 118846674, 118846675, 118846676, 118846677, 118846678, 118846679, 118846680, 118846681, 118846682, 118846683, 118846684, 118846685, 118846686, 118846687, 118846688, 118846689, 118846690, 118846691, 118846692, 118846693, 118846694, 118846695, 118846696, 118846697, 118846699, 118846700, 118846701, 118846702, 118846703, 118846704, 118846705, 118846706, 118846707, 118846708, 118846709, 118846710, 118846711, 118846712, 118846713, 118846714, 118846715, 118846716, 118846717, 118846718, 118846719, 118846720, 118846721, 118846722, 118846723, 118846724, 118846725, 118846726, 118846727, 118846728, 118846729, 118846730, 118846731, 118846732, 118846733, 118846734, 118846735, 118846736, 118846737, 118846738, 118846739, 118846740, 118846741, 118846742, 118846743, 118846744, 118846745, 118846746, 118846747, 118846748, 118846749, 118846750, 118846751, 118846752, 118846753, 118846754, 118846755, 118846756, 118846757, 118846758, 118846759, 118846760, 118846761, 118846762, 118846763, 118846764, 118846765, 118846766, 118846767, 118846768, 118846769, 118846770, 118846771, 118846772, 118846773, 118846774, 118846775, 118846883, 118846884, 118846885, 118846886, 118846887, 118846888, 118846889, 118846890, 118846891, 118846892, 118846893, 118846894, 118846895, 118846896, 118846897, 118846898, 118846899, 118846900, 118846901, 118846902, 118846903, 118846904, 118846905, 118846906, 118846907, 118846908, 118846909, 118846910, 118846911, 118846912, 118846913, 118846914, 118846915, 118846916, 118846917, 118846918, 118846919, 118846920, 118846921, 118846922, 118846923, 118846924, 118846925, 118846926, 118846927, 118846928, 118846929, 118846930) AND `swars_memberships`.`judge_id` = 1 AND `swars_battles`.`xmode_id` IN (1, 4) GROUP BY `swars_imodes`.`key`, `swars_rules`.`key`, `locations`.`key`, `judges`.`key` /*application='ShogiWeb'*/
# >>   ↳ app/models/quick_script/swars/rule_wise_win_rate_script/sprintha_gotegatuyoi_noka.rb:86:in 'QuickScript::Swars::RuleWiseWinRateScript::SprinthaGotegatuyoiNoka#aggregate_now'
# >> {"normal/ten_min/black/win": 131,
# >>  "normal/ten_min/white/win": 126,
# >>  "normal/ten_sec/black/win": 22,
# >>  "normal/ten_sec/white/win": 21,
# >>  "normal/three_min/black/win": 58,
# >>  "normal/three_min/white/win": 41,
# >>  "sprint/three_min/white/win": 44,
# >>  "sprint/three_min/black/win": 40}
# >> |-----------------+----------+----------+--------+--------+------|
# >> | 種類            | ▲勝率   | △勝率   | ▲勝数 | △勝数 | 分母 |
# >> |-----------------+----------+----------+--------+--------+------|
# >> | 通常 野良 10分  | 50.973 % | 49.027 % |    131 |    126 |  257 |
# >> | 通常 野良 3分   | 58.586 % | 41.414 % |     58 |     41 |   99 |
# >> | 通常 野良 10秒  | 51.163 % | 48.837 % |     22 |     21 |   43 |
# >> | ｽﾌﾟﾘﾝﾄ 野良 3分 | 47.619 % | 52.381 % |     40 |     44 |   84 |
# >> |-----------------+----------+----------+--------+--------+------|
