aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat-1 <github@matdoes.dev>2021-05-25 00:39:18 +0000
committermat-1 <github@matdoes.dev>2021-05-25 00:39:18 +0000
commit8c132c8eb308ce3e02cf1d1f79d58820dc1e65e8 (patch)
tree521cdadc1b8f9f2e9f8c1c2fe6440b8dd0d2f886
parent17d2c47ec62f0bdea043cc6d0e09ac3c39a58ea1 (diff)
downloadskyblock-api-8c132c8eb308ce3e02cf1d1f79d58820dc1e65e8.tar.gz
skyblock-api-8c132c8eb308ce3e02cf1d1f79d58820dc1e65e8.tar.bz2
skyblock-api-8c132c8eb308ce3e02cf1d1f79d58820dc1e65e8.zip
Compiled TS into JS
-rw-r--r--build/database.js20
-rw-r--r--build/hypixelCached.js2
2 files changed, 12 insertions, 10 deletions
diff --git a/build/database.js b/build/database.js
index aa8765c..55867ce 100644
--- a/build/database.js
+++ b/build/database.js
@@ -25,7 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
-exports.queueUpdateDatabaseProfile = exports.queueUpdateDatabaseMember = exports.updateDatabaseProfile = exports.updateDatabaseMember = exports.fetchMemberLeaderboardSpots = exports.fetchLeaderboard = exports.fetchProfileLeaderboard = exports.fetchMemberLeaderboard = exports.fetchAllMemberLeaderboardAttributes = exports.fetchSlayerLeaderboards = exports.fetchAllLeaderboardsCategorized = void 0;
+exports.queueUpdateDatabaseProfile = exports.queueUpdateDatabaseMember = exports.updateDatabaseProfile = exports.updateDatabaseMember = exports.fetchMemberLeaderboardSpots = exports.fetchLeaderboard = exports.fetchProfileLeaderboard = exports.fetchMemberLeaderboard = exports.fetchAllMemberLeaderboardAttributes = exports.fetchSlayerLeaderboards = exports.fetchAllLeaderboardsCategorized = exports.cachedRawLeaderboards = void 0;
const stats_1 = require("./cleaners/skyblock/stats");
const mongodb_1 = require("mongodb");
const cached = __importStar(require("./hypixelCached"));
@@ -41,7 +41,7 @@ const recentlyUpdated = new node_cache_1.default({
checkperiod: 60,
useClones: false,
});
-const cachedRawLeaderboards = new Map();
+exports.cachedRawLeaderboards = new Map();
const leaderboardMax = 100;
const reversedLeaderboards = [
'first_join',
@@ -188,8 +188,8 @@ function isLeaderboardReversed(name) {
async function fetchMemberLeaderboardRaw(name) {
if (!client)
throw Error('Client isn\'t initialized yet');
- if (cachedRawLeaderboards.has(name))
- return cachedRawLeaderboards.get(name);
+ if (exports.cachedRawLeaderboards.has(name))
+ return exports.cachedRawLeaderboards.get(name);
// typescript forces us to make a new variable and set it this way because it gives an error otherwise
const query = {};
query[`stats.${name}`] = { '$exists': true, '$ne': NaN };
@@ -200,12 +200,12 @@ async function fetchMemberLeaderboardRaw(name) {
.sort(sortQuery)
.limit(leaderboardMax)
.toArray();
- cachedRawLeaderboards.set(name, leaderboardRaw);
+ exports.cachedRawLeaderboards.set(name, leaderboardRaw);
return leaderboardRaw;
}
async function fetchProfileLeaderboardRaw(name) {
- if (cachedRawLeaderboards.has(name))
- return cachedRawLeaderboards.get(name);
+ if (exports.cachedRawLeaderboards.has(name))
+ return exports.cachedRawLeaderboards.get(name);
// typescript forces us to make a new variable and set it this way because it gives an error otherwise
const query = {};
query[`stats.${name}`] = { '$exists': true, '$ne': NaN };
@@ -216,7 +216,7 @@ async function fetchProfileLeaderboardRaw(name) {
.sort(sortQuery)
.limit(leaderboardMax)
.toArray();
- cachedRawLeaderboards.set(name, leaderboardRaw);
+ exports.cachedRawLeaderboards.set(name, leaderboardRaw);
return leaderboardRaw;
}
/** Fetch a leaderboard that ranks members, as opposed to profiles */
@@ -399,7 +399,7 @@ async function updateDatabaseMember(member, profile) {
}])
.sort((a, b) => leaderboardReverse ? a.stats[attributeName] - b.stats[attributeName] : b.stats[attributeName] - a.stats[attributeName])
.slice(0, 100);
- cachedRawLeaderboards.set(attributeName, newRawLeaderboard);
+ exports.cachedRawLeaderboards.set(attributeName, newRawLeaderboard);
}
if (_1.debug)
console.debug('added member to leaderboards', member.username, leaderboardAttributes);
@@ -448,7 +448,7 @@ async function updateDatabaseProfile(profile) {
}])
.sort((a, b) => leaderboardReverse ? a.stats[attributeName] - b.stats[attributeName] : b.stats[attributeName] - a.stats[attributeName])
.slice(0, 100);
- cachedRawLeaderboards.set(attributeName, newRawLeaderboard);
+ exports.cachedRawLeaderboards.set(attributeName, newRawLeaderboard);
}
if (_1.debug)
console.debug('added profile to leaderboards', profile.name, leaderboardAttributes);
diff --git a/build/hypixelCached.js b/build/hypixelCached.js
index 8dac057..72399c8 100644
--- a/build/hypixelCached.js
+++ b/build/hypixelCached.js
@@ -31,6 +31,7 @@ const mojang = __importStar(require("./mojang"));
const hypixel = __importStar(require("./hypixel"));
const util_1 = require("./util");
const _1 = require(".");
+const database_1 = require("./database");
// cache usernames for 4 hours
/** uuid: username */
exports.usernameCache = new node_cache_1.default({
@@ -351,6 +352,7 @@ setInterval(() => {
console.log('basicPlayerCache', exports.basicPlayerCache.getStats());
console.log('usernameCache', exports.usernameCache.getStats());
console.log('profileCache', exports.profileCache.getStats());
+ console.log('cachedRawLeaderboards size', database_1.cachedRawLeaderboards.size);
console.log(Math.floor((process.memoryUsage().heapUsed / 1024 / 1024) * 10) / 10
+ 'mb');
}, 60 * 1000);