Skip to content

Commit

Permalink
Fixes and added comments to important changes
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite committed Jan 2, 2024
1 parent 1e32544 commit f24fc33
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export const SidePanelActivity = (): JSX.Element => {
</div>

<div className="flex flex-col flex-1 overflow-hidden" ref={contentRef} onScroll={handleScroll}>
<ScrollableShadows direction="vertical" innerClassName="p-2 space-y-x">
<ScrollableShadows direction="vertical" innerClassName="p-2 space-y-px">
{activeTab === SidePanelActivityTab.Unread ? (
<>
{importantChangesLoading && !hasNotifications ? (
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/lib/components/ActivityLog/activityLogLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { router, urlToAction } from 'kea-router'
import api, { ActivityLogPaginatedResponse } from 'lib/api'
import {
ActivityLogItem,
defaultDescriber,
Describer,
humanize,
HumanizedActivityLogItem,
Expand Down Expand Up @@ -44,7 +45,7 @@ export const describerFor = (logItem?: ActivityLogItem): Describer | undefined =
case ActivityScope.NOTEBOOK:
return notebookActivityDescriber
default:
return undefined
return (logActivity) => defaultDescriber(logActivity)
}
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/toolbar/actions/ActionsListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function ActionsListView({ actions }: ActionsListViewProps): JSX.Element
const { allActionsLoading, searchTerm } = useValues(actionsLogic)
const { selectAction } = useActions(actionsTabLogic)
return (
<div className={'flex flex-col h-full overflow-y-scoll space-y-x'}>
<div className={'flex flex-col h-full overflow-y-scoll space-y-px'}>
{allActionsLoading ? (
<div className={'flex items-center'}>
<Spinner className={'text-4xl'} />
Expand Down
16 changes: 16 additions & 0 deletions posthog/api/activity_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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 = [
Expand All @@ -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(
Expand Down Expand Up @@ -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 = ""

Expand Down Expand Up @@ -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
Expand All @@ -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))
)
)
)
Expand Down

0 comments on commit f24fc33

Please sign in to comment.