Skip to content

Commit 561df37

Browse files
authored
Don't populate list with null tag (#280)
1 parent 60ec1c5 commit 561df37

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

bats_ai/core/views/recording.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,13 @@ def get_recordings(request: HttpRequest, public: bool | None = None):
252252
recordings = (
253253
Recording.objects.filter(public=True)
254254
.exclude(Q(owner=request.user) | Q(spectrogram__isnull=True))
255-
.annotate(tags_text=ArrayAgg('tags__text'))
255+
.annotate(tags_text=ArrayAgg('tags__text', filter=Q(tags__text__isnull=False)))
256256
.values()
257257
)
258258
else:
259259
recordings = (
260260
Recording.objects.filter(owner=request.user)
261-
.annotate(tags_text=ArrayAgg('tags__text'))
261+
.annotate(tags_text=ArrayAgg('tags__text', filter=Q(tags__text__isnull=False)))
262262
.values()
263263
)
264264

@@ -298,7 +298,9 @@ def get_recording(request: HttpRequest, id: int):
298298
# Filter recordings based on the owner's id or public=True
299299
try:
300300
recordings = (
301-
Recording.objects.filter(pk=id).annotate(tags_text=ArrayAgg('tags__text')).values()
301+
Recording.objects.filter(pk=id)
302+
.annotate(tags_text=ArrayAgg('tags__text', filter=Q(tags__text__isnull=False)))
303+
.values()
302304
)
303305
if len(recordings) > 0:
304306
recording = recordings[0]

0 commit comments

Comments
 (0)