Skip to content

Sync kolibri_public when a channel is made public, private or deleted - #6475

Open
rtibblesbot wants to merge 1 commit into
learningequality:hotfixesfrom
rtibblesbot:issue-6469-c4a408
Open

rtibblesbot wants to merge 1 commit into
learningequality:hotfixesfrom
rtibblesbot:issue-6469-c4a408

Conversation

@rtibblesbot

@rtibblesbot rtibblesbot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A channel made public after its last publish shows in Kolibri's Device import but not in Learn's Explore libraries. Making a channel private or deleting it never removed it from the public v2 API, and export_channels_to_kolibri_public failed on every channel.

A background task now exports a published channel to kolibri_public when it becomes public, and deletes its public rows when it becomes private or is deleted. The management command exports again.

References

Fixes #6469. Related: #6470.

Reviewer guidance

Suggested review: Full code review, then manual QA once the reviewer sets Needs QA.

Engineer review

  • A channel made private while it is publishing gets its kolibri_public rows back when the publish maps (contentcuration/utils/publish.py:204).
  • A client revalidating the v2 list with If-Modified-Since alone still gets 304 after a removal (kolibri_public/views.py:63).
  • --channel-id now exports only channels that are public and published in the local DB, which drops 2eece7e's export of channels absent locally (kolibri_public/management/commands/export_channels_to_kolibri_public.py:51).
  • The sync holds a transaction and the advisory lock while it downloads and migrates the content database (kolibri_public/utils/export_channel_to_kolibri_public.py:105-111); confirm that suits the largest public channels.
  • First task sent by bare apply_async with no user or CustomTaskMetadata, so task tracking never sees it (contentcuration/models.py:1423); others will copy it.
Engineer evidence
  1. Studio admin → Channels → a published private channel → Actions → Make public. The request returns at once; once the worker runs, /api/public/v2/channel/<id>/ returns 200.
  2. Make that channel private. /api/public/v2/channel/<id>/ returns 404.
  3. Soft delete, then hard delete, a public channel. /api/public/v2/channel/<id>/ returns 404.
  4. python manage.py export_channels_to_kolibri_public --channel-id <id> on a published public channel. /api/public/v2/channel/<id>/ returns 200.

For the by-hand backfill, use --channel-id: the no-argument form also republishes public channels with a null or pre-2019 last_published.

Open questions:

  • --channel-id now skips channels that are not public and published in the local database; previously it exported channels absent locally.
  • The sync holds a transaction and the advisory lock while it downloads and maps the content database; is that acceptable for the largest public channels?

QA review

  • Studio admin → Channels → Actions → Make public on a published private channel returns at once; once the worker runs, /api/public/v2/channel/<id>/ returns 200 and Kolibri Learn → Explore libraries lists it.
  • Make private on that channel: /api/public/v2/channel/<id>/ returns 404 and Explore libraries drops it.
  • Admin soft delete, then hard delete, of a public channel: /api/public/v2/channel/<id>/ returns 404.

AI usage

Used Claude Code to plan the change, write the code and tests, and draft this description. Verified with the full test suite and pre-commit.


Written by rtibblesbot, an LLM-based coding agent.

@rtibblesbot

🟡 Waiting for feedback

WAITING · for review
Last updated: 2026-11-26 02:25 UTC

- Channel schedules sync_channel_to_kolibri_public_task after commit when
  public or deleted changes on a public channel, and on hard delete
- The task exports a published public channel, or deletes its public
  kolibri_public rows, under a per-channel advisory lock
- export_channels_to_kolibri_public called the module, not the function,
  so every export failed

Fixes learningequality#6469

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rtibblesbot
rtibblesbot marked this pull request as ready for review November 26, 2026 02:23
@rtibblesbot
rtibblesbot requested review from a team and leq-bot November 26, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant