Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dotaplus xp #2145

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions processors/createParsedDataBlob.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function getParseSchema() {
radiant_gold_adv: [],
radiant_xp_adv: [],
cosmetics: {},
dotaplus: {},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should store this as a field per player instead of per match? since we need to store it per player in the player_caches table anyway

players: Array(...new Array(10)).map(() => ({
player_slot: 0,
obs_placed: 0,
Expand Down
3 changes: 3 additions & 0 deletions processors/populate.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ function populate(e, container) {
case 'cosmetics':
container.cosmetics = JSON.parse(e.key);
break;
case 'dotaplus':
container.dotaplus = JSON.parse(e.key);
break;
case 'CHAT_MESSAGE_FIRSTBLOOD':
case 'CHAT_MESSAGE_COURIER_LOST':
case 'CHAT_MESSAGE_AEGIS':
Expand Down
3 changes: 3 additions & 0 deletions processors/processExpand.js
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,9 @@ function processExpand(entries, meta) {
cosmetics(e) {
expand(e);
},
dotaplus(e) {
expand(e);
},
};
for (let i = 0; i < entries.length; i += 1) {
const e = entries[i];
Expand Down
22 changes: 20 additions & 2 deletions routes/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,10 @@ You can find data that can be used to convert hero and ability IDs and other inf
description: 'The ID value of the hero played',
type: 'integer',
},
hero_dotaplus_xp: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this make more sense stored as a separate table from each player_hero combination? Seems like this would be a properly that's independent of each match, unless we care about their dota plus level at the time of the match.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how the game client displays it, also not sure if gets set to 0 on the replays if the player doesn't have a valid subscription anymore

description: 'Dota Plus hero xp',
type: 'integer',
},
item_0: {
description: 'Item in the player\'s first slot',
type: 'integer',
Expand Down Expand Up @@ -1441,7 +1445,13 @@ You can find data that can be used to convert hero and ability IDs and other inf
summary: 'GET /players/{account_id}/heroes',
description: 'Heroes played',
tags: ['players'],
parameters: playerParams,
parameters: [...playerParams, {
name: 'hero_dotaplus_xp',
in: 'query',
description: 'Hero dotaplus level progress',
required: false,
type: 'boolean',
}],
responses: {
200: {
description: 'Success',
Expand Down Expand Up @@ -1483,6 +1493,10 @@ You can find data that can be used to convert hero and ability IDs and other inf
description: 'against_win',
type: 'integer',
},
hero_dotaplus_xp: {
builder-247 marked this conversation as resolved.
Show resolved Hide resolved
description: 'Appears if the parameter is set',
type: 'integer',
},
},
},
},
Expand All @@ -1505,7 +1519,7 @@ You can find data that can be used to convert hero and ability IDs and other inf
};
heroes[heroId] = hero;
});
req.queryObj.project = req.queryObj.project.concat('heroes', 'account_id', 'start_time', 'player_slot', 'radiant_win');
req.queryObj.project = req.queryObj.project.concat('heroes', 'account_id', 'start_time', 'player_slot', 'radiant_win', 'hero_dotaplus_xp');
builder-247 marked this conversation as resolved.
Show resolved Hide resolved
queries.getPlayerMatches(req.params.account_id, req.queryObj, (err, cache) => {
if (err) {
return cb(err);
Expand Down Expand Up @@ -1534,6 +1548,10 @@ You can find data that can be used to convert hero and ability IDs and other inf
heroes[tmHero].against_games += 1;
heroes[tmHero].against_win += playerWin ? 1 : 0;
}
if (req.query.hero_dotaplus_xp) {
// Use the highest xp value
heroes[tmHero].hero_dotaplus_xp = Math.max(m.hero_dotaplus_xp, heroes[tmHero].hero_dotaplus_xp || 0);
}
}
});
});
Expand Down
2 changes: 2 additions & 0 deletions sql/create_tables.cql
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ CREATE TABLE IF NOT EXISTS matches (
teamfights text,
version int,
cosmetics text,
dotaplus text,
skill int,
radiant_team_id int,
dire_team_id int,
Expand Down Expand Up @@ -150,6 +151,7 @@ CREATE TABLE IF NOT EXISTS player_caches (
gold_per_min text,
xp_per_min text,
hero_id text,
hero_dotaplus_xp text,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we only need it in the table if we are going to aggregate this across matches for a player

leaver_status text,
version text,
courier_kills text,
Expand Down
1 change: 1 addition & 0 deletions sql/create_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ CREATE TABLE IF NOT EXISTS matches (
draft_timings json[],
version integer,
cosmetics json,
dotaplus json,
series_id integer,
series_type integer
);
Expand Down
2 changes: 2 additions & 0 deletions sql/migrations.cql
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
ALTER TABLE player_matches ADD damage_targets text;
ALTER TABLE player_matches ADD connection_log text;
ALTER TABLE player_caches ADD hero_dotaplus_xp text;
ALTER TABLE matches ADD dotaplus text;
1 change: 1 addition & 0 deletions sql/migrations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ CREATE TABLE IF NOT EXISTS webhooks (
CREATE INDEX IF NOT EXISTS webhooks_account_id_idx on webhooks(account_id);

ALTER TABLE player_matches ADD connection_log json[];
ALTER TABLE matches ADD dotaplus json;
5 changes: 4 additions & 1 deletion store/buildMatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const redis = require('../store/redis');
const db = require('../store/db');

const { computeMatchData } = compute;
const { deserialize, buildReplayUrl, isContributor } = utility;
const {
deserialize, buildReplayUrl, isContributor,
} = utility;
const getRedisAsync = promisify(redis.get).bind(redis);

async function getMatchData(matchId) {
Expand Down Expand Up @@ -51,6 +53,7 @@ async function extendPlayerData(player, match) {
cluster: match.cluster,
lobby_type: match.lobby_type,
game_mode: match.game_mode,
hero_dotaplus_xp: (match.dotaplus || {})[player.player_slot] || 0,
is_contributor: isContributor(player.account_id),
};
computeMatchData(p);
Expand Down
2 changes: 2 additions & 0 deletions store/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,8 @@ function insertPlayerCache(match, cb) {
p.account_id = match.pgroup[p.player_slot].account_id;
// add hero_id to each player so we update records with hero played
p.hero_id = match.pgroup[p.player_slot].hero_id;
// add dotaplusxp
p.hero_dotaplus_xp = (match.dotaplus || {})[p.player_slot] || 0;
}
});
}
Expand Down