Skip to main content

Python library to process solo queue game data with comprehensive database models to additionally store LoL Esports data

Reason this release was yanked:

Indevelopment code was accidentally commited

Project description

ATG - All The Games

Opinionated but flexible library of database models and scripts and APIs to store solo queue / competitive games, player, team and game data tailored for LoL Esports.

Features

  • Functions to access Riot & GRID APIs with smart region handling
  • SQLAlchemy database models compatible with both solo queue & esports games
  • Database models to store riot game event JSONL files
  • Ability to store complete Match-V5 JSON objects
  • Scripts to insert/manage solo queue accounts & store new solo queue games

1.X Release Notes

As of version 1.X, PostgreSQL is the required database backend due to the use of JSONB columns which are declared using the sqlalchemy.dialects.postgresql.JSONB datatype.

I have decided to bump the major version since this library is mature enough for my production needs however expect extensive schema changes as I look to fully mature my database models.

Although naming initially reflects the match-v5 API's choices and the terminology used by GRID esports, I've had to make some changes.

Here is are the major differences / exceptions that should be noted.

Key used Meaning Examples
Series A collection of related games A series has many games
source_data Raw/unprocessed/additional data Specifically in ParticipantStats we store the unprocessed match_v5 columns here
X_id table_id; Foreign key name champion_id, game_id
team_id Blue / red sides 100 - Blue, 200 - Red
participant_id The "#" of the participant From 1 - 10 representing blue top -> red bottom most of the time.

Todo

  • Remove the usage of ratelimit in favor of something that actually does stable rate limiting
  • Properly handle API error codes
  • Add the ability to store draft / other available esports game information
  • Open source GRID API code and GRID insertion scripts
  • Handle database sessions and API keys better using dependency injection or something other than passing session objects around. I kind of like the current functional nature of the API
  • Normalize database objects. Specifically the series/tournament-game relationship
  • Reduce the number of nullable columns where possible. This is especially a problem on the game table
  • Introduce enums where appropriate
  • Transition to HTTPX > requests
  • Remove or update the player_team_association table. I currently don't use it but it's definitely useful and should be revisited in the future.

Setup & Example Usage

It is recommended to use a virtual environment when directly running this library's scripts.

Setup dependencies

pip install -r requirements.txt

Edit the .env file with your Riot API key and database connection string. The psycopg3 database driver is installed if this code is installed as a library and is recommended.

python main.py

Example usage (linking a pro player by name to a solo queue account)

import os
from sqlalchemy import select

from ATG.database import get_session_factory
from ATG.api import get_account_by_riot_id
from ATG.models import Player, Account

RIOT_API = os.environ["RIOT_API"]
Session = get_session_factory(os.environ["PROD_DB"])

def link_pro(pro_name, soloq):
    with Session() as session:
        try:
            player = session.execute(select(Player).where(Player.name == pro_name)).scalar_one()
        except:
            print(f"Unable to find associated player for {pro_name}")
            return
        name, tagline = soloq.split("#")
        details = get_account_by_riot_id(name, tagline, RIOT_API).json()
        new_acc = Account(puuid=details['puuid'], name=details['gameName'], tagline=details['tagLine'], region='NA1', player_id=player.id)
        session.add(new_acc)
        try:
            session.commit()
            print(f"Linked {pro_name} with {name}#{tagline}")
        except:
            session.rollback()
            print(f"Account {name}#{tagline} already linked")

link_pro("Tactical", "Tactical0#NA1")

Schema changes - Alembic commands

In the case of schema changes, Alembic allows us to automatically generate a script to apply the changes to the database. When a commit will cause a schema change, an alembic script should be attached to the commit.

alembic revision --autogenerate -m "changes"
alembic upgrade head

Poetry

Commands to publish updates on PyPi

poetry build
poetry publish

Legal

ATG is not endorsed by Riot Games and does not reflect the views or opinions of Riot Games or anyone officially involved in producing or managing Riot Games properties. Riot Games and all associated properties are trademarks or registered trademarks of Riot Games, Inc

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

atg_lib-1.5.1.tar.gz (31.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

atg_lib-1.5.1-py3-none-any.whl (44.2 kB view details)

Uploaded Python 3

File details

Details for the file atg_lib-1.5.1.tar.gz.

File metadata

  • Download URL: atg_lib-1.5.1.tar.gz
  • Upload date:
  • Size: 31.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-29-generic

File hashes

Hashes for atg_lib-1.5.1.tar.gz
Algorithm Hash digest
SHA256 35c189c13af939d09b79aa05d0738f5816e80452fe92a425469e7f1f790e1866
MD5 37b9a26af4d446d69ea5c6dc36f9a3ed
BLAKE2b-256 22848d3b9427904135f10ecae315b779b9697c688171520042f8fb8da34f8585

See more details on using hashes here.

File details

Details for the file atg_lib-1.5.1-py3-none-any.whl.

File metadata

  • Download URL: atg_lib-1.5.1-py3-none-any.whl
  • Upload date:
  • Size: 44.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-29-generic

File hashes

Hashes for atg_lib-1.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 110a70b76c36a6aec089a22ffb59e2f1c7a2b3bca75530a9dcdb77b2a25296ac
MD5 8ce6c297bbbcddc2b63c36ec6fc5e1e6
BLAKE2b-256 25bb916fa16fe66b0ab1d524de25ddfce58653678b83f8e44daf8f206d49b9be

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page