From 75a3788316bb19f11541e6e6d8d54e769b63b483 Mon Sep 17 00:00:00 2001 From: Andrey Vertiprahov Date: Mon, 2 May 2022 14:31:43 +0000 Subject: [PATCH] Merge branch 'fix-avs-isrege-label-migration' into 'master' Add migrate is_regex to is_matching field in Label. See merge request noc/noc!6272 (cherry picked from commit ef62aadfbab9b75fd4d68cefa852b422adc35a43) e0b4c5ca Add migrate is_regex to is_matching field in Label. --- .../0064_migrate_is_matching_labels.py | 16 ++++++++++++++++ main/models/label.py | 2 +- ui/web/main/label/Application.js | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 main/migrations/0064_migrate_is_matching_labels.py diff --git a/main/migrations/0064_migrate_is_matching_labels.py b/main/migrations/0064_migrate_is_matching_labels.py new file mode 100644 index 0000000000..47dc622684 --- /dev/null +++ b/main/migrations/0064_migrate_is_matching_labels.py @@ -0,0 +1,16 @@ +# ---------------------------------------------------------------------- +# Migrate is_regex to is_matching field +# ---------------------------------------------------------------------- +# Copyright (C) 2007-2022 The NOC Project +# See LICENSE for details +# ---------------------------------------------------------------------- + +# NOC modules +from noc.core.migration.base import BaseMigration + + +class Migration(BaseMigration): + depends_on = [("main", "0063_migrate_filter_labels")] + + def migrate(self): + self.mongo_db["labels"].update_many({"is_regex": True}, {"$set": {"is_matching": True}}) diff --git a/main/models/label.py b/main/models/label.py index 2e66464d6d..094b11dc36 100644 --- a/main/models/label.py +++ b/main/models/label.py @@ -1176,7 +1176,7 @@ class Label(Document): """ rxs = [] for ll in Label.objects.filter( - __raw__={"is_regex": True, "match_regex": {"$elemMatch": {"scope": scope}}} + __raw__={"is_matching": True, "match_regex": {"$elemMatch": {"scope": scope}}} ): for rx in ll.match_regex: if rx.scope == scope: diff --git a/ui/web/main/label/Application.js b/ui/web/main/label/Application.js index 30444052b3..f7bf448c74 100644 --- a/ui/web/main/label/Application.js +++ b/ui/web/main/label/Application.js @@ -280,7 +280,7 @@ Ext.define("NOC.main.label.Application", { value: "{is_matching}", disabled: "{isEnableDisableRx}" }, - boxLabel: __("Regexp Label"), + boxLabel: __("Is Matching Label"), }, { name: "match_regex", -- GitLab