Skip to content

Commit

Permalink
exclude playlists with no name and no derived name
Browse files Browse the repository at this point in the history
  • Loading branch information
raquelmsmith committed Dec 30, 2024
1 parent 3fb0911 commit 6c8a3d4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
19 changes: 15 additions & 4 deletions posthog/tasks/periodic_digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,21 @@ def get_teams_with_new_event_definitions(end: datetime, begin: datetime) -> Quer


def get_teams_with_new_playlists(end: datetime, begin: datetime) -> QuerySet:
return SessionRecordingPlaylist.objects.filter(
created_at__gt=begin,
created_at__lte=end,
).values("team_id", "name", "short_id", "derived_name")
return (
SessionRecordingPlaylist.objects.filter(
created_at__gt=begin,
created_at__lte=end,
)
.exclude(
name__isnull=True,
derived_name__isnull=True,
)
.exclude(
name="",
derived_name="",
)
.values("team_id", "name", "short_id", "derived_name")
)


def get_teams_with_new_experiments_launched(end: datetime, begin: datetime) -> QuerySet:
Expand Down
15 changes: 6 additions & 9 deletions posthog/tasks/test/test_periodic_digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,17 @@ def test_periodic_digest_report(self, mock_capture: MagicMock) -> None:
team=self.team,
name="Test Playlist",
)
# These should be included in the digest but use the derived name
derived_playlist = SessionRecordingPlaylist.objects.create(
# This should be excluded from the digest because it has no name and no derived name
SessionRecordingPlaylist.objects.create(
team=self.team,
name=None,
derived_name="Derived Playlist",
derived_name=None,
)
derived_playlist_2 = SessionRecordingPlaylist.objects.create(
# This should be included in the digest but use the derived name
derived_playlist = SessionRecordingPlaylist.objects.create(
team=self.team,
name="",
derived_name="Derived Playlist 2",
derived_name="Derived Playlist",
)

# Create experiments
Expand Down Expand Up @@ -170,10 +171,6 @@ def test_periodic_digest_report(self, mock_capture: MagicMock) -> None:
"name": "Derived Playlist",
"id": derived_playlist.short_id,
},
{
"name": "Derived Playlist 2",
"id": derived_playlist_2.short_id,
},
],
"new_experiments_launched": [
{
Expand Down

0 comments on commit 6c8a3d4

Please sign in to comment.