Skip to content

Web app for tracking, analyzing and visualizing data for CSGO matches played on the scrim service PopFlash

Notifications You must be signed in to change notification settings

jakvah/tenmen-tracker

Repository files navigation

tenmen-tracker

Python web app for tracking, analyzing and visualizing match data from CSGO matches played on the scrim service PopFlash. The match extracion module scrapes the PopFlash match page and extracts the match data. The database management module accepts the match data and adds it to a MySQL database. The __init__.py is the Flask based Python backend interacting with the database and webscraper to present the stored matches and match data to the website. It also allows users to add their matches to be included as part of the total statistics.

A live demo of the website can be found here

Website screenshots

Table of Contents

Dependencies

The requried dependencies for the database management module, the match extraction module and the entire Wep App are specified in the requirements.txt file. If you want to install all the dependencies run

~$ pip install -r requirements.txt

If you only want to install the dependencies for a specific module, see the requirements.txt file for the dependencies corresponding to the module of choice.

Hosting the Web App

Quickstart

Make sure you have installed the required dependencies. If you are familiar with Python based web development and already have a MySQL database and Apache2 (or similar) on your server, clone this project into the folder hosting your web app. You will have to alter the login details of the database management module to match your own database.

Running on Ubuntu/Linux-based host system

There are several ways to host (Python based) web applications. If you are new to the field, I can recommend a Digital Ocean droplet for hosting your web app. They will set you back $5 USD a month, however offer loads of great tutorial for beginners. To deploy the tenman-tracker Flask app, follow this tutorial. Navigate to the folder hosting your web app

~$ cd /var/www/<FlaskApp>/<FlaskApp>

and clone the git repository into the folder

~$ git clone git@github.com:jakvah/tenmen-tracker.git

The match exctraction module

The match extraction module containes a simple Web Scraper that searches the match page of a given match ID and extracts relevant match data. Additionally it contains custom Match, Player and Team classes, which makes it easier to work with the match data.

A simple code example illustrating the usage of the classes and some of their class methods is shown below

from match_extraction import popflash_scraper as ps
from match_extraction.Match import Match
from match_extraction.Team import Team
from match_extraction.Player import Player

# Get match data in an instance of the Match class
match_id = 123
match = ps.get_match_data(match_id)

# Get data for winning team in an instance of the Team class
winning_team = match.get_winner()
winning_team_score = winning_team.get_score()

# The team class is iterable, so we can iterate through the players in the team, and print each player (the Player class has a __str__ method)
for player in winning_team:
    print(player)

# Get the top player from the match in an instance of the Player class
top_player = match.get_highest_rated()
top_player_nick = top_player.get_nick()

For more class methods, see the source code for the various classes

The database management module

The database management module is, as the name suggests, responsible for interacting with the database where the match data is stored. It is based on the MySQL-Connector module. The login info is stored in the DATABASE_LOGIN_DETAILS dictionary. The password to the MySQL server is stored here, which is probably not the greatest idea. If this is to be implemented .. this should probably be kept more secure.

The functions interacting with the database are defined in the database_interaction.py file. The names of the various functions should be pretty self explainatory. The all have in common that they require as MySQLdb-connection object as an input argument. This is taken care of by calling the get_database() function, and passing the returned connection object as an input the whatever funciton you want to use.

To make error handling easier, a set of custom made exceptions have also been defined in the database_exceptions.py file. The following sample code suggests how to use the functions from the module.

from database_management import db_interaction as dbi

conn = dbi.get_database_connection()

if dbi.table_exists(conn,"my_table"):
    data = dbi.get_table_data(conn,"my_table")
else:
    raise TablesDoesNotExistError

About

Web app for tracking, analyzing and visualizing data for CSGO matches played on the scrim service PopFlash

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published