From 090870b03efb8c99a142a74f1df0b9bc01831809 Mon Sep 17 00:00:00 2001 From: Nikhil <118773738+pablohashescobar@users.noreply.github.com> Date: Mon, 17 Jul 2023 16:09:30 +0530 Subject: [PATCH] fix: created_by notifications (#1534) * chore: add triggered by details for notifications * dev: update issue activity json to include extra fields * dev: remove unused imports and improve the filtering * dev: fix unread filter * dev: fix created_by none when updating the field --- apiserver/plane/api/serializers/notification.py | 1 - apiserver/plane/api/views/issue.py | 1 - apiserver/plane/api/views/notification.py | 3 +++ apiserver/plane/bgtasks/issue_activites_task.py | 10 +++++++--- apiserver/plane/db/models/issue.py | 1 - 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apiserver/plane/api/serializers/notification.py b/apiserver/plane/api/serializers/notification.py index 56dcc0dd8..b6a4f3e4a 100644 --- a/apiserver/plane/api/serializers/notification.py +++ b/apiserver/plane/api/serializers/notification.py @@ -4,7 +4,6 @@ from .user import UserLiteSerializer from plane.db.models import Notification class NotificationSerializer(BaseSerializer): - triggered_by_details = UserLiteSerializer(read_only=True, source="triggered_by") class Meta: diff --git a/apiserver/plane/api/views/issue.py b/apiserver/plane/api/views/issue.py index 476fd4c5a..aab926fd2 100644 --- a/apiserver/plane/api/views/issue.py +++ b/apiserver/plane/api/views/issue.py @@ -45,7 +45,6 @@ from plane.api.serializers import ( IssueLiteSerializer, IssueAttachmentSerializer, IssueSubscriberSerializer, - ProjectMemberSerializer, ProjectMemberLiteSerializer, ) from plane.api.permissions import ( diff --git a/apiserver/plane/api/views/notification.py b/apiserver/plane/api/views/notification.py index 802cbb03f..86cc74d3f 100644 --- a/apiserver/plane/api/views/notification.py +++ b/apiserver/plane/api/views/notification.py @@ -216,6 +216,7 @@ class UnreadNotificationEndpoint(BaseAPIView): watching_notification_count = Notification.objects.filter( workspace__slug=slug, receiver_id=request.user.id, + read_at__isnull=True, entity_identifier__in=IssueSubscriber.objects.filter( workspace__slug=slug, subscriber_id=request.user.id ).values_list("issue_id", flat=True), @@ -225,6 +226,7 @@ class UnreadNotificationEndpoint(BaseAPIView): my_issues_count = Notification.objects.filter( workspace__slug=slug, receiver_id=request.user.id, + read_at__isnull=True, entity_identifier__in=IssueAssignee.objects.filter( workspace__slug=slug, assignee_id=request.user.id ).values_list("issue_id", flat=True), @@ -234,6 +236,7 @@ class UnreadNotificationEndpoint(BaseAPIView): created_issues_count = Notification.objects.filter( workspace__slug=slug, receiver_id=request.user.id, + read_at__isnull=True, entity_identifier__in=Issue.objects.filter( workspace__slug=slug, created_by=request.user ).values_list("pk", flat=True), diff --git a/apiserver/plane/bgtasks/issue_activites_task.py b/apiserver/plane/bgtasks/issue_activites_task.py index abbbb5f5f..2a7c6eddc 100644 --- a/apiserver/plane/bgtasks/issue_activites_task.py +++ b/apiserver/plane/bgtasks/issue_activites_task.py @@ -1028,10 +1028,14 @@ def issue_activity( actor = User.objects.get(pk=actor_id) project = Project.objects.get(pk=project_id) - issue = Issue.objects.filter(pk=issue_id).first() - if issue is not None: + + try: + issue = Issue.objects.get(pk=issue_id) issue.updated_at = timezone.now() - issue.save() + issue.save(update_fields=["updated_at"]) + except Exception as e: + pass + if subscriber: # add the user to issue subscriber diff --git a/apiserver/plane/db/models/issue.py b/apiserver/plane/db/models/issue.py index f301d4191..3e9da02d5 100644 --- a/apiserver/plane/db/models/issue.py +++ b/apiserver/plane/db/models/issue.py @@ -28,7 +28,6 @@ class IssueManager(models.Manager): | models.Q(issue_inbox__status=2) | models.Q(issue_inbox__isnull=True) ) - .filter(archived_at__isnull=True) .exclude(archived_at__isnull=False) )