MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / to_representation

Method to_representation

apps/channels/serializers.py:533–548  ·  view source on GitHub ↗
(self, instance)

Source from the content-addressed store, hash-verified

531 }
532
533 def to_representation(self, instance):
534 include_streams = self.context.get("include_streams", False)
535
536 if include_streams:
537 self.fields["streams"] = serializers.SerializerMethodField()
538 return super().to_representation(instance)
539 else:
540 # Read from the prefetched channelstream_set (ordered by the
541 # viewset's Prefetch); chaining .order_by() rebuilds the
542 # queryset and fires one SELECT per row in list responses.
543 representation = super().to_representation(instance)
544 if "streams" in representation:
545 representation["streams"] = [
546 cs.stream_id for cs in instance.channelstream_set.all()
547 ]
548 return representation
549
550 def get_logo(self, obj):
551 return LogoSerializer(obj.logo).data

Callers 1

to_representationMethod · 0.45

Calls 1

getMethod · 0.45

Tested by

no test coverage detected