
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Overview
Migrate PinnedDeviceViewSet from explicit values tuple to serializer-derived pattern as part of the BaseValuesViewset refactor (#14036).
Complexity: Low
Target branch: develop
Context
PinnedDeviceViewSet in kolibri/core/discovery/api.py currently has both serializer_class = PinnedDeviceSerializer and an explicit values = ("instance_id", "id") tuple. It has no field_map, consolidate(), or annotate_queryset() — making it a straightforward migration.
The Change
Remove the explicit values tuple from PinnedDeviceViewSet so that values and field mappings are derived from PinnedDeviceSerializer. Update the serializer if any read-path fields are missing or need source kwargs.
See #14036 for the overall pattern and FacilityUserViewSet in kolibri/core/auth/api.py for a concrete migration example.
Out of Scope
- Changes to the API response shape — the API contract must not change
- Modifications to existing tests — if tests need to change, the migration is wrong
- Write-path changes — only the read serialization path is affected
Acceptance Criteria
Testing
- Before migrating: verify that existing test coverage is adequate. If the viewset has insufficient API tests, write them first to capture the current behavior. Tests must pass before and after migration without modification.
- Benchmark: run the benchmark script before and after the migration using the same data:
python integration_testing/scripts/viewset_serialization_benchmark.py \
kolibri.core.discovery.api.PinnedDeviceViewSet \
--inherit-kolibri-home -o baseline.json
# ... make changes ...
python integration_testing/scripts/viewset_serialization_benchmark.py \
kolibri.core.discovery.api.PinnedDeviceViewSet \
--inherit-kolibri-home --compare baseline.json
- The benchmark comparison must pass — this validates that the data output is identical and there is no performance regression.
- Include the benchmark before/after comparison in the pull request description.
Benchmark data setup (run via kolibri manage shell before benchmarking):
from kolibri.core.discovery.models import PinnedDevice
import uuid
for i in range(100):
PinnedDevice.objects.get_or_create(
instance_id=uuid.uuid4(),
)
References
AI usage
This issue was drafted with Claude Code assistance, reviewed and directed by @rtibbles.
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
Migrate
PinnedDeviceViewSetfrom explicitvaluestuple to serializer-derived pattern as part of theBaseValuesViewsetrefactor (#14036).Complexity: Low
Target branch: develop
Context
PinnedDeviceViewSetinkolibri/core/discovery/api.pycurrently has bothserializer_class = PinnedDeviceSerializerand an explicitvalues = ("instance_id", "id")tuple. It has nofield_map,consolidate(), orannotate_queryset()— making it a straightforward migration.The Change
Remove the explicit
valuestuple fromPinnedDeviceViewSetso that values and field mappings are derived fromPinnedDeviceSerializer. Update the serializer if any read-path fields are missing or needsourcekwargs.See #14036 for the overall pattern and
FacilityUserViewSetinkolibri/core/auth/api.pyfor a concrete migration example.Out of Scope
Acceptance Criteria
valuestuple removed fromPinnedDeviceViewSetPinnedDeviceSerializerhas all read-path fields with correctsourcekwargsTesting
python integration_testing/scripts/viewset_serialization_benchmark.py \ kolibri.core.discovery.api.PinnedDeviceViewSet \ --inherit-kolibri-home -o baseline.json # ... make changes ... python integration_testing/scripts/viewset_serialization_benchmark.py \ kolibri.core.discovery.api.PinnedDeviceViewSet \ --inherit-kolibri-home --compare baseline.jsonBenchmark data setup (run via
kolibri manage shellbefore benchmarking):References
integration_testing/scripts/viewset_serialization_benchmark.pyFacilityUserViewSetinkolibri/core/auth/api.pyAI usage
This issue was drafted with Claude Code assistance, reviewed and directed by @rtibbles.