diff --git a/src/index.js b/src/index.js
index f1fdf29..02c77cf 100644
--- a/src/index.js
+++ b/src/index.js
@@ -84,4 +84,40 @@ app.get('/api/v1/nodes', async (req, res) => {
}
});
+app.get('/api/v1/stats/hardware-models', async (req, res) => {
+ try {
+
+ // get nodes from db
+ const results = await prisma.node.groupBy({
+ by: ['hardware_model'],
+ orderBy: {
+ _count: {
+ hardware_model: 'desc',
+ },
+ },
+ _count: {
+ hardware_model: true,
+ },
+ });
+
+ const hardwareModelStats = results.map((result) => {
+ return {
+ count: result._count.hardware_model,
+ hardware_model: result.hardware_model,
+ hardware_model_name: HardwareModel.valuesById[result.hardware_model] ?? "UNKNOWN",
+ };
+ });
+
+ res.json({
+ hardware_model_stats: hardwareModelStats,
+ });
+
+ } catch(err) {
+ console.error(err);
+ res.status(500).json({
+ message: "Something went wrong, try again later.",
+ });
+ }
+});
+
app.listen(8080);
diff --git a/src/public/index.html b/src/public/index.html
index 67517cf..526a329 100644
--- a/src/public/index.html
+++ b/src/public/index.html
@@ -24,6 +24,10 @@
+
+
+
+