mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2025-02-17 01:12:20 +00:00
Pull hive2 data, updated hive view
This commit is contained in:
parent
15acbca96c
commit
6e30e52ac2
4 changed files with 37 additions and 22 deletions
|
@ -52,28 +52,24 @@ const UserModal = React.createClass({
|
|||
<td>{user.hive.skill}</td>
|
||||
</tr>,
|
||||
<tr key="hours">
|
||||
<td>Hours Played</td>
|
||||
<td>Play Time (Hours)</td>
|
||||
<td>{Math.round(user.hive.playTime / 3600)}</td>
|
||||
</tr>,
|
||||
<tr key="wins">
|
||||
<td>Wins</td>
|
||||
<td>{user.hive.wins}</td>
|
||||
</tr>,
|
||||
<tr key="losses">
|
||||
<td>Losses</td>
|
||||
<td>{user.hive.loses}</td>
|
||||
<td>Marine Play Time (Hours)</td>
|
||||
<td>{_.round(user.hive.marine_playtime / 3600, 1)}</td>
|
||||
</tr>,
|
||||
<tr key="kills">
|
||||
<td>Kills (/min)</td>
|
||||
<td>{user.hive.kills} ({_.round(user.hive.kills / (user.hive.playTime / 60), 1)})</td>
|
||||
<td>Alien Play Time (Hours)</td>
|
||||
<td>{_.round(user.hive.alien_playtime / 3600, 1)}</td>
|
||||
</tr>,
|
||||
<tr key="assists">
|
||||
<td>Assists (/min)</td>
|
||||
<td>{user.hive.assists} ({_.round(user.hive.assists / (user.hive.playTime / 60), 1)})</td>
|
||||
<td>Commander Play Time (Hours)</td>
|
||||
<td>{_.round(user.hive.commander_time / 3600, 1)}</td>
|
||||
</tr>,
|
||||
<tr key="deaths">
|
||||
<td>Deaths (/min)</td>
|
||||
<td>{user.hive.deaths} ({_.round(user.hive.deaths / (user.hive.playTime / 60), 1)})</td>
|
||||
<tr key="wins">
|
||||
<td>Player ID</td>
|
||||
<td>{user.hive.pid}</td>
|
||||
</tr>
|
||||
]
|
||||
}
|
||||
|
@ -104,7 +100,7 @@ const UserModal = React.createClass({
|
|||
src={user.avatar}
|
||||
alt="User Avatar" />
|
||||
</div>
|
||||
<table className="table">
|
||||
<table className="table borderless">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Lifeforms</td>
|
||||
|
|
|
@ -291,3 +291,6 @@ html, body {
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
.borderless td, .borderless th {
|
||||
border: none !important;
|
||||
}
|
||||
|
|
|
@ -4,13 +4,15 @@ const path = require("path");
|
|||
const request = require("request");
|
||||
const logger = require("winston");
|
||||
const querystring = require('querystring');
|
||||
const UserStatisticsWrapper = require("./stats_wrapper");
|
||||
const config = require(path.join(__dirname, "../../config/config"));
|
||||
|
||||
|
||||
function HiveClient (options) {
|
||||
if (!(this instanceof HiveClient)) {
|
||||
return new HiveClient(options);
|
||||
}
|
||||
this.baseUrl = config.hive_url;
|
||||
this.baseUrl = config.hive2_url;
|
||||
}
|
||||
|
||||
HiveClient.prototype.getUserStats = function (user, callback) {
|
||||
|
@ -18,9 +20,23 @@ HiveClient.prototype.getUserStats = function (user, callback) {
|
|||
return callback(new Error("Invalid user instance supplied"));
|
||||
}
|
||||
return request({
|
||||
url: `${this.baseUrl}api/get/playerData/${user.hive.id}`,
|
||||
url: `${config.hive_url}/api/get/playerData/${user.hive.id}`,
|
||||
json: true
|
||||
}, callback);
|
||||
}, (error, response, body) => {
|
||||
return callback(error, response, new UserStatisticsWrapper(body));
|
||||
});
|
||||
};
|
||||
|
||||
HiveClient.prototype.getUserStatsV2 = function (user, callback) {
|
||||
if (!user || !user.hive.id) {
|
||||
return callback(new Error("Invalid user instance supplied"));
|
||||
}
|
||||
return request({
|
||||
url: `${config.hive2_url}/api/get/playerData/${user.hive.id}`,
|
||||
json: true
|
||||
}, (error, response, body) => {
|
||||
return callback(error, response, new UserStatisticsWrapper(body));
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = HiveClient;
|
||||
|
|
|
@ -116,10 +116,10 @@ User.find = function (id, callback) {
|
|||
},
|
||||
// Retrive Hive Stats
|
||||
callback => {
|
||||
hiveClient.getUserStats(user, (error, response, body) => {
|
||||
if (error || response.statusCode !== 200 || body.id === null) return callback();
|
||||
_.assign(user.hive, body);
|
||||
return callback(null, body);
|
||||
hiveClient.getUserStatsV2(user, (error, response, userStats) => {
|
||||
if (error || response.statusCode !== 200 || userStats.id === null) return callback();
|
||||
_.assign(user.hive, userStats);
|
||||
return callback(null, userStats);
|
||||
});
|
||||
}
|
||||
], function (error, result) {
|
||||
|
|
Loading…
Reference in a new issue