Example #1
0
Emerson Matson

Moves the large data set into a more compact, workable dataset for analysis.
"""

from sqlalchemy import func, Integer

from league import db

from league.models import Champion
from league.models import ChampionData
from league.models import Match

from prettylog import PrettyLog

LOGGING = PrettyLog()

"""
TODO(Optimize this query for large databases.)
    Window the query.
        http://stackoverflow.com/
            questions/7389759/
            memory-efficient-built-in-sqlalchemy-iterator-generator
    Filter the query to the most recent matches (30 days?)
    Limit the query to a good amount (10 million?)
    Prune the database every so often.
"""


def analyze_champions():
    """Analyzes the champion database and condenses the statistics."""
Example #2
0
Emerson Matson

Collects tweets from the Twitter sample stream.
"""

import tweepy

from prettylog import PrettyLog

from twitter import db

from twitter.models import Tweet

from analysis.connection import API

LOGGING = PrettyLog()


class TweetStreamListener(tweepy.StreamListener):
    """Configures the Stream Listener for storage"""

    num_tweets = 0

    # TODO(Consider using PrettyLog for this.)
    def on_connect(self):
        LOGGING.push("Successfully connected to Twitter streaming API.")

    def on_status(self, status):
        if (
            db.session.query(Tweet).filter_by(tweet_id=status.id).count() == 0
            and
Example #3
0
import tweepy

from prettylog import PrettyLog

from twitter import app
from twitter import db

from twitter.models import Tweet

from analysis.connection import AUTH

API = tweepy.API(AUTH, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)

CATEGORIES = app.config['CATEGORIES']

LOGGING = PrettyLog()


def limit_handled(cursor):
    """Limits the cursor's accesses with respect to the rate limit.

    Args:
        cursor: Cursor to limit.

    Notes:
        Once the rate limit is reached, program execution waits 15 minutes.
    """

    while True:
        """
        remaining = int(API.last_response.getheader('x-rate-limit-remaining'))
Example #4
0
"""
Champion Score Analysis
Emerson Matson

Analyzes individual champion (and role's) score.
"""

from league.models import ChampionData

from prettylog import PrettyLog

LOGGING = PrettyLog()


def make_adjustments():
    """Takes all champion data and creates a score."""

    champions = ChampionData.query.all()

    # TODO(Look at external sources for better analysis.)
    #   Look at pro players? Look at nerfplz.com and analyze their
    #       algorithm for assigning tier lists. Look at popularity on twitter?

    for champion in champions:
        # True forces the methods to force updates
        champion.get_score(True)
        champion.get_counters(True)
        champion.get_assists(True)

        # TODO(Use adjustments attribute to assign miscellaneous overall stats)
        #   ChampionDatas as verticies. Directed edges against champions to