From f24fc3396dfb92b6e97f12b6630b25023c0db820 Mon Sep 17 00:00:00 2001 From: Ben White Date: Tue, 2 Jan 2024 12:48:54 +0100 Subject: [PATCH] Fixes and added comments to important changes --- .../panels/activity/SidePanelActivity.tsx | 2 +- .../components/ActivityLog/activityLogLogic.tsx | 3 ++- frontend/src/toolbar/actions/ActionsListView.tsx | 2 +- posthog/api/activity_log.py | 16 ++++++++++++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/frontend/src/layout/navigation-3000/sidepanel/panels/activity/SidePanelActivity.tsx b/frontend/src/layout/navigation-3000/sidepanel/panels/activity/SidePanelActivity.tsx index 36aa0a6304d75..a870c73e50e7d 100644 --- a/frontend/src/layout/navigation-3000/sidepanel/panels/activity/SidePanelActivity.tsx +++ b/frontend/src/layout/navigation-3000/sidepanel/panels/activity/SidePanelActivity.tsx @@ -182,7 +182,7 @@ export const SidePanelActivity = (): JSX.Element => {
- + {activeTab === SidePanelActivityTab.Unread ? ( <> {importantChangesLoading && !hasNotifications ? ( diff --git a/frontend/src/lib/components/ActivityLog/activityLogLogic.tsx b/frontend/src/lib/components/ActivityLog/activityLogLogic.tsx index 7f24ddd22ed49..f5045c5a1f8be 100644 --- a/frontend/src/lib/components/ActivityLog/activityLogLogic.tsx +++ b/frontend/src/lib/components/ActivityLog/activityLogLogic.tsx @@ -4,6 +4,7 @@ import { router, urlToAction } from 'kea-router' import api, { ActivityLogPaginatedResponse } from 'lib/api' import { ActivityLogItem, + defaultDescriber, Describer, humanize, HumanizedActivityLogItem, @@ -44,7 +45,7 @@ export const describerFor = (logItem?: ActivityLogItem): Describer | undefined = case ActivityScope.NOTEBOOK: return notebookActivityDescriber default: - return undefined + return (logActivity) => defaultDescriber(logActivity) } } diff --git a/frontend/src/toolbar/actions/ActionsListView.tsx b/frontend/src/toolbar/actions/ActionsListView.tsx index 82bcdfd710e75..d2ef9983ce824 100644 --- a/frontend/src/toolbar/actions/ActionsListView.tsx +++ b/frontend/src/toolbar/actions/ActionsListView.tsx @@ -14,7 +14,7 @@ export function ActionsListView({ actions }: ActionsListViewProps): JSX.Element const { allActionsLoading, searchTerm } = useValues(actionsLogic) const { selectAction } = useActions(actionsTabLogic) return ( -
+
{allActionsLoading ? (
diff --git a/posthog/api/activity_log.py b/posthog/api/activity_log.py index 82f82ca1ce6c6..90cd4584e703b 100644 --- a/posthog/api/activity_log.py +++ b/posthog/api/activity_log.py @@ -11,6 +11,7 @@ from posthog.api.routing import StructuredViewSetMixin from posthog.api.shared import UserBasicSerializer from posthog.models import ActivityLog, FeatureFlag, Insight, NotificationViewed, User +from posthog.models.comment import Comment from posthog.models.notebook.notebook import Notebook @@ -81,6 +82,7 @@ def important_changes(self, request: Request, *args: Any, **kwargs: Any) -> Resp FeatureFlag.objects.filter(created_by=user, team_id=self.team.pk).values_list("id", flat=True) ) my_notebooks = list(Notebook.objects.filter(created_by=user, team_id=self.team.pk).values_list("id", flat=True)) + my_comments = list(Comment.objects.filter(created_by=user, team_id=self.team.pk).values_list("id", flat=True)) # then things they edited interesting_changes = [ @@ -89,6 +91,7 @@ def important_changes(self, request: Request, *args: Any, **kwargs: Any) -> Resp "sharing enabled", "sharing disabled", "deleted", + "commented", ] my_changed_insights = list( ActivityLog.objects.filter( @@ -123,6 +126,17 @@ def important_changes(self, request: Request, *args: Any, **kwargs: Any) -> Resp .values_list("item_id", flat=True) ) + my_changed_comments = list( + ActivityLog.objects.filter( + team_id=self.team.id, + activity__in=interesting_changes, + user_id=user.pk, + scope="Comment", + ) + .exclude(item_id__in=my_comments) + .values_list("item_id", flat=True) + ) + last_read_date = NotificationViewed.objects.filter(user=user).first() last_read_filter = "" @@ -160,6 +174,7 @@ def important_changes(self, request: Request, *args: Any, **kwargs: Any) -> Resp Q(Q(scope="FeatureFlag") & Q(item_id__in=my_feature_flags)) | Q(Q(scope="Insight") & Q(item_id__in=my_insights)) | Q(Q(scope="Notebook") & Q(item_id__in=my_notebooks)) + | Q(Q(scope="Comment") & Q(item_id__in=my_comments)) ) | Q( # don't want to see creation of these things since that was before the user edited these things @@ -168,6 +183,7 @@ def important_changes(self, request: Request, *args: Any, **kwargs: Any) -> Resp Q(Q(scope="FeatureFlag") & Q(item_id__in=my_changed_feature_flags)) | Q(Q(scope="Insight") & Q(item_id__in=my_changed_insights)) | Q(Q(scope="Notebook") & Q(item_id__in=my_changed_notebooks)) + | Q(Q(scope="Comment") & Q(item_id__in=my_changed_comments)) ) ) )