(self)
| 153 | return [Authenticated()] |
| 154 | |
| 155 | def get_queryset(self): |
| 156 | qs = super().get_queryset() |
| 157 | # Exclude streams from inactive M3U accounts |
| 158 | qs = qs.exclude(m3u_account__is_active=False) |
| 159 | |
| 160 | assigned = self.request.query_params.get("assigned") |
| 161 | if assigned is not None: |
| 162 | qs = qs.filter(channels__id=assigned) |
| 163 | |
| 164 | unassigned = self.request.query_params.get("unassigned") |
| 165 | if unassigned and str(unassigned).lower() in ("1", "true", "yes", "on"): |
| 166 | # Use annotation with Count for better performance on large datasets |
| 167 | qs = qs.annotate(channel_count=Count('channels')).filter(channel_count=0) |
| 168 | |
| 169 | channel_group = self.request.query_params.get("channel_group") |
| 170 | if channel_group: |
| 171 | group_names = channel_group.split(",") |
| 172 | qs = qs.filter(channel_group__name__in=group_names) |
| 173 | |
| 174 | # Allow client to hide stale streams (streams marked as is_stale=True) |
| 175 | hide_stale = self.request.query_params.get("hide_stale") |
| 176 | if hide_stale and str(hide_stale).lower() in ("1", "true", "yes", "on"): |
| 177 | qs = qs.filter(is_stale=False) |
| 178 | |
| 179 | return qs |
| 180 | |
| 181 | def list(self, request, *args, **kwargs): |
| 182 | ids = request.query_params.get("ids", None) |
no test coverage detected