3 Commits

Author SHA1 Message Date
Lee
41c28168e9 Update README.md
All checks were successful
Publish Docker Image / docker (push) Successful in 3m48s
2023-12-31 01:09:07 +00:00
565b533ad4 format peak time frame properly
Some checks failed
Publish Docker Image / docker (push) Has been cancelled
2023-12-31 01:07:32 +00:00
5c5e44ad20 fix db location
All checks were successful
Publish Docker Image / docker (push) Successful in 5m6s
2023-12-31 00:13:39 +00:00
5 changed files with 40 additions and 9 deletions

View File

@ -4,7 +4,7 @@
# Minetrack # Minetrack
Minetrack makes it easy to keep an eye on your favorite Minecraft servers. Simple and hackable, Minetrack easily runs on any hardware. Use it for monitoring, analytics, or just for fun. [Check it out](https://minetrack.me). Minetrack makes it easy to keep an eye on your favorite Minecraft servers. Simple and hackable, Minetrack easily runs on any hardware. Use it for monitoring, analytics, or just for fun. [Check it out](https://mc.fascinated.cc/).
### This project is not actively supported ### This project is not actively supported

View File

@ -4,8 +4,8 @@
"ip": "0.0.0.0" "ip": "0.0.0.0"
}, },
"rates": { "rates": {
"pingAll": 15000, "pingAll": 30000,
"connectTimeout": 10000 "connectTimeout": 5000
}, },
"oldPingsCleanup": { "oldPingsCleanup": {
"enabled": false, "enabled": false,
@ -13,6 +13,6 @@
}, },
"logFailedPings": true, "logFailedPings": true,
"logToDatabase": true, "logToDatabase": true,
"graphDuration": 86400000, "graphDuration": 604800000,
"serverGraphDuration": 180000 "serverGraphDuration": 360000
} }

View File

@ -10,11 +10,11 @@ services:
- 8.8.8.8 - 8.8.8.8
- 1.1.1.1 - 1.1.1.1
ports: ports:
- "8080:8080" - "8880:8080"
volumes: volumes:
# Copy these from the git repo # Copy these from the git repo
- ./servers.json:/usr/src/minetrack/servers.json - ./servers.json:/usr/src/minetrack/servers.json
- ./config.json:/usr/src/minetrack/config.json - ./config.json:/usr/src/minetrack/config.json
- ./data:/data # The sqlite database will be stored here - ./data:/usr/src/minetrack/data # The sqlite database will be stored here
restart: always restart: always

View File

@ -6,6 +6,7 @@ const MessageOf = require("./message");
const config = require("../config"); const config = require("../config");
const minecraftVersions = require("../minecraft_versions"); const minecraftVersions = require("../minecraft_versions");
const { formatMsToTime } = require("./utils/timeUtils");
class App { class App {
serverRegistrations = []; serverRegistrations = [];
@ -74,9 +75,11 @@ class App {
// Send configuration data for rendering the page // Send configuration data for rendering the page
return { return {
// graphDurationLabel:
// config.graphDurationLabel ||
// Math.floor(config.graphDuration / (60 * 60 * 1000)) + "h",
graphDurationLabel: graphDurationLabel:
config.graphDurationLabel || config.graphDurationLabel || formatMsToTime(config.graphDuration),
Math.floor(config.graphDuration / (60 * 60 * 1000)) + "h",
graphMaxLength: TimeTracker.getMaxGraphDataLength(), graphMaxLength: TimeTracker.getMaxGraphDataLength(),
serverGraphMaxLength: TimeTracker.getMaxServerGraphDataLength(), serverGraphMaxLength: TimeTracker.getMaxServerGraphDataLength(),
servers: this.serverRegistrations.map((serverRegistration) => servers: this.serverRegistrations.map((serverRegistration) =>

28
lib/utils/timeUtils.js Normal file
View File

@ -0,0 +1,28 @@
/**
* Formats a time in milliseconds to a human readable format
* eg: 1000ms -> 1s or 60000ms -> 1m
*
* @param ms the time in milliseconds
* @returns the formatted time
*/
function formatMsToTime(ms) {
// this is really fucking shitty but it works!
const seconds = Math.floor(ms / 1000);
const minutes = Math.floor(seconds / 60);
const hours = Math.floor(minutes / 60);
const days = Math.floor(hours / 24);
if (days > 0) {
return `${days}d`;
} else if (hours > 0) {
return `${hours}h`;
} else if (minutes > 0) {
return `${minutes}m`;
} else {
return `${seconds}s`;
}
}
module.exports = {
formatMsToTime,
};