Skip to content

Commit

Permalink
changed env vars to enable, actually fixes odota#722
Browse files Browse the repository at this point in the history
  • Loading branch information
howardchung committed Nov 10, 2015
1 parent 4874957 commit 446cd5c
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 34 deletions.
4 changes: 1 addition & 3 deletions .env_example
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
STEAM_USER=REPLACE_THIS
STEAM_PASS=REPLACE_THIS
STEAM_API_KEY=REPLACE_THIS
DISABLE_RECAPTCHA=1
DISABLE_ADS=1
STEAM_API_KEY=REPLACE_THIS
1 change: 0 additions & 1 deletion compute.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ function computeMatchData(match) {
**/
function computePlayerMatchData(player_match) {
computeMatchData(player_match);
console.log(player_match.patch);
player_match.player_win = (isRadiant(player_match) === player_match.radiant_win); //did the player win?
player_match.isRadiant = isRadiant(player_match);
player_match.total_gold = ~~(player_match.gold_per_min * player_match.duration / 60);
Expand Down
11 changes: 5 additions & 6 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ var defaults = {
"PROXY_URLS": "", //comma separated list of proxy urls to use
"STEAM_API_HOST": "api.steampowered.com",
"ROLE": "", //for specifying a node type
"DISABLE_RECAPTCHA": "", // set to disable the recaptcha on the Request page,
"DISABLE_PRO_PARSING": "", // set to disable parsing pro matches from sequential API
"DISABLE_ADS": "", //disable ads
"PARSER_PARALLELISM": 8,
"MMSTATS_DATA_INTERVAL": 3, //minutes between requests for MMStats data
"ENABLE_MATCH_CACHE": "",
"ENABLE_PLAYER_CACHE": "",
"ENABLE_RECAPTCHA": "", // set to disable the recaptcha on the Request page,
"ENABLE_ADS": "", //disable ads
"ENABLE_PRO_PARSING": "", // set to parse pro matches from sequential API
"ENABLE_MATCH_CACHE": "", // set to enable caching matches
"ENABLE_PLAYER_CACHE": "", // set to enable caching players
//the following are deprecated
"PARSER_HOST": "localhost:5200",
"MONGO_URL": "mongodb://localhost/dota",
Expand Down
13 changes: 10 additions & 3 deletions java_parser/src/main/java/yasp/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,17 @@ public void onTickStart(Context ctx, boolean synthetic) {
while (added < numPlayers && i < 100) {
//check each m_vecPlayerData to ensure the player's team is radiant or dire
int playerTeam = getEntityProperty(pr, "m_vecPlayerData.%i.m_iPlayerTeam", i);
//Long steamid = getEntityProperty(pr, "m_vecPlayerData.%i.m_iPlayerSteamID", i);
//System.err.format("%s: %s: %s\n", i, playerTeam, steamid);
int teamSlot = getEntityProperty(pr, "m_vecPlayerTeamData.%i.m_iTeamSlot", i);
Long steamid = getEntityProperty(pr, "m_vecPlayerData.%i.m_iPlayerSteamID", i);
//System.err.format("%s %s %s: %s\n", i, playerTeam, teamSlot, steamid);
if (playerTeam == 2 || playerTeam == 3) {
//if so, add it to validIndices, add 1 to added
//output the player_slot based on team and teamslot
Entry entry = new Entry(time);
entry.type = "player_slot";
entry.key = String.valueOf(added);
entry.value = (playerTeam == 2 ? 0 : 128) + teamSlot;
es.output(entry);
//add it to validIndices, add 1 to added
validIndices[added] = i;
added += 1;
}
Expand Down
9 changes: 2 additions & 7 deletions queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ function getColumnInfo(db, cb) {

function insertMatch(db, redis, queue, match, options, cb) {
var players = match.players ? JSON.parse(JSON.stringify(match.players)) : undefined;
if (players) {
players.sort(function(a, b) {
return a.player_slot - b.player_slot;
});
}
delete match.players;
//options specify api, parse, or skill
//we want to insert into matches, then insert into player_matches for each entry in players
Expand Down Expand Up @@ -265,11 +260,11 @@ function insertMatch(db, redis, queue, match, options, cb) {
return cb();
}
else {
//slot to id map so after parse we can figure out the player ids for each slot
//slot to id map so after parse we can figure out the player ids for each slot (for caching update without db read)
//do this at the end so it doesn't get deleted during match insertion step
if (players) {
match.slot_to_id = {};
players.forEach(function(p) {
players.forEach(function(p, i) {
match.slot_to_id[p.player_slot] = p.account_id;
});
}
Expand Down
2 changes: 1 addition & 1 deletion scanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function scanApi(seq_num) {
}
logger.info("[API] seq_num:%s, matches:%s", seq_num, resp.length);
async.each(resp, function(match, cb) {
if (match.leagueid && !config.DISABLE_PRO_PARSING) {
if (match.leagueid && config.ENABLE_PRO_PARSING) {
//parse tournament games
match.parse_status = 0;
}
Expand Down
3 changes: 2 additions & 1 deletion utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ function mode(array) {

function getParseSchema() {
return {
"version": 14,
"version": 15,
"match_id": 0,
"teamfights": [],
"objectives": [],
Expand All @@ -280,6 +280,7 @@ function getParseSchema() {
"radiant_xp_adv": [],
"players": Array.apply(null, new Array(10)).map(function() {
return {
"player_slot": 0,
"stuns": 0,
"max_hero_hit": {
value: 0
Expand Down
2 changes: 1 addition & 1 deletion views/mixins/ads.jade
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mixin ad(type)
if !(user && user.cheese) && !config.DISABLE_ADS
if !(user && user.cheese) && config.ENABLE_ADS
if type==="banner1"
script.
//check adblocker
Expand Down
3 changes: 1 addition & 2 deletions views/request.jade
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ block content
.form-group
input#match_id.form-control(type='text' name='match_id' placeholder='Match ID')
.form-group
if !config.DISABLE_RECAPTCHA
if config.ENABLE_RECAPTCHA
.g-recaptcha#recaptcha(data-sitekey=rc_public, data-theme="dark", data-callback="submit")
else
// if the DISABLE_RECAPTCHA env var has been set, bypass the recaptcha
button.btn.btn-default(onclick="submit()") Request Parse
#progContainer(style="display:none")
img(src="/public/images/loading.gif", style="display:none")#loading
Expand Down
2 changes: 1 addition & 1 deletion web.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ app.route('/request_job').post(function(req, res) {
}
var match_id = req.body.match_id;
match_id = Number(match_id);
if (!body.success && !config.DISABLE_RECAPTCHA) {
if (!body.success && config.ENABLE_RECAPTCHA) {
console.log('failed recaptcha');
res.json({
error: "Recaptcha Failed!"
Expand Down
18 changes: 11 additions & 7 deletions workParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,8 @@ function getJob() {
}
console.log(job);
if (job.jobId && job.data && job.data.payload && job.data.payload.url) {
var payload = job.data.payload;
var url = job.data.payload.url;
console.log("got work from server, jobid: %s, url: %s", job.jobId, url);
runParse(payload, function(err, parsed_data) {
console.log("got work from server, jobid: %s, url: %s", job.jobId, job.data.payload.url);
runParse(job.data.payload, function(err, parsed_data) {
if (err) {
console.error("error occurred on parse: %s", err);
parsed_data = {
Expand Down Expand Up @@ -118,9 +116,9 @@ function getJob() {
});
}

function runParse(data, cb) {
function runParse(match, cb) {
var print_multi_kill_streak_debugging = false;
var url = data.url;
var url = match.url;
var error = "incomplete";
var inStream;
var parseStream;
Expand All @@ -130,7 +128,7 @@ function runParse(data, cb) {
var entries = [];
var hero_to_slot = {};
var hero_to_id = {};
var curr_player_hero = {};
//var curr_player_hero = {};
var game_zero = 0;
var curr_teamfight;
var teamfights = [];
Expand All @@ -153,6 +151,10 @@ function runParse(data, cb) {
}
};
var types = {
"player_slot": function(e) {
parsed_data.players[e.key].player_slot = e.value;
console.log(e);
},
"match_id": function(e) {
parsed_data.match_id = e.value;
},
Expand Down Expand Up @@ -685,6 +687,8 @@ function runParse(data, cb) {
xptotal -= p.xp_t[i];
goldtotal -= p.gold_t[i];
}
//use player slot to id mapping sent from server to fill in account_ids (for determining player cache updates on insert)
p.account_id = match.slot_to_id[p.player_slot];
});
parsed_data.radiant_gold_adv.push(goldtotal);
parsed_data.radiant_xp_adv.push(xptotal);
Expand Down
1 change: 0 additions & 1 deletion workServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ function start() {
match[key] = match[key] || parsed_data[key];
}
match.players.forEach(function(p, i) {
p.player_slot = i < match.players.length / 2 ? i : i + (128 - 5);
p.account_id = match.slot_to_id[p.player_slot];
});
match.parse_status = 2;
Expand Down
2 changes: 2 additions & 0 deletions worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ function processApi(job, cb) {
clearInterval(poll);
return cb("failed");
}
}).catch(function(err) {
return cb(err);
});
});
}, 2000);
Expand Down

0 comments on commit 446cd5c

Please sign in to comment.