Git Product home page Git Product logo

make-a-stats's Introduction

Make a Stats

Application to view all kinds of PUBG related statistics for the Make A Stand discord gamers.

Build Status

Architecture

Frontend

Statically generated site with hugo, containing 1 page with an embedded VueJS component to consume and render a REST API, made accessible via AWS Lambda.

Backend

AWS Lambda function(s) that consume the PUBG API, and might cache data on AWS RDS or whatever.

Backend Java

A (temporary?) java backend to consume the PUBG API.

Flow

Contributing

PUBG Stub

We've got a semi-functional stub for the PUBG API implemented with Express

cd make-a-stats/pubg-stub
npm install
npm start

Modify players.js or matches.js to determine what players and matches there are.

There is some logic to deal with filter queries and path params.

For testing purposes this stub does not have throttling like the PUBG API does.

You can regenerate matches and players by calling http://localhost:3333/pubg-stub/regen?with[playerNames]=sch3lp,jooones&with[minMaxMatches]=1,4&with[minMaxKills]=2,9.

Frontend

Install frontend dependencies and run application locally:

cd make-a-stats/frontend
npm install
npm run serve

Backend

Loosely basing this code on https://github.com/ktonon/elm-serverless-demo

Running locally

cd make-a-stats/backend
npm install
npm start

Things to know

src/Stats/API.elm contains the source code that is loaded via the src/Stats/api.js JS bridge.

The JS Bridge is loaded via the Serverless JS package.

Chaining http requests to the PUBG API, by first getting the players, and then the matches of those players is done by transforming Http.get's to Tasks. Read this article for an explanation and easier example.

Deploying from local

Setup AWS_REGION, AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY in your environment (aws configure).

Make sure the AWS_ACCESS_KEY_ID maps to a user with restricted privileges that are sufficient for Serverless.

cd make-a-stats/backend
npm run deploy

You can also choose your aws profile to deploy with:

cd make-a-stats/backend
npm run deploy -- --profile <your local aws profile>

Read more about this configuration on the Serverless docs site.

Backend Java

Build code:

cd make-a-stats/backend_java
./gradlew clean build

Setup local machine to connect to the pubg developer api:

  • Place the property development=<dev-api-key> in a .key/pubgapi.key file in your user's home directory where <dev-api-key> is your api key retrieved from https://developer.playbattlegrounds.com
    • cd ~
    • mkdir .key
    • nano .key/pubgapi.key
    • add development=<dev-api-key>

Start application locally: Build code:

cd make-a-stats/backend_java
./gradlew bootRun

Navigate to http://localhost:8888/api/player/ and suffix the url with a player name

Change the boolean USE_STUB in the PubgApiCaller class to determine if the backup needs to use the pubg-stub or the actual pubg-api.

Currently, the request is very slow as we have to wait 6 seconds between each request to the pubg api. For one player with 20 matches played since 14 days, we have to make 1 player request and 20 match requests meaning we will have to wait 1 * 6 + 20 * 6 = 126 seconds. If 2 players are requested at the same time, errors will occur because of too many requests.

make-a-stats's People

Contributors

sch3lp avatar davidopdebeeck avatar jooones avatar hahawin avatar

Watchers

 avatar

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.