def process_members(config, clan, warlog, current_war, member_history, war_readiness_map={}): """ Process member list, adding calculated meta-data for rendering of status in the clan member table. """ # calculate the number of days since the donation last sunday, for # donation tracking purposes: days_from_donation_reset = config['crtools']['timestamp'].isoweekday() if days_from_donation_reset > 7 or days_from_donation_reset <= 0: days_from_donation_reset = 1 # process members with results from the API factory = MemberFactory(config=config, clan=clan, current_war=current_war, warlog=warlog, member_history=member_history, days_from_donation_reset=days_from_donation_reset) members_processed = [] for member_src in clan.member_list: war_readiness = war_readiness_map.get(member_src.tag) members_processed.append( factory.get_processed_member(member_src, war_readiness)) return members_processed
def test_get_suggestions_nosuggestions(tmpdir): config_file = tmpdir.mkdir('test_get_suggestions').join('testfile') config_file.write( __config_file_score__ + '\nthreshold_demote=-999999\nthreshold_promote=9999999\nmin_clan_size={}' .format(crtools.MAX_CLAN_SIZE)) config = load_config_file(config_file.realpath()) war = ProcessedCurrentWar( config=config, current_war=pyroyale.WarCurrent(state='notInWar')) factory = MemberFactory(config=config, member_history=history.get_member_history( __fake_clan__.member_list, config['crtools']['timestamp'], '{}', war), current_war=war, clan=__fake_clan__, warlog=pyroyale.WarLog(items=[])) members = [] for i in range(0, crtools.MAX_CLAN_SIZE): member = factory.get_processed_member( pyroyale.ClanMember(tag="#AAAAAA", name="LeaderPerson", role="leader", exp_level=13, trophies=9999, donations=9999, arena=pyroyale.Arena(id=54000012, name='Legendary Arena'), last_seen="20190802T154619.000Z")) member.safe = True members.append(member) suggestions = crtools.get_suggestions(config, members, __fake_clan__.required_trophies) assert len(suggestions) == 1 assert suggestions[-1] == config['strings']['suggestionNone']
def process_members(config, clan, warlog, current_war, member_history): """ Process member list, adding calculated meta-data for rendering of status in the clan member table. """ # calculate the number of days since the donation last sunday, for # donation tracking purposes: now = datetime.utcnow() days_from_donation_reset = now.isoweekday() if days_from_donation_reset > 7 or days_from_donation_reset <= 0: days_from_donation_reset = 1 # process members with results from the API factory = MemberFactory(config=config, clan=clan, current_war=current_war, warlog=warlog, member_history=member_history, days_from_donation_reset=days_from_donation_reset, now=now) members_processed = [] for member_src in clan.member_list: members_processed.append(factory.get_processed_member(member_src)) return members_processed