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

Include the Workloads info in the stats view in the dashboard and the stats project. #2848

Merged
merged 2 commits into from
Jun 4, 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
1 change: 1 addition & 0 deletions packages/gridproxy_client/src/modules/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface Stats {
gateways: number;
twins: number;
contracts: number;
workloads_number: number;
nodesDistribution: { [key: string]: number };
dedicatedNodes: number;
}
Expand Down
1 change: 1 addition & 0 deletions packages/playground/src/views/stats.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ const fetchData = async () => {
{ data: stats!.twins, title: "Twins", icon: "mdi-brain" },
{ data: stats!.publicIps, title: "Public IPs", icon: "mdi-access-point" },
{ data: stats!.contracts, title: "Contracts", icon: "mdi-file-document-edit-outline" },
{ data: stats!.workloads_number, title: "Number of workloads", icon: "mdi-state-machine" },
];

loading.value = false;
Expand Down
1 change: 1 addition & 0 deletions packages/stats/src/components/stats_table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const Istats = computed((): IStatistics[] => {
{ data: formattedStats.value.twins, title: "Twins", icon: "mdi-brain" },
{ data: formattedStats.value.publicIps, title: "Public IPs", icon: "mdi-access-point" },
{ data: formattedStats.value.contracts, title: "Contracts", icon: "mdi-file-document-edit-outline" },
{ data: formattedStats.value.workloads_number, title: "Number of workloads", icon: "mdi-state-machine" },
];
}
});
Expand Down
5 changes: 5 additions & 0 deletions packages/stats/src/utils/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { NetworkStats } from "@/types";
function mergeAllStatsData(stats: Stats[]): Stats {
const res = stats[0];
for (let i = 1; i < stats.length; i++) {
const workloads = isNaN(stats[i].workloads_number) ? 0 : stats[i].workloads_number;
res.accessNodes += stats[i].accessNodes;
res.dedicatedNodes += stats[i].dedicatedNodes;
res.contracts += stats[i].contracts;
Expand All @@ -20,6 +21,7 @@ function mergeAllStatsData(stats: Stats[]): Stats {
res.twins += stats[i].twins;
res.nodesDistribution = mergeNodeDistribution([res.nodesDistribution, stats[i].nodesDistribution]);
res.countries = Object.keys(res.nodesDistribution).length;
res.workloads_number += workloads;
}

return res;
Expand All @@ -28,6 +30,7 @@ function mergeAllStatsData(stats: Stats[]): Stats {
function mergeStatsData(stats: Stats[]): Stats {
const res = stats[0];
for (let i = 1; i < stats.length; i++) {
const workloads = isNaN(stats[i].workloads_number) ? 0 : stats[i].workloads_number;
res.accessNodes += stats[i].accessNodes;
res.dedicatedNodes += stats[i].dedicatedNodes;
res.gateways += stats[i].gateways;
Expand All @@ -39,6 +42,7 @@ function mergeStatsData(stats: Stats[]): Stats {
res.gpus += stats[i].gpus;
res.nodesDistribution = mergeNodeDistribution([res.nodesDistribution, stats[i].nodesDistribution]);
res.countries = Object.keys(res.nodesDistribution).length;
res.workloads_number += workloads;
}
return res;
}
Expand Down Expand Up @@ -86,6 +90,7 @@ export function formatData(network: string[] = ["main"], totalStat: NetworkStats
contracts: 0,
nodesDistribution: {},
dedicatedNodes: 0,
workloads_number: 0,
};
for (let i = 0; i < network.length; i++) {
const currentStats = totalStat[network[i]];
Expand Down
Loading