Coder Social home page Coder Social logo

jakvah / tenmen-tracker Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 8.82 MB

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

Home Page: http://jakobvahlin.com/tenman

Python 22.55% CSS 9.48% SCSS 16.06% HTML 51.91%
database analyzing-data webscraping python mysql

tenmen-tracker's Introduction

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 [email protected]: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

tenmen-tracker's People

Contributors

jakvah avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

rockyspade

tenmen-tracker's Issues

Slow webscraper

The process of extracting match data from popflash takes a long time. This makes loading the match page take a long time. Can be fixed by:

  • Increasing the performance of the webscraper (should be possible)
  • Storing more match data in the database (getting data from database is very quick)

Match can be duplicated

If x users adds matches almost at the same time, then the match will be added x times. Introduce semaphores/locks?

Tie match will update average but not total sample number

When updating the average for a player statistic, the sample size for the average is given by the players wins + lossess. However, when adding a tied match, the average will be updated, but the sample size will be unaffected.

PopFlash API

Hey, this project is really cool! I operate PopFlash and am rolling out an API for simpler access to data. If you're interested in it, feel free to shoot me a note on our discord (https://popflash.site/discord, tag me @switz). Happy to give you access :)

Take care

Unicode chars

The webscraper uses wrong character encoding for non english chararacters (i.e "æ","ø","å"). Must specify utf-8 in webscraper

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.