bucket date
This commit is contained in:
1 parent
174665e70a
commit
11c95f885d
8 files changed
+24
-13
No files matched your search
@@ -28,7 +28,7 @@ export const MonitorStatBoxes = ({
|
|||||||
const timeSinceLastFailure =
|
const timeSinceLastFailure =
|
||||||
timeOfLastFailure > 0
|
timeOfLastFailure > 0
|
||||||
? Date.now() - timeOfLastFailure
|
? Date.now() - timeOfLastFailure
|
||||||
: Date.now() - new Date(monitorStats?.createdAt);
|
: Date.now() - new Date(monitorStats?.createdAt || 0).getTime();
|
||||||
|
|
||||||
// Determine time since last check
|
// Determine time since last check
|
||||||
const timeOfLastCheck = monitorStats?.lastCheckTimestamp || 0;
|
const timeOfLastCheck = monitorStats?.lastCheckTimestamp || 0;
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ export const HistogramDetails = ({
|
|||||||
<XAxis
|
<XAxis
|
||||||
axisLine={false}
|
axisLine={false}
|
||||||
tickLine={false}
|
tickLine={false}
|
||||||
dataKey="_id"
|
dataKey="bucketDate"
|
||||||
tick={(props) => (
|
tick={(props) => (
|
||||||
<XTick
|
<XTick
|
||||||
{...props}
|
{...props}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ const XLabel = ({ p1, p2, range }: XLabelProps) => {
|
|||||||
fontSize={11}
|
fontSize={11}
|
||||||
fill={theme.palette.text.secondary}
|
fill={theme.palette.text.secondary}
|
||||||
>
|
>
|
||||||
{formatDateWithTz(p1._id, dateFormat, uiTimezone)}
|
{formatDateWithTz(p1.bucketDate, dateFormat, uiTimezone)}
|
||||||
</text>
|
</text>
|
||||||
<text
|
<text
|
||||||
x="100%"
|
x="100%"
|
||||||
@@ -41,7 +41,7 @@ const XLabel = ({ p1, p2, range }: XLabelProps) => {
|
|||||||
fontSize={11}
|
fontSize={11}
|
||||||
fill={theme.palette.text.secondary}
|
fill={theme.palette.text.secondary}
|
||||||
>
|
>
|
||||||
{formatDateWithTz(p2._id, dateFormat, uiTimezone)}
|
{formatDateWithTz(p2.bucketDate, dateFormat, uiTimezone)}
|
||||||
</text>
|
</text>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
@@ -78,8 +78,8 @@ export const HistogramStatus = ({
|
|||||||
const titleText = t("common.charts.labels.averageResponseTime");
|
const titleText = t("common.charts.labels.averageResponseTime");
|
||||||
const fmt = range === "30d" ? "MMM D, YYYY" : "ddd, MMM D, YYYY, h:mm A";
|
const fmt = range === "30d" ? "MMM D, YYYY" : "ddd, MMM D, YYYY, h:mm A";
|
||||||
let dateLabel = "";
|
let dateLabel = "";
|
||||||
if (d?._id) {
|
if (d?.bucketDate) {
|
||||||
const base = new Date(d._id);
|
const base = new Date(d.bucketDate);
|
||||||
const midBucket =
|
const midBucket =
|
||||||
range === "30d" ? new Date(base.getTime() + 12 * 60 * 60 * 1000) : base;
|
range === "30d" ? new Date(base.getTime() + 12 * 60 * 60 * 1000) : base;
|
||||||
dateLabel = formatDateWithTz(midBucket.toISOString(), fmt, uiTimezone);
|
dateLabel = formatDateWithTz(midBucket.toISOString(), fmt, uiTimezone);
|
||||||
@@ -151,11 +151,11 @@ export const HistogramStatus = ({
|
|||||||
maxBarSize={7}
|
maxBarSize={7}
|
||||||
background={{ fill: "transparent" }}
|
background={{ fill: "transparent" }}
|
||||||
>
|
>
|
||||||
{checks?.map((groupedCheck) => {
|
{checks?.map((groupedCheck, index) => {
|
||||||
const fillColor = getResponseTimeColor(groupedCheck.avgResponseTime);
|
const fillColor = getResponseTimeColor(groupedCheck.avgResponseTime);
|
||||||
return (
|
return (
|
||||||
<Cell
|
<Cell
|
||||||
key={groupedCheck._id}
|
key={groupedCheck.bucketDate || `check-${index}`}
|
||||||
fill={theme.palette[fillColor].main}
|
fill={theme.palette[fillColor].main}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -53,7 +53,11 @@ const UptimeDetailsPage = () => {
|
|||||||
isLoading: monitorIsLoading,
|
isLoading: monitorIsLoading,
|
||||||
error: monitorError,
|
error: monitorError,
|
||||||
refetch: refetchMonitor,
|
refetch: refetchMonitor,
|
||||||
} = useGet<MonitorDetailsResponse>(monitorDetailsUrl);
|
} = useGet<MonitorDetailsResponse>(
|
||||||
|
monitorDetailsUrl,
|
||||||
|
{},
|
||||||
|
{ refreshInterval: 10000, keepPreviousData: true }
|
||||||
|
);
|
||||||
|
|
||||||
const monitorData = monitorDetailsData?.monitorData;
|
const monitorData = monitorDetailsData?.monitorData;
|
||||||
const monitor = monitorData?.monitor;
|
const monitor = monitorData?.monitor;
|
||||||
|
|||||||
@@ -88,7 +88,11 @@ const UptimeMonitorsPage = () => {
|
|||||||
data: monitors,
|
data: monitors,
|
||||||
isLoading: monitorsLoading,
|
isLoading: monitorsLoading,
|
||||||
error,
|
error,
|
||||||
} = useGet<Monitor[]>("/monitors/team?type=http&type=ping&type=port&type=docker");
|
} = useGet<Monitor[]>(
|
||||||
|
"/monitors/team?type=http&type=ping&type=port&type=docker",
|
||||||
|
{},
|
||||||
|
{ keepPreviousData: true }
|
||||||
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: monitorsWithChecksData,
|
data: monitorsWithChecksData,
|
||||||
@@ -98,7 +102,7 @@ const UptimeMonitorsPage = () => {
|
|||||||
} = useGet<MonitorsWithChecksResponse>(
|
} = useGet<MonitorsWithChecksResponse>(
|
||||||
monitorsWithChecksUrl,
|
monitorsWithChecksUrl,
|
||||||
{},
|
{},
|
||||||
{ refreshInterval: 5000 }
|
{ refreshInterval: 5000, keepPreviousData: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
const { monitors: monitorsWithChecks, summary, count } = monitorsWithChecksData ?? {};
|
const { monitors: monitorsWithChecks, summary, count } = monitorsWithChecksData ?? {};
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ export interface Check {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface GroupedCheck {
|
export interface GroupedCheck {
|
||||||
_id: string;
|
bucketDate: string;
|
||||||
avgResponseTime: number;
|
avgResponseTime: number;
|
||||||
totalChecks: number;
|
totalChecks: number;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -483,6 +483,7 @@ class MongoChecksRepository implements IChecksRepository {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ $sort: { _id: 1 } },
|
{ $sort: { _id: 1 } },
|
||||||
|
{ $project: { bucketDate: "$_id", avgResponseTime: 1, totalChecks: 1, _id: 0 } },
|
||||||
],
|
],
|
||||||
groupedUpChecks: [
|
groupedUpChecks: [
|
||||||
{ $match: { status: true } },
|
{ $match: { status: true } },
|
||||||
@@ -496,6 +497,7 @@ class MongoChecksRepository implements IChecksRepository {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ $sort: { _id: 1 } },
|
{ $sort: { _id: 1 } },
|
||||||
|
{ $project: { bucketDate: "$_id", avgResponseTime: 1, totalChecks: 1, _id: 0 } },
|
||||||
],
|
],
|
||||||
groupedDownChecks: [
|
groupedDownChecks: [
|
||||||
{ $match: { status: false } },
|
{ $match: { status: false } },
|
||||||
@@ -509,6 +511,7 @@ class MongoChecksRepository implements IChecksRepository {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ $sort: { _id: 1 } },
|
{ $sort: { _id: 1 } },
|
||||||
|
{ $project: { bucketDate: "$_id", avgResponseTime: 1, totalChecks: 1, _id: 0 } },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ export interface HardwareChecksResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface GroupedCheck {
|
export interface GroupedCheck {
|
||||||
_id: string;
|
bucketDate: string;
|
||||||
avgResponseTime: number;
|
avgResponseTime: number;
|
||||||
totalChecks: number;
|
totalChecks: number;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user