Migrate the channel metadata viewsets to serializer derivation - #15180
Open
rtibblesbot wants to merge 7 commits into
Open
Migrate the channel metadata viewsets to serializer derivation#15180rtibblesbot wants to merge 7 commits into
rtibblesbot wants to merge 7 commits into
Conversation
Contributor
Build Artifacts
Smoke test screenshot |
rtibblesbot
force-pushed
the
issue-14312-87cd34
branch
2 times, most recently
from
August 12, 2026 02:28
9c72527 to
8adce42
Compare
rtibblesbot
marked this pull request as ready for review
August 12, 2026 02:54
The internal and public channel endpoints have no assertions on included_languages, included_categories, included_grade_levels, last_published, thumbnail or record order, and the public one has no API tests at all. These pin current behaviour and must pass unchanged after the migration. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Replaces the _split_text_field lambdas the channel viewsets pass through field_map. learningequality#14300 needs the same field for ContentNode. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
BaseChannelMetadataMixin drops its values tuple and field_map for a serializer pair: the public viewset keeps the raw thumbnail column, the internal one overrides it with the URL. included_languages stays in consolidate(). A SQL array aggregate loses the sort_value order SortedManyToManyField gives the relation, and the GROUP BY it needs would also drop Meta.ordering on Django 3.2. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Its only consumer was the device plugin's viewset, a plain ReadOnlyModelViewSet that needs the model-instance-based fields. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Both this issue and learningequality#14300 need them importable from a content-side module once the public viewsets move out of kolibri.core.public. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copy only — the originals stay in place and nothing imports this yet, so git blame -C -C can follow the code across the move. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
rtibblesbot
force-pushed
the
issue-14312-87cd34
branch
from
August 12, 2026 03:19
8adce42 to
86a32f2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The internal and public channel metadata endpoints built their responses from an explicit
valuestuple, afield_mapof renames and lambdas, and aconsolidate()pass, so neither had a serializer describing what it returns. Both now derive their fields from a serializer pair — the public one keeps the raw base64 thumbnail column, the internal one returns a thumbnail URL — and the domain moves into its own module undercontent/viewsets/.References
Fixes #14312. Unblocks #14300, which needs
SplitTextFieldandcontent/utils/cache.py.Acceptance criteria not met
values,field_mapandconsolidate()removed fromBaseChannelMetadataMixinconsolidate()survives forincluded_languagesalone, taking the ordering escape hatch the issue grants —annotate_array_aggregatereorders the list on SQLite.Reviewer guidance
kolibri/core/content/viewsets/channel_metadata.py:142— holding thesort_valueorder ofincluded_languagescosts a second query. Is that element order contractual enough to buy?kolibri/core/content/viewsets/channel_metadata.py:83—last_publishedrenders as a raw datetime matchinglast_updatedonly becauseKolibriModelSerializermaps the model'sDateTimeTzField. Is that coupling intended?Evidence
ChannelMetadataViewSetPublicChannelMetadataViewSetAI usage
Used Claude Code to write the characterization tests, migrate both viewsets to serializer derivation, and move the domain, following a pre-approved plan. Verified with the full test suite on SQLite and PostgreSQL, the viewset serialization benchmark, and prek.
@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly
How was this generated?
🟡 Waiting for feedback
Last updated: 2026-08-12 03:28 UTC