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 player/records endpoint #1839

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Fixed is_contributor
  • Loading branch information
builder-247 committed Jan 22, 2019
commit 5e09b2377c90a6e29026e8457acefe0d0d653d2d
18 changes: 9 additions & 9 deletions store/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const cacheFunctions = require('./cacheFunctions');
const benchmarksUtil = require('../util/benchmarksUtil');

const {
redisCount, convert64to32, serialize, deserialize, isRadiant,
redisCount, convert64to32, serialize, deserialize, isRadiant, isContributor,
} = utility;
const { computeMatchData } = compute;
const columnInfo = {};
Expand Down Expand Up @@ -201,8 +201,8 @@ function getHeroRankings(db, redis, heroId, options, cb) {
join players using(account_id)
left join notable_players using(account_id)
left join rank_tier using(account_id)
WHERE hero_id = ?
ORDER BY score DESC
WHERE hero_id = ?
ORDER BY score DESC
LIMIT 100
`, [heroId || 0]).asCallback((err, result) => {
if (err) {
Expand Down Expand Up @@ -275,7 +275,7 @@ function getPlayerMatches(accountId, queryObj, cb) {
// console.log(queryObj.project, cassandraColumnInfo.player_caches);
const query = util.format(
`
SELECT %s FROM player_caches
SELECT %s FROM player_caches
WHERE account_id = ?
ORDER BY match_id DESC
${queryObj.dbLimit ? `LIMIT ${queryObj.dbLimit}` : ''}
Expand Down Expand Up @@ -384,7 +384,7 @@ function getPeers(db, input, player, cb) {
}
t.personaname = row.personaname;
t.name = row.name;
t.is_contributor = row.is_contributor;
t.is_contributor = isContributor(t.account_id);
t.last_login = row.last_login;
t.avatar = row.avatar;
t.avatarfull = row.avatarfull;
Expand Down Expand Up @@ -651,7 +651,7 @@ async function updateTeamRankings(match, options) {
const win2 = Number(!team1Win);
const ratingDiff1 = kFactor * (win1 - e1);
const ratingDiff2 = kFactor * (win2 - e2);
const query = `INSERT INTO team_rating(team_id, rating, wins, losses, last_match_time) VALUES(?, ?, ?, ?, ?)
const query = `INSERT INTO team_rating(team_id, rating, wins, losses, last_match_time) VALUES(?, ?, ?, ?, ?)
ON CONFLICT(team_id) DO UPDATE SET team_id=team_rating.team_id, rating=team_rating.rating + ?, wins=team_rating.wins + ?, losses=team_rating.losses + ?, last_match_time=?`;
await db.raw(query, [
team1, currRating1 + ratingDiff1, win1, Number(!win1), match.start_time,
Expand Down Expand Up @@ -1118,9 +1118,9 @@ function getLaneRoles(req, cb) {
db.raw(
`SELECT hero_id, lane_role, time, sum(games) games, sum(wins) wins
FROM scenarios
WHERE lane_role IS NOT NULL
WHERE lane_role IS NOT NULL
AND (0 = :heroId OR hero_id = :heroId)
AND (0 = :lane OR lane_role = :lane)
AND (0 = :lane OR lane_role = :lane)
GROUP BY hero_id, lane_role, time ORDER BY hero_id, time, lane_role
LIMIT 1200`,
{ heroId, lane },
Expand All @@ -1132,7 +1132,7 @@ function getTeamScenarios(req, cb) {
db.raw(
`SELECT scenario, is_radiant, region, sum(games) games, sum(wins) wins
FROM team_scenarios
WHERE ('' = :scenario OR scenario = :scenario)
WHERE ('' = :scenario OR scenario = :scenario)
GROUP BY scenario, is_radiant, region ORDER BY scenario
LIMIT 1000`,
{ scenario },
Expand Down