Skip to content

Add management command for auditing missing sources#5711

Merged
bjester merged 3 commits intolearningequality:hotfixesfrom
bjester:incompletely-synced
Feb 18, 2026
Merged

Add management command for auditing missing sources#5711
bjester merged 3 commits intolearningequality:hotfixesfrom
bjester:incompletely-synced

Conversation

@bjester
Copy link
Member

@bjester bjester commented Feb 18, 2026

Summary

  • Adds CTE functionality to channel model
  • Adds new management command that audits missing import sources for public channels, where source node was deleted or public channel was marked as deleted

References

#5683

Reviewer guidance

  • Tests make sense?
  • Can you run the command? It will generate a fix_missing_import_sources.csv in your CWD

LLMs

  • LLMs were used to convert SQL queries into Django ORM queries, but the result was almost entirely rewritten
  • Tests were bootstrapped then also rewritten

@bjester bjester requested a review from rtibblesbot February 18, 2026 17:05
Copy link

@rtibblesbot rtibblesbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Audit command for missing import sources on public channels, with CTE support added to the Channel model. Code is clean and well-structured.

CI: linting and frontend builds pass; Python unit tests still pending. The "Update community pull requests spreadsheet" failure is an unrelated admin workflow.

  • suggestion: Command name vs. current behavior mismatch (inline)
  • suggestion: Duplicate CTE construction (inline)
  • nitpick: .gitignore additions are unrelated to the PR scope but harmless

@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?

Reviewed the pull request diff checking for:

  • Correctness: bugs, edge cases, undocumented behavior, resource leaks, hardcoded values
  • Design: unnecessary complexity, naming, readability, comment accuracy, redundant state
  • Architecture: duplicated concerns, minimal interfaces, composition over inheritance
  • Testing: behavior-based assertions, mocks only at hard boundaries, accurate coverage
  • Completeness: missing dependencies, unupdated usages, i18n, accessibility, security
  • Principles: DRY (same reason to change), SRP, Rule of Three (no premature abstraction)
  • Checked CI status and linked issue acceptance criteria
  • For UI changes: inspected screenshots for layout, visual completeness, and consistency



class ChannelModelQuerySet(models.QuerySet):
class ChannelModelQuerySet(CTEQuerySet):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Good approach — inheriting from CTEQuerySet instead of models.QuerySet keeps the custom create/update_or_create methods intact while adding CTE support. The ChannelModelManager via from_queryset is the correct Django pattern for this.

Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran it locally and got this:

INFO:contentcuration.management.commands.fix_missing_import_sources:=== Iterating over private destination channels. ===
INFO:contentcuration.management.commands.fix_missing_import_sources:=== Done iterating over private destination channels. ===
INFO:contentcuration.management.commands.fix_missing_import_sources:Found 0 nodes across 0 channels.
INFO:contentcuration.management.commands.fix_missing_import_sources:Finished in 0.015901565551757812

Which seems accurate :)

Further testing we can do live.

@bjester bjester merged commit bf03d5f into learningequality:hotfixes Feb 18, 2026
19 of 21 checks passed
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.

3 participants

Comments