VASTLY decreased the amount of pregenerations done by the site, greatly improving performance
This commit is contained in:
parent
ae1397d84a
commit
ba79d970a1
3 changed files with 11 additions and 3 deletions
1
api.js
1
api.js
|
@ -56,6 +56,7 @@ function socketeer() {
|
|||
module.exports.connected = true
|
||||
ping(30000)
|
||||
lastPong = Date.now()
|
||||
events.emit("lanyardConnect")
|
||||
} else if (data.op == 3) {
|
||||
lastPong = Date.now()
|
||||
} else if (data.op == 0) {
|
||||
|
|
|
@ -20,6 +20,7 @@ var globalSpins = 0
|
|||
var commitCount = "500+"
|
||||
|
||||
var uptime = Date.now()
|
||||
var lastPregen = 0
|
||||
|
||||
var pregenFiles = []
|
||||
|
||||
|
@ -231,6 +232,7 @@ function converter(html, dynamic = true) {
|
|||
"LAST_LANYARD": timeFormatter((Date.now() - api.lastLanyardUpdate) / 1000),
|
||||
"RANDOM_TITLE": titles[Math.floor(Math.random() * titles.length)],
|
||||
"RANDOM_QUOTE": quotes[Math.floor(Math.random() * quotes.length)],
|
||||
"LAST_PREGEN": timeFormatter((Date.now() - lastPregen) / 1000)
|
||||
}
|
||||
|
||||
if (dynamic) {
|
||||
|
@ -353,6 +355,7 @@ updateCommits()
|
|||
|
||||
|
||||
function pregenerate() {
|
||||
lastPregen = Date.now()
|
||||
for (var i = 0; i < pregenFiles.length; i++) {
|
||||
var startTime = Date.now()
|
||||
pregenFiles[i].html = converter(fs.readFileSync(pregenFiles[i].absolutePath).toString(), false)
|
||||
|
@ -362,9 +365,13 @@ function pregenerate() {
|
|||
|
||||
pregenerate()
|
||||
|
||||
api.events.on("lanyardUpdate", async () => {
|
||||
pregenerate()
|
||||
api.events.on("lanyardConnect", pregenerate)
|
||||
|
||||
api.events.on("lanyardUpdate", async () => {
|
||||
if (!api.lanyard.activityChanged) {
|
||||
pregenerate()
|
||||
}
|
||||
|
||||
for (var i = 0; i < api.lanyard.activities.length; i++) {
|
||||
var activity = api.lanyard.activities[i]
|
||||
if (activity.type == 4 && activity.emoji) {
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="noscript">Violet has been spun {SPINCOUNT} times!</p>
|
||||
<!-- <p class="noscript">Violet has been spun {SPINCOUNT} times!</p> -->
|
||||
<p class="spinnyCount" style="display: none;">You have spun Violet <span class="localSpins">4</span> times!<br>
|
||||
Everyone has spun Violet <span class="globalSpins">{SPINCOUNT}</span> times!</p>
|
||||
|
||||
|
|
Loading…
Reference in a new issue