def handle(self, *args, **options): heroes = get_json('/heroes/all') bulk = [] for hero in heroes: bulk.append(Heroes( hero_id=heroes[hero]['hero_id'], disp_name=heroes[hero]['disp_name'], description=heroes[hero]['description'], primaryattribute=heroes[hero]['primaryattribute'], attacktype=heroes[hero]['attacktype'], team=heroes[hero]['team'] )) Heroes.objects.all().delete() Heroes.objects.bulk_create(bulk) self.stdout.write("success")
def handle(self, *args, **options): heroes = get_json('/heroes/usage') today = (date.today()+timedelta(days=1)).strftime("%Y-%m-%d") bulk = [] del heroes['total'] del heroes['0'] print json.dumps(heroes) order = sorted(heroes, key=lambda key: heroes[key]) for index, hero in enumerate(order[::-1]): bulk.append(HeroUse( date=today, hero_id=hero, popularity=index+1, usage=heroes[hero] )) HeroUse.objects.bulk_create(bulk) self.stdout.write("success")
def handle(self, *args, **options): players = PlayerStats.objects.raw("""SELECT DISTINCT B.`player_id` FROM honbot_playerstats A RIGHT JOIN honbot_playermatches B ON A.`player_id` = B.`player_id` WHERE A.`player_id` is NULL""") count = 0 for player in players: sleep(.1) data = get_json('/player_statistics/ranked/accountid/' + str(player.player_id)) if data is not None: data = player_math(data, 'rnk') player_save(data, 'rnk') update_player_count() count += 1 if count == 100: break self.stdout.write("success on " + str(count))
def handle(self, *args, **options): today = date.today().strftime("%Y-%m-%d") print today print HeroUse.objects.filter(date=today).count() if HeroUse.objects.filter(date=today).count() < 1: heroes = get_json('/heroes/usage') bulk = [] if heroes['0']: del heroes['0'] del heroes['total'] print json.dumps(heroes) order = sorted(heroes, key=lambda key: heroes[key]) for index, hero in enumerate(order[::-1]): bulk.append(HeroUse( date=today, hero_id=hero, popularity=index+1, usage=heroes[hero] )) HeroUse.objects.bulk_create(bulk) self.stdout.write("success") else: self.stdout.write("success")
def handle(self, *args, **options): heroes = Heroes.objects.all().values('hero_id') bulk = [] for hero in heroes: if hero['hero_id'] is not 185: data = get_json('/heroes/id/' + str(hero['hero_id'])) else: data = pure('/heroes/id/' + str(hero['hero_id'])) data = loads(data.text.split('line 84')[1]) HeroData(hero_id=data['hero_id'], disp_name=data['disp_name'], cli_name=data['cli_name'], category=data['attributes']['CATEGORY'], difficulty=data['attributes']['DIFFICULTY'], solorating=data['attributes']['SOLORATING'], junglerating=data['attributes']['JUNGLERATING'], carryrating=data['attributes']['CARRYRATING'], supportrating=data['attributes']['SUPPORTRATING'], initiatorrating=data['attributes']['INITIATORRATING'], gankerating=data['attributes']['GANKERRATING'], pusherrating=data['attributes']['PUSHERRATING'], rangedrating=data['attributes']['RANGEDRATING'], meleerating=data['attributes']['MELEERATING'], movespeed=data['attributes']['MOVESPEED'], turnrate=data['attributes']['TURNRATE'], maxhealth=data['attributes']['MAXHEALTH'], healthregen=data['attributes']['HEALTHREGEN'], manaregen=data['attributes']['MANAREGEN'], maxmana=data['attributes']['MAXMANA'], armor=data['attributes']['ARMOR'], magicarmor=data['attributes']['MAGICARMOR'], attackduration=data['attributes']['ATTACKDURATION'], attackactiontime=data['attributes']['ATTACKACTIONTIME'], attackcooldown=data['attributes']['ATTACKCOOLDOWN'], attackdamagemin=data['attributes']['ATTACKDAMAGEMIN'], attackdamagemax=data['attributes']['ATTACKDAMAGEMAX'], attacknumanims=data['attributes']['ATTACKNUMANIMS'], attackrange=data['attributes']['ATTACKRANGE'], attacktype=data['attributes']['ATTACKTYPE'], aggrorange=data['attributes']['AGGRORANGE'], sightrangeday=data['attributes']['SIGHTRANGEDAY'], sightrangenight=data['attributes']['SIGHTRANGENIGHT'], wanderrange=data['attributes']['WANDERRANGE'], primaryattribute=data['attributes']['PRIMARYATTRIBUTE'], strength=data['attributes']['STRENGTH'], strengthperlevel=data['attributes']['STRENGTHPERLEVEL'], agility=data['attributes']['AGILITY'], agilityperlevel=data['attributes']['AGILITYPERLEVEL'], intelligence=data['attributes']['INTELLIGENCE'], intelligenceperlevel=data['attributes']['INTELLIGENCEPERLEVEL'], calcattackspeed=data['attributes']['CALCATTACKSPEED'], attackspeedpersec=data['attributes']['ATTACKSPEEDPERSEC'], effectivearmor=data['attributes']['EFFECTIVEARMOR'], health=data['attributes']['HEALTH'], mana=data['attributes']['MANA'], ability1=dumps(data['abilities'].items()[0]), ability2=dumps(data['abilities'].items()[1]), ability3=dumps(data['abilities'].items()[2]), ability4=dumps(data['abilities'].items()[3]), ).save() self.stdout.write("success")