From 23f99f6769d48479d97183aab78c2b56fc687f68 Mon Sep 17 00:00:00 2001 From: Fotis Paraskevopoulos Date: Fri, 6 Feb 2026 14:53:03 +0200 Subject: [PATCH] Reverting slo violations --- lib/metric_model.js | 6 +----- modules/application/index.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/lib/metric_model.js b/lib/metric_model.js index f082ba0..3aa69de 100644 --- a/lib/metric_model.js +++ b/lib/metric_model.js @@ -140,11 +140,7 @@ module.exports = { }]; }; - let violations=[] - object.sloViolations.forEach(sloViolation => { - violations.push(...processSloViolations(sloViolation)) - }) - object.sloViolations = violations + object.sloViolations = processSloViolations(object.sloViolations); } let specContent = { diff --git a/modules/application/index.js b/modules/application/index.js index dcd15bc..29e90be 100644 --- a/modules/application/index.js +++ b/modules/application/index.js @@ -537,6 +537,34 @@ module.exports = { console.error("Couldn't run migration ", e) } }); + self.apos.migration.add('fix-slo-violations-revert', async () => { + try { + await self.apos.migration.eachDoc({ + type: 'application', + }, async (doc) => { + if(doc.sloViolations) { + try{ + let creations = "" + if(Array.isArray(doc.sloViolations) && doc.sloViolations.length > 0) { + creations = JSON.stringify(doc.sloViolations[0]) + }else{ + creations = JSON.parse(doc.sloViolations) + if(Array.isArray(creations) && creations.length > 0) { + creations = JSON.stringify(creations[0]) + } + } + await self.apos.doc.db.updateOne({ + _id: doc._id + }, { + $set: {sloViolations: creations}, + }); + }catch (error) {} + } + }); + } catch (e) { + console.error("Couldn't run migration ", e) + } + }); }, handlers(self) {