scottwillson/racing_on_rails

View on GitHub
app/models/calculations/v3/steps/select_members.rb

Summary

Maintainability
A
25 mins
Test Coverage
# frozen_string_literal: true

module Calculations
  module V3
    module Steps
      module SelectMembers
        TEAMS_2021 = [26594, 34306, 41938, 1885, 8244, 15384, 1812, 41795, 5407, 42694, 7701, 39195, 34940, 9956, 5615, 34881, 32, 1010, 25746, 1236, 11, 22, 29000, 27329, 30099, 35242, 13701, 38755, 43222, 43271, 43270, 41843, 39809, 25877, 43273, 5179, 42594, 40561, 41965, 40496, 42700, 40967, 19914, 12702, 3065, 43265, 13624, 43613, 43214, 30638, 43682, 37529, 39210, 10763, 43217, 37513, 10626, 42982, 26020, 36982, 40532, 33251, 29299, 40425, 40757, 33955, 43269, 43263, 41832, 10, 44009, 42285, 1182, 6526, 30049, 41680, 41985, 39659, 43043, 40948, 38750, 31037, 2308, 42399, 35258, 2714, 450, 341, 43596, 186, 18146, 32236, 44056, 43557, 7900, 1988, 40222, 8858, 428, 42246, 43671, 43592, 43593, 43594, 33561, 152, 43246, 42255, 33678, 2356, 42428, 37605, 40461, 7834, 6580, 39424, 94, 7750, 91, 40878, 7372, 29933, 41810, 42979, 14321, 37544, 43571, 43572, 43573, 43574, 76, 40137, 32764, 6834, 12692, 40872, 41800, 40710, 42253, 5777, 39417, 986, 43579, 1149, 43581, 41809, 38571, 35423, 37597, 41142, 34729, 37536, 2938, 9, 22435, 27837, 10668, 7645, 43597, 43216, 8279, 37143, 973, 42491, 49, 37537, 40688, 37183, 34828, 30588, 43223, 43589, 35413, 32733, 43262, 5064, 32805, 43245, 22396, 43534, 29160, 42853, 43210, 25087, 21194, 40759, 2042, 39354, 35635, 43241, 43828, 43587, 37518, 34039, 37647, 3957, 34032, 12911, 43561, 43562, 43563, 42017, 33068, 43565, 38804, 29359, 32509, 33293, 24796, 42223, 43531, 43532, 43533, 43535, 41834, 43536, 43537, 43538, 33427, 43539, 43540, 43541, 40781, 42277, 43542, 43543, 4475, 43544, 43545, 43546, 43547, 43548, 43549, 37547, 43550, 43551, 43552, 43553, 43554, 43555, 38609, 5483, 10201, 36863, 43556, 43558, 43559, 43560, 43564, 22274, 43566, 43567, 43568, 40581, 43569, 43570, 4061, 3664, 37236, 43575, 43576, 41925, 43577, 25355, 741, 33533, 37920, 43578, 37564, 43580, 33939, 4676, 39116, 43582, 43583, 1534, 43584, 43585, 15621, 41369, 43586, 43588, 41529, 43590, 43591, 40606, 43595, 43598, 43599, 43600, 43601, 43602, 43603, 29319, 43604, 43610, 43611, 43612, 40010, 43614, 43615, 43233, 40634, 43616, 41066, 43617, 43618, 43619, 33550, 43639, 43075, 37910, 43621, 43622, 40365, 43623, 42378, 43624, 43625, 43249, 39993, 6652, 43626, 38001, 30278, 43627, 19, 43628, 43022, 33712, 52, 43640, 43606, 43641, 43642, 43643, 43644, 43645, 15293, 43646, 43647, 39503, 43638, 43651, 43652, 43653, 43654, 43655, 43656, 43657, 43609, 43658, 43659, 43660, 43661, 10221, 43662, 43663, 43664, 43665, 43666, 6719, 43667, 43668, 43669, 43670, 42276, 35826, 42073, 43672, 32844, 43673, 28293, 43674, 43675, 43676, 34447, 33521, 43277, 42485, 41848, 43278, 34932, 43240, 42827, 43070, 41797, 37445, 39259, 42772, 42864, 40127, 30425, 42980, 38248, 42384, 43678, 43917, 36279, 43225, 40417, 42440, 33620, 40353, 43266, 35098, 939, 10427, 43697, 8272, 6892, 43738, 35633, 9878, 963, 222, 5581, 37187, 29369, 24808, 85, 5162, 42637, 39213, 36260, 43707, 40386, 43693, 26596, 43730, 5302, 40392, 42872, 42631, 43728, 4520, 26182, 43608, 29541, 795, 353, 43234, 43915, 26485, 1888, 40039, 43803, 39874, 35747, 41197, 39572, 42709, 22419, 37918, 25482, 38730, 43228, 42901, 41940, 40965, 43257, 43722, 41813, 24150, 6998, 43698, 43700, 43729, 43702, 43703, 43731, 41091, 43706, 40490, 43732, 43733, 43734, 41829, 43711, 43712, 43735, 42869, 43736, 43748, 43715, 43716, 43739, 43740, 42736, 35769, 42142, 39519, 43720, 43741, 5077, 43688, 43752, 33162, 43753, 43754, 43755, 43756, 32523, 42875, 43757, 39872, 35437, 36641, 3519, 40714, 33139, 5035, 40558, 40, 41008, 43829, 41047, 40647, 43793, 43794, 37083, 12752, 40761, 43795, 29, 43796, 43797, 39497, 43798, 43799, 43800, 43801, 42075, 43802, 43804, 43805, 43806, 42394, 40776, 43807, 43808, 43809, 43810, 43811, 43812, 39712, 43813, 41971, 43814, 38256, 43815, 42213, 33541, 7953, 43816, 23223, 43817, 43818, 42408, 4726, 43819, 43820, 43821, 43822, 43823, 43824, 30772, 43825, 42010, 19774, 43826, 1019, 43279, 3, 35430, 15041, 20739, 35977, 34059, 37474, 33615, 40162, 42503, 35891, 39481, 44047, 29070, 38368, 40976, 38903, 43260, 4955, 43061, 1113, 35385, 43751, 43224, 42688, 3001, 43758, 38374, 40486, 43220, 43727, 29918, 1030, 19207, 41286, 35729, 22950, 21937, 7948, 572, 26610, 40677, 40731, 42691, 43243, 953, 42090, 43726, 40996, 43681, 43187, 43839, 43840, 43841, 43842, 43843, 43844, 43845, 2708, 43846, 43847, 10532, 43848, 43849, 43850, 2303, 13135, 42873, 43851, 43852, 43853, 3314, 29868, 39228, 43854, 7805, 26229, 25342, 3904, 11102, 35296, 40758, 40559, 43219, 22519, 272, 142, 22210, 40251, 3663, 43677, 29272, 43858, 43838, 43837, 38999, 43855, 43065, 897, 41765, 40424, 28, 43866, 40020, 43864, 6005, 40794, 33560, 29013, 43867, 1913, 43650, 43835, 40755, 25526, 30248, 3846, 43836, 9501, 6710, 39985, 42548, 25485, 32529, 43749, 42040, 42615, 39635, 39356, 3584, 41812, 4162, 42561, 42524, 43679, 34865, 44028, 30162, 42696, 43649, 40426, 40685, 39574, 23070, 40583, 43686, 40844, 33944, 379, 40730, 34418, 41996, 42530, 43893, 41774, 42380, 43908, 42094, 43909, 43910, 43911, 43912, 3408, 43913, 43914, 40161, 40748, 26460, 39509, 43891, 43064, 40845, 42494, 33544, 41982, 41811, 24761, 40971, 12363, 43012, 37128, 40172, 40375, 40963, 2849, 35606, 43921, 41562, 43916, 42104, 35370, 30357, 42412, 31012, 43920, 38756, 308, 29124, 39211, 41974, 43827, 43957, 41280, 34326, 2872, 40090, 37319, 12039, 13741, 41833, 40756, 9489, 41941, 32725, 36838, 40409, 43865, 19264, 43834, 30416, 2858, 43954, 40822, 2535, 43955, 43956, 41215, 43919, 17225, 29434, 29255, 6338, 42297, 41054, 43962, 43966, 37846, 40534, 43967, 43968, 43969, 43970, 43971, 43254, 43972, 26600, 40972, 43973, 22428, 43683, 42371, 43684, 37858, 10726, 42788, 43963, 40879, 43004, 2358, 10227, 36762, 29381, 38542, 26488, 9201, 30128, 26667, 35834, 2027, 17401, 9572, 39550, 42196, 36769, 7607, 1999, 40495, 43685, 43975, 120, 15331, 42708, 32502, 42759, 6322, 32505, 1738, 32515, 40585, 5646, 43976, 37939, 43974, 43977, 43978, 34406, 38977, 29345, 42200, 6977, 37344, 21823, 38524, 38553, 33698, 32533, 10967, 37533, 36652, 884, 43979, 43980, 38862, 42904, 712, 38852, 24805, 36635, 41187, 36645, 36851, 38165, 36985, 17237, 35669, 43258, 40040, 37336, 36636, 5136, 40806, 26486, 44000, 5747, 25756, 17327, 43208, 41120, 43994, 41828, 805, 41981, 599, 44005, 43996, 42, 43918, 43960, 43993, 43995, 43959, 35023, 6906, 44006, 44007, 44008, 43997, 43998, 5107, 43191, 43999, 44001, 44002, 44004, 42930, 43830, 42779, 43831, 43832, 44035, 44036, 8128, 40362, 42210, 980, 44037, 42442, 44026, 44027, 29547, 44029, 37211, 44030, 44031, 44032, 44033, 44034, 3839, 43964, 34941, 38691, 36116, 39937, 38018, 43021, 29543, 3368, 435, 44045, 39704, 44049, 42078, 44050, 25777, 40742, 44054, 44087, 39681, 30375, 43000, 39234, 4239, 26692, 43172, 44053, 42247, 37196, 41990, 41937, 2891, 39478, 44110, 42504, 35968, 22012, 44038, 35744, 44078, 44079, 44080, 44058, 44059, 32821, 44055, 44081, 35619, 44077, 44072, 44073, 44074, 44075, 44076, 36209, 27, 39237, 44082, 35321, 127, 44085, 44086, 7026, 39223, 486, 24651, 44083, 41261, 42619, 4527, 43236, 42091, 43015, 40791, 44103, 38640, 7049, 43192, 43856, 27430, 43857, 43859, 43860, 43861, 43862, 43863, 44090, 44088, 6373, 35719, 44091, 38694, 44097, 29770, 37415, 6770, 40864, 36326, 39329, 44092, 38463, 18747, 5129, 39560, 5284, 43179, 2902, 44101, 44102, 37887, 33524, 41994, 37327, 40649, 41313, 37463, 44107, 27341, 30718, 37282, 44100, 44096, 44116, 44117, 44118, 5004, 44104, 44105, 44106, 39154, 44112, 44114, 44115, 39221, 40743, 40981, 28842, 40343, 44127, 44093, 44094, 44095, 6204, 37587, 44098, 33718, 44099, 33476, 27591, 44125, 44126, 43958, 42047, 38747, 44131, 43024, 37279, 43193, 12219, 44129, 3086, 19549, 44130, 21413, 3251, 10974, 41198, 44121, 44132, 35315, 17222, 163, 4292, 44133, 44134, 44135, 44136, 38495, 44137, 44138, 44139, 44140, 19862]

        def self.calculate!(calculator)
          if calculator.rules.members_only?
            calculator.unrejected_results.each do |result|
              if calculator.year == 2021
                result.participant.id.in?(TEAMS_2021)
              else
                unless result.participant.member?(calculator.year)
                  result.reject :members_only
                end
              end
            end
          end

          calculator.event_categories
        end
      end
    end
  end
end