diff --git a/metrics/metrics.js b/metrics/metrics.js index aac8188..4b6cc1b 100644 --- a/metrics/metrics.js +++ b/metrics/metrics.js @@ -38,20 +38,20 @@ app.post('/metrics', async (req, res) => { } }) -// app.put('/updateMetrics', async (req, res) => { -// try { -// const metrics = await utils.retrieveMetrics(); -// if (new Date().getDay() == 7) { -// metrics.saturdaysCounter++; -// } else { -// metrics.totalCounter++; -// } -// await utils.updateMetrics(metrics); -// res.sendStatus(200); -// } catch(ex) { -// res.status(401).send({ message: 'Failed updating metrics' + ex}); -// } -// }); +app.put('/updateMetrics', async (req, res) => { + try { + const metrics = await utils.retrieveMetrics(); + if (new Date().getDay() == 7) { + metrics.saturdaysCounter++; + } else { + metrics.totalCounter++; + } + await utils.updateMetrics(metrics); + res.sendStatus(200); + } catch(ex) { + res.status(401).send({ message: 'Failed updating metrics' + ex}); + } +}); app.get('/healthz', async (req, res) => { res.status(200); diff --git a/orders/index.js b/orders/index.js index e393505..65f1f69 100644 --- a/orders/index.js +++ b/orders/index.js @@ -52,7 +52,7 @@ fastify.post('/orders', async function (request, reply) { order.state = 'landed' ordersCollection.insertOne(order); reply.send(order.state).code(200); - // await axios.put('http://metrics:3000/updateMetrics') + await axios.put('http://metrics:3000/updateMetrics') }) fastify.get('/orders', async function (request, reply) {