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

fix(backend): 轮值问题处理 #1553 #1555

Merged
merged 1 commit into from
Oct 28, 2023
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
5 changes: 5 additions & 0 deletions dbm-ui/backend/db_monitor/models/alarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from collections import defaultdict

from django.db import models
from django.db.models import Count
from django.utils.translation import gettext_lazy as _

from backend import env
Expand Down Expand Up @@ -294,6 +295,10 @@ def delete(self, using=None, keep_parents=False):
BKMonitorV3Api.delete_duty_rules({"ids": [self.monitor_duty_rule_id], "bk_biz_ids": [env.DBA_APP_BK_BIZ_ID]})
super().delete()

@classmethod
def priority_distinct(cls) -> list:
return list(cls.objects.values_list("priority", flat=True).distinct().order_by("-priority"))

class Meta:
verbose_name_plural = verbose_name = _("轮值规则")

Expand Down
10 changes: 10 additions & 0 deletions dbm-ui/backend/db_monitor/views/duty_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""
from django.db.models import Count
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext_lazy as _
from rest_framework.decorators import action
from rest_framework.response import Response

from backend.bk_web import viewsets
from backend.bk_web.pagination import AuditedLimitOffsetPagination
from backend.bk_web.swagger import common_swagger_auto_schema
from backend.db_monitor import serializers
from backend.db_monitor.models.alarm import DutyRule
Expand Down Expand Up @@ -58,7 +62,13 @@ class MonitorDutyRuleViewSet(viewsets.AuditedModelViewSet):

queryset = DutyRule.objects.all()
serializer_class = DutyRuleSerializer
pagination_class = AuditedLimitOffsetPagination
filter_fields = {"db_type": ["exact"]}

def _get_custom_permissions(self):
return [GlobalManageIAMPermission()]

@common_swagger_auto_schema(operation_summary=_("轮值规则优先级统计"), tags=[SWAGGER_TAG])
@action(methods=["GET"], detail=False)
def priority_distinct(self, request, *args, **kwargs):
return Response(DutyRule.priority_distinct())
5 changes: 3 additions & 2 deletions dbm-ui/backend/db_monitor/views/notice_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
from django.db.models import Q
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext_lazy as _
from rest_framework import status
from rest_framework.decorators import action
from rest_framework.response import Response

from backend.bk_web import viewsets
from backend.bk_web.pagination import AuditedLimitOffsetPagination
from backend.bk_web.swagger import common_swagger_auto_schema
from backend.components import CCApi, CmsiApi
from backend.components import CmsiApi
from backend.configuration.constants import PLAT_BIZ_ID
from backend.db_monitor import serializers
from backend.db_monitor.models import MonitorPolicy, NoticeGroup
Expand Down Expand Up @@ -83,6 +83,7 @@ class MonitorNoticeGroupViewSet(viewsets.AuditedModelViewSet):

queryset = NoticeGroup.objects.all()
serializer_class = NoticeGroupSerializer
pagination_class = AuditedLimitOffsetPagination
filter_class = MonitorPolicyListFilter

def _get_custom_permissions(self):
Expand Down
2 changes: 1 addition & 1 deletion helm-charts/bk-dbm/charts/dbm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
appVersion: 1.2.0-alpha.412
appVersion: 1.2.0-alpha.418
description: A Helm chart for dbm
name: dbm
type: application
Expand Down
Loading