Skip to content

Commit

Permalink
Add Contributor state to API (#1731)
Browse files Browse the repository at this point in the history
* Created contributors file for OpenDota contributors to flag their profile if desired.  Added it to the API response for /players/:id.

* revert package-lock changes.  Add Albert + Howard to CONTRIBUTORS file.  Update contributor documentation for OpenAPI definition.  Minor tweak to logic in contributor injection into player profile.

* Add null check for playerData

* update contributors file to use github username as comment rather than random names
  • Loading branch information
gu3st authored and howardchung committed Sep 19, 2018
1 parent 82d158e commit f65401e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ redis-config.yaml
postgres-config.yaml
dependency-reduced-pom.xml
Procfile.dev
docker-compose.override.yml
docker-compose.override.yml
.idea
11 changes: 11 additions & 0 deletions CONTRIBUTORS.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
This file is for contributors to OpenDota to add their DOTA friend codes (AKA SteamId3).
Currently this will cause the /players/:id endpoint to return is_contributor = true for your profile
*/

module.exports = {
88367253: {}, // howardchung
102344608: {}, // albertcui
9977887: {}, // gu3st
};
13 changes: 12 additions & 1 deletion routes/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const packageJson = require('../package.json');
const cacheFunctions = require('../store/cacheFunctions');
const params = require('./params');
const properties = require('./properties');
const contributors = require('../CONTRIBUTORS');
const {
teamObject, matchObject, heroObject, playerObject,
} = require('./objects');
Expand Down Expand Up @@ -1017,6 +1018,11 @@ Please keep request rate to approximately 1/s.
description: 'loccountrycode',
type: 'string',
},
is_contributor: {
description: 'Boolean indicating if the user contributed to the development of OpenDota',
type: 'boolean',
default: false,
},
},
},
},
Expand All @@ -1028,7 +1034,12 @@ Please keep request rate to approximately 1/s.
const accountId = Number(req.params.account_id);
async.parallel({
profile(cb) {
queries.getPlayer(db, accountId, cb);
queries.getPlayer(db, accountId, (err, playerData) => {
if (playerData !== null && playerData !== undefined) {
playerData.is_contributor = accountId in contributors;
}
cb(err, playerData);
});
},
tracked_until(cb) {
redis.zscore('tracked', accountId, cb);
Expand Down

0 comments on commit f65401e

Please sign in to comment.