Browse Source

[ref] rename snooze/mute to ignore (#4318)

* [ref] rename snooze/mute to ignore

* language

* fix remaining ref to snooze
David Cramer 8 years ago
parent
commit
9a74b0dbbf

+ 4 - 1
src/sentry/api/endpoints/group_details.py

@@ -59,6 +59,9 @@ class GroupSerializer(serializers.Serializer):
     isSubscribed = serializers.BooleanField()
     hasSeen = serializers.BooleanField()
     assignedTo = UserField()
+    ignoreDuration = serializers.IntegerField()
+
+    # TODO(dcramer): remove in 9.0
     snoozeDuration = serializers.IntegerField()
 
 
@@ -245,7 +248,7 @@ class GroupDetailsEndpoint(GroupEndpoint):
         :pparam string issue_id: the ID of the group to retrieve.
         :param string status: the new status for the groups.  Valid values
                               are ``"resolved"``, ``"unresolved"`` and
-                              ``"muted"``.
+                              ``"ignored"``.
         :param string assignedTo: the username of the user that should be
                                assigned to this issue.
         :param boolean hasSeen: in case this API call is invoked with a user

+ 25 - 16
src/sentry/api/endpoints/project_group_index.py

@@ -67,8 +67,11 @@ def list_project_issues_scenario(runner):
 STATUS_CHOICES = {
     'resolved': GroupStatus.RESOLVED,
     'unresolved': GroupStatus.UNRESOLVED,
-    'muted': GroupStatus.MUTED,
+    'ignored': GroupStatus.IGNORED,
     'resolvedInNextRelease': GroupStatus.UNRESOLVED,
+
+    # TODO(dcramer): remove in 9.0
+    'muted': GroupStatus.IGNORED,
 }
 
 
@@ -85,6 +88,9 @@ class GroupSerializer(serializers.Serializer):
     isPublic = serializers.BooleanField()
     isSubscribed = serializers.BooleanField()
     merge = serializers.BooleanField()
+    ignoreDuration = serializers.IntegerField()
+
+    # TODO(dcramer): remove in 9.0
     snoozeDuration = serializers.IntegerField()
 
 
@@ -283,15 +289,15 @@ class ProjectGroupIndexEndpoint(ProjectEndpoint):
         :qparam string status: optionally limits the query to issues of the
                                specified status.  Valid values are
                                ``"resolved"``, ``"unresolved"`` and
-                               ``"muted"``.
+                               ``"ignored"``.
         :pparam string organization_slug: the slug of the organization the
                                           issues belong to.
         :pparam string project_slug: the slug of the project the issues
                                      belong to.
         :param string status: the new status for the issues.  Valid values
                               are ``"resolved"``, ``"unresolved"`` and
-                              ``"muted"``.
-        :param int snoozeDuration: the number of minutes to mute this issue.
+                              ``"ignored"``.
+        :param int ignoreDuration: the number of minutes to ignore this issue.
         :param boolean isPublic: sets the issue to public or private.
         :param boolean merge: allows to merge or unmerge different issues.
         :param boolean hasSeen: in case this API call is invoked with a user
@@ -451,27 +457,30 @@ class ProjectGroupIndexEndpoint(ProjectEndpoint):
                 group__in=group_ids,
             ).delete()
 
-            if new_status == GroupStatus.MUTED:
-                snooze_duration = result.pop('snoozeDuration', None)
-                if snooze_duration:
-                    snooze_until = timezone.now() + timedelta(
-                        minutes=snooze_duration,
+            if new_status == GroupStatus.IGNORED:
+                ignore_duration = (
+                    result.pop('ignoreDuration', None)
+                    or result.pop('snoozeDuration', None)
+                )
+                if ignore_duration:
+                    ignore_until = timezone.now() + timedelta(
+                        minutes=ignore_duration,
                     )
                     for group in group_list:
                         GroupSnooze.objects.create_or_update(
                             group=group,
                             values={
-                                'until': snooze_until,
+                                'until': ignore_until,
                             }
                         )
                         result['statusDetails'] = {
-                            'snoozeUntil': snooze_until,
+                            'ignoreUntil': ignore_until,
                         }
                 else:
                     GroupSnooze.objects.filter(
                         group__in=group_ids,
                     ).delete()
-                    snooze_until = None
+                    ignore_until = None
                     result['statusDetails'] = {}
             else:
                 result['statusDetails'] = {}
@@ -480,11 +489,11 @@ class ProjectGroupIndexEndpoint(ProjectEndpoint):
                 if new_status == GroupStatus.UNRESOLVED:
                     activity_type = Activity.SET_UNRESOLVED
                     activity_data = {}
-                elif new_status == GroupStatus.MUTED:
-                    activity_type = Activity.SET_MUTED
+                elif new_status == GroupStatus.IGNORED:
+                    activity_type = Activity.SET_IGNORED
                     activity_data = {
-                        'snoozeUntil': snooze_until,
-                        'snoozeDuration': snooze_duration,
+                        'ignoreUntil': ignore_until,
+                        'ignoreDuration': ignore_duration,
                     }
 
                 for group in group_list:

+ 7 - 7
src/sentry/api/serializers/models/group.py

@@ -80,7 +80,7 @@ class GroupSerializer(Serializer):
             ).values_list('group', 'values_seen')
         )
 
-        snoozes = dict(
+        ignore_durations = dict(
             GroupSnooze.objects.filter(
                 group__in=item_list,
             ).values_list('group', 'until')
@@ -112,7 +112,7 @@ class GroupSerializer(Serializer):
                 'has_seen': seen_groups.get(item.id, active_date) > active_date,
                 'annotations': annotations,
                 'user_count': user_counts.get(item.id, 0),
-                'snooze': snoozes.get(item.id),
+                'ignore_duration': ignore_durations.get(item.id),
                 'pending_resolution': pending_resolutions.get(item.id),
             }
         return result
@@ -120,11 +120,11 @@ class GroupSerializer(Serializer):
     def serialize(self, obj, attrs, user):
         status = obj.status
         status_details = {}
-        if attrs['snooze']:
-            if attrs['snooze'] < timezone.now() and status == GroupStatus.MUTED:
+        if attrs['ignore_duration']:
+            if attrs['ignore_duration'] < timezone.now() and status == GroupStatus.IGNORED:
                 status = GroupStatus.UNRESOLVED
             else:
-                status_details['snoozeUntil'] = attrs['snooze']
+                status_details['ignoreUntil'] = attrs['ignore_duration']
         elif status == GroupStatus.UNRESOLVED and obj.is_over_resolve_age():
             status = GroupStatus.RESOLVED
             status_details['autoResolved'] = True
@@ -132,8 +132,8 @@ class GroupSerializer(Serializer):
             status_label = 'resolved'
             if attrs['pending_resolution']:
                 status_details['inNextRelease'] = True
-        elif status == GroupStatus.MUTED:
-            status_label = 'muted'
+        elif status == GroupStatus.IGNORED:
+            status_label = 'ignored'
         elif status in [GroupStatus.PENDING_DELETION, GroupStatus.DELETION_IN_PROGRESS]:
             status_label = 'pending_deletion'
         elif status == GroupStatus.PENDING_MERGE:

+ 5 - 2
src/sentry/constants.py

@@ -50,12 +50,15 @@ SEARCH_SORT_OPTIONS = OrderedDict((
 # XXX: Deprecated: use GroupStatus instead
 STATUS_UNRESOLVED = 0
 STATUS_RESOLVED = 1
-STATUS_MUTED = 2
+STATUS_IGNORED = 2
 
 STATUS_CHOICES = {
     'resolved': STATUS_RESOLVED,
     'unresolved': STATUS_UNRESOLVED,
-    'muted': STATUS_MUTED,
+    'ignored': STATUS_IGNORED,
+
+    # TODO(dcramer): remove in 9.0
+    'muted': STATUS_IGNORED,
 }
 
 # Normalize counts to the 15 minute marker. This value MUST be less than 60. A

+ 1 - 1
src/sentry/event_manager.py

@@ -847,7 +847,7 @@ class EventManager(object):
         is_regression = bool(Group.objects.filter(
             id=group.id,
             # ensure we cant update things if the status has been set to
-            # muted
+            # ignored
             status__in=[GroupStatus.RESOLVED, GroupStatus.UNRESOLVED],
         ).exclude(
             # add to the regression window to account for races here

+ 2 - 2
src/sentry/models/activity.py

@@ -26,7 +26,7 @@ class Activity(Model):
 
     SET_RESOLVED = 1
     SET_UNRESOLVED = 2
-    SET_MUTED = 3
+    SET_IGNORED = 3
     SET_PUBLIC = 4
     SET_PRIVATE = 5
     SET_REGRESSION = 6
@@ -46,7 +46,7 @@ class Activity(Model):
         (SET_RESOLVED_BY_AGE, 'set_resolved_by_age'),
         (SET_RESOLVED_IN_RELEASE, 'set_resolved_in_release'),
         (SET_UNRESOLVED, 'set_unresolved'),
-        (SET_MUTED, 'set_muted'),
+        (SET_IGNORED, 'set_ignored'),
         (SET_PUBLIC, 'set_public'),
         (SET_PRIVATE, 'set_private'),
         (SET_REGRESSION, 'set_regression'),

+ 12 - 6
src/sentry/models/group.py

@@ -48,11 +48,14 @@ def looks_like_short_id(value):
 class GroupStatus(object):
     UNRESOLVED = 0
     RESOLVED = 1
-    MUTED = 2
+    IGNORED = 2
     PENDING_DELETION = 3
     DELETION_IN_PROGRESS = 4
     PENDING_MERGE = 5
 
+    # TODO(dcramer): remove in 9.0
+    MUTED = IGNORED
+
 
 def get_group_with_redirect(id, queryset=None):
     """
@@ -164,7 +167,7 @@ class Group(Model):
     status = BoundedPositiveIntegerField(default=0, choices=(
         (GroupStatus.UNRESOLVED, _('Unresolved')),
         (GroupStatus.RESOLVED, _('Resolved')),
-        (GroupStatus.MUTED, _('Muted')),
+        (GroupStatus.IGNORED, _('Ignored')),
     ), db_index=True)
     times_seen = BoundedPositiveIntegerField(default=1, db_index=True)
     last_seen = models.DateTimeField(default=timezone.now, db_index=True)
@@ -239,8 +242,11 @@ class Group(Model):
             return False
         return self.last_seen < timezone.now() - timedelta(hours=int(resolve_age))
 
-    def is_muted(self):
-        return self.get_status() == GroupStatus.MUTED
+    def is_ignored(self):
+        return self.get_status() == GroupStatus.IGNORED
+
+    # TODO(dcramer): remove in 9.0 / after plugins no long ref
+    is_muted = is_ignored
 
     def is_resolved(self):
         return self.get_status() == GroupStatus.RESOLVED
@@ -249,7 +255,7 @@ class Group(Model):
         # XXX(dcramer): GroupSerializer reimplements this logic
         from sentry.models import GroupSnooze
 
-        if self.status == GroupStatus.MUTED:
+        if self.status == GroupStatus.IGNORED:
             try:
                 snooze = GroupSnooze.objects.get(group=self)
             except GroupSnooze.DoesNotExist:
@@ -258,7 +264,7 @@ class Group(Model):
                 # XXX(dcramer): if the snooze row exists then we need
                 # to confirm its still valid
                 if snooze.until > timezone.now():
-                    return GroupStatus.MUTED
+                    return GroupStatus.IGNORED
                 else:
                     return GroupStatus.UNRESOLVED
 

+ 3 - 0
src/sentry/models/groupsnooze.py

@@ -5,6 +5,9 @@ from sentry.db.models import Model, FlexibleForeignKey, sane_repr
 
 
 class GroupSnooze(Model):
+    """
+    A snooze marks an issue as ignored for a duration (specified by ``until``).
+    """
     __core__ = False
 
     group = FlexibleForeignKey('sentry.Group', unique=True)

+ 1 - 1
src/sentry/plugins/base/notifier.py

@@ -25,7 +25,7 @@ class Notifier(object):
         """
 
     def should_notify(self, group, event):
-        if group.is_muted():
+        if group.is_ignored():
             return False
 
         project = group.project

+ 1 - 1
src/sentry/plugins/bases/notify.py

@@ -160,7 +160,7 @@ class NotificationPlugin(Plugin):
         if not self.is_configured(project=project):
             return False
 
-        if group.is_muted():
+        if group.is_ignored():
             return False
 
         # If the plugin doesn't support digests or they are not enabled,

Some files were not shown because too many files changed in this diff