Skip to content

Migrate the facility plugin to the new resource methods - #15184

Open
rtibblesbot wants to merge 5 commits into
learningequality:developfrom
rtibblesbot:issue-15062-fbe9fc
Open

Migrate the facility plugin to the new resource methods#15184
rtibblesbot wants to merge 5 commits into
learningequality:developfrom
rtibblesbot:issue-15062-fbe9fc

Conversation

@rtibblesbot

@rtibblesbot rtibblesbot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Every resource call in facility moves to the new Resource methods, and DeletedFacilityUserResource.restoreCollection is rewritten onto request.
  • The users table reads through useList.
  • Deletes the dead plugin-local PortalResource.
  • Dropping the client cache surfaced a backend bug it had been hiding: the member_of, related_to__in and user_type filters OR-ed a multi-valued relation, returning a user once per matching membership or role.
  • Those three now match through id__in=<subquery>.

References

Fixes #15062. Recipe: #15057.

Reviewer guidance

  • composables/useUserManagement.js:68 — check the stale-page 404 redirect cannot loop, now that error handling runs in a watch rather than a catch.
  • kolibri/core/auth/viewsets/facility_user.py:112 — check no caller relied on these filters returning a row per membership or role.
  • Four setup() reads keep list(): their loading ref is also set by a write path, which useList cannot do. Check that beats refactoring MoveToTrashModal.vue:90, AssignCoachesSidePanel.vue:178, EnrollLearnersSidePanel.vue:176, ClassCopyModal.vue:178.
  • Reads that passed no force: true now hit the network every time. Check that is acceptable for the side panels, which refetch on open.

Duplicate row on the users page:

Before After
Before After

Pages exercised live:

Page Screenshot
Class detail Class
Deleted users Trash
Data Data

AI usage

Used Claude Code to apply the migration recipe call site by call site, then to diagnose the duplicate row it surfaced. Verified with the facility and kolibri-common Jest suites, the auth Python suite, prek, and live QA in a browser.


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

How was this generated?
  • Ran pre-flight CI checks (lint, format, tests) and verified all pass
  • Rebased onto the target branch and resolved any conflicts
  • Reorganized commit history into clean, logical commits
  • Audited the diff to ensure only issue-relevant files are changed
  • Built PR body from the repository's PR template with evidence blocks
@rtibblesbot

🟡 Waiting for feedback

Last updated: 2026-08-12 22:29 UTC

@github-actions github-actions Bot added DEV: backend Python, databases, networking, filesystem... APP: Facility Re: Facility App (user/class management, facility settings, csv import/export, etc.) DEV: frontend SIZE: large labels Aug 12, 2026
@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

@rtibblesbot
rtibblesbot force-pushed the issue-15062-fbe9fc branch 2 times, most recently from 39f2b74 to 7f68609 Compare August 12, 2026 17:11
@rtibblesbot
rtibblesbot marked this pull request as ready for review August 12, 2026 21:11
rtibblesbot and others added 5 commits August 12, 2026 14:19
The Model/Collection cache goes with them, so every read that did not pass
`force: true` now hits the network.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The resource is imported only by facility, so the recipe's in-place rewrite
applies rather than a `_v2` sibling. It now resolves with the payload instead
of the axios response, and failures are logged by `request`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Four behaviour changes come with useFetch: `dataLoading` clears on failure
rather than spinning forever, `usersCount`/`totalPages` normalise to 0 instead
of undefined, a superseded fetch's response is discarded, and failure handling
runs from a watcher a tick later instead of a catch.

`fetchClasses` stays a plain `list()` — `useUsersFilters` dereferences the
`classes` ref before any fetch runs, and `useFetch` initialises `data` to null.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
It duplicates packages/kolibri-common/apiResources/PortalResource.js and has
no importers.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
member_of, related_to__in and user_type joined memberships and roles, returning
a user once per matching row - a learner in two classes appeared twice. The
legacy Collection cache deduplicated by id client-side, hiding it until the
resource migration.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

APP: Facility Re: Facility App (user/class management, facility settings, csv import/export, etc.) DEV: backend Python, databases, networking, filesystem... DEV: frontend SIZE: large

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate facility to the new Resource-layer methods

2 participants