Gravity is the project responsible for get data from LoL API and store them in NoSQL database. This project was a part of a bigger one that I was participating with some friends :)
As you can see, we have two databases: lol_dirty_data and lol_clean_data. The reason for it is the type of datas that we manipulate: dirty and clean datas.
LoL Matches’ data has a lot of informations that, most of them, we aren’t going to use for now. I called this data as dirty.
Imagine a stone that inside has a diamond. We want the diamond, not the entire stone. But we need the stone to get the diamond. That’s the point. lol_dirty_data store brute data (stones with diamonds).
Gravity is like a miner: it just insert data in lol_dirty_data. It collects stones for other applications that know how to extract diamonds from stones.
Our other database is lol_clean_data, where the diamonds are placed.
All data treated by our applications should be stored in it. The applications should load datas from lol_dirty_data or others integration, compile them and store in lol_clean_data.
Gravity will not insert data in lol_clean_data.
Nowadays Gravity load two data types: seed files and recent games.
Seed files are a compilation of aleatory matches that LoL team offers to new developers. It's the easiest way to understand the data's struct. Those files are updated every 3 months or when data's struct is modified. Seed files are stored in collection seed_match
.
Recent games came from a LoL API's service (game endpoint) that returns the last 10 games played from a summoner. Recent gmaes are stored in collection recent_game
.
Install MongoDB:
Then install Bundler
Now you can clone Gravity:
git clone https://github.com/eduardoeof/gravity.git
On Gravity's dir, install gems:
bundle install
On terminal, run MongoDB:
mongod
Gravity needs summonerIds to load recent games. For this, create file create_summoners.js
with:
db = db.getSiblingDB('lol_clean_data')
db.summoner.insertMany(
[
{ name: "LEP", summonerId: "1634366" },
{ name: "Minerva", summonerId: "9480188" },
{ name: "tinowns", summonerId: "20410406" },
{ name: "pbo", summonerId: "15723636" },
{ name: "wOs", summonerId: "761032" },
{ name: "Yang", summonerId: "488056" },
{ name: "Revolta", summonerId: "1876119" },
{ name: "Tockers", summonerId: "21894688" },
{ name: "micao", summonerId: "16404993" },
{ name: "Jockster", summonerId: "22594355" }
]
)
Then execute the file from mongo shell client:
mongo create_summoners.js
Then go to Gravity's dir and execute:
./gravity
Also can be used arguments to load specific datas:
-g
or--game
: load just recent games.-s
or--seed
: load just seed files.-a
or--all
: load recent games and seed files.
./gravity -g
Eat your vegetables.