Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🕒 Zeitzonen-Problem behoben #686

Merged
merged 4 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ RUN mv /myspeed/client/build /myspeed

FROM node:18-alpine

RUN apk add --no-cache tzdata

ENV NODE_ENV=production
ENV TZ=Etc/UTC

WORKDIR /myspeed

Expand Down
7 changes: 5 additions & 2 deletions client/src/pages/Statistics/charts/PingChart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ const chartOptions = {
};

const SpeedChart = (props) => {
const testTime = localStorage.getItem("testTime") || 1;
const chartData = {
labels: props.labels,
labels: testTime < 3 ? props.labels.map((label) => new Date(label).toLocaleTimeString([],
{hour: "2-digit", minute: "2-digit"})) : props.labels.slice(1).map((label) =>
new Date(label).toLocaleDateString()),
datasets: [
{
label: t("latest.ping"),
data: props.data.ping,
data: testTime < 3 ? props.data.ping : props.data.ping.slice(1),
borderColor: '#45C65A',
},
],
Expand Down
17 changes: 14 additions & 3 deletions client/src/pages/Statistics/charts/SpeedChart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,22 @@ const chartOptions = {
};

const SpeedChart = (props) => {
const testTime = localStorage.getItem("testTime") || 1;
const chartData = {
labels: props.labels,
labels: testTime < 3 ? props.labels.map((label) => new Date(label).toLocaleTimeString([],
{hour: "2-digit", minute: "2-digit"})) : props.labels.slice(1).map((label) =>
new Date(label).toLocaleDateString()),
datasets: [
{label: t("latest.down"), data: props.data.download, borderColor: '#45C65A'},
{label: t("latest.up"), data: props.data.upload, borderColor: '#456AC6'},
{
label: t("latest.down"),
data: testTime < 3 ? props.data.download : props.data.download.slice(1),
borderColor: '#45C65A'
},
{
label: t("latest.up"),
data: testTime < 3 ? props.data.upload : props.data.upload.slice(1),
borderColor: '#456AC6'
},
],
};

Expand Down
6 changes: 3 additions & 3 deletions server/controller/speedtests.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ module.exports.listAverage = async (days) => {
time: Math.round(avgNumbers["time"]),
type: "average",
amount: currentDay.length,
created: created.getFullYear() + "-" + (created.getMonth() + 1) + "-" + created.getDate()
created: created.toISOString()
});
}

Expand Down Expand Up @@ -124,8 +124,8 @@ module.exports.listStatistics = async (days) => {
upload: mapFixed(notFailed, "upload"),
time: mapRounded(notFailed, "time"),
data,
labels: days >= 3 ? avgEntries.map((entry) => new Date(entry.created).toLocaleDateString())
: notFailed.map((entry) => new Date(entry.created).toLocaleTimeString([], {hour: "2-digit", minute: "2-digit"}))
labels: days >= 3 ? avgEntries.map((entry) => new Date(entry.created).toISOString())
: notFailed.map((entry) => new Date(entry.created).toISOString())
};
}

Expand Down