예제 #1
0
def update_guild():
    for guild in Guild.query.all():
        if r.get(guild.name+"-"+guild.realm+"-"+guild.region) is None:
            r.set(guild.name+"-"+guild.realm+"-"+guild.region, datetime.utcfromtimestamp(0))
        if (datetime.utcnow() - datetime.strptime(r.get(guild.name+"-"+guild.realm+"-"+guild.region).split(".")[0],
                                                  "%Y-%m-%d %H:%M:%S")).total_seconds() > 60:
            r.set(guild.name+"-"+guild.realm+"-"+guild.region, datetime.utcnow())
            guild.update_wowprogress()
            guild.update_members()
            guild.update_progress()
예제 #2
0
def update_raids():
    if r.get("zones") is None:
        r.set("zones", datetime.utcfromtimestamp(0))
    if (datetime.utcnow() - datetime.strptime(r.get("zones").split(".")[0],
                                              "%Y-%m-%d %H:%M:%S")).total_seconds() > 60:
        r.set("zones", datetime.utcnow())
        params = {"locale": "en_GB", "apikey": battlenet_apikey}
        zones = requests.get("https://eu.api.battle.net/wow/zone/", params=params).json()
        raids = {}
        for zone in zones["zones"]:

            if zone["isRaid"]:
                raids[zone["id"]] = {"name": zone["name"], "bosses": len(zone["bosses"])}

        for wow_id, info in raids.iteritems():
            raid = Raid.query.filter_by(wow_id=wow_id).first()
            if raid is None:
                raid = Raid(wow_id)
                sql_connection.session.add(raid)
                sql_connection.session.commit()