Repository navigation
OpenConceptLab/ocl_online#741 | Collection versions holding a resource, and contains, name only versions viewable with their HEAD - #1035
Merged
Conversation
…ing a resource, and contains, name only versions viewable with their HEAD
Contributor
Author
|
Read-only timing check for the detail page (ocl_online#741's second criterion). This is the query a signed-out concept detail now runs for EXPLAIN (ANALYZE, BUFFERS)
SELECT c.uri
FROM collection_expansions_concepts ec
JOIN collection_expansions e ON ec.expansion_id = e.id
JOIN collections c ON e.collection_version_id = c.id
WHERE ec.concept_id = <concept row id>
AND NOT (c.version = 'HEAD')
AND EXISTS (
SELECT 1 FROM collections v
WHERE v.id = e.collection_version_id
AND v.is_active AND v.public_access IN ('View', 'Edit')
AND NOT EXISTS (
SELECT 1 FROM collections h
WHERE (h.organization_id = v.organization_id OR h.user_id = v.user_id)
AND h.is_active AND h.mnemonic = v.mnemonic AND h.version = 'HEAD'
AND NOT (h.public_access IN ('View', 'Edit'))
LIMIT 1)
LIMIT 1);What to expect: one primary-key lookup on |
snyaggarwal
commented
Nov 23, 2026
snyaggarwal
left a comment
Contributor
Author
There was a problem hiding this comment.
Verdict: ready to merge once CI passes. No findings on 5c11eda.
What I checked:
- The shared check:
filter_by_viewable_collection_versionnow appliesget_viewable_versions_criteriafrom #1027, the query form ofhas_view_access, as a correlatedEXISTSon the collection version's primary key:- staff get no filter, as before;
- owners and org members match through
own, as they did throughorganization__members; - versions under a private HEAD, and inactive versions, now drop out for everyone else.
- What it covers: every caller goes through this function, so one change covers version detail, the versions lists (
load_collection_versions, a page at a time), bothcollection-versions/routes, and$cascade, which uses the same serializers. contains: it now uses the signed-out criteria, so a version counts only if it's public, active and under a public HEAD. As before, the answer doesn't depend on who asks. It also now counts versions with the legacyEditaccess, becausePUBLIC_ACCESS_VALUEStreats that as public, which is whathas_view_accessdoes.- The tests: four of the five new tests fail on master's code. The four access-control failures in the wider local run fail the same way on master, in source-version search, so they're unrelated.
Detail-page timing: the read-only EXPLAIN in the comment above is the last check the ticket asks for. It's a production run, for whoever has access.
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.
For OpenConceptLab/ocl_online#741. Once a collection's HEAD is made private, its released versions are private as well:
has_view_accessneeds the HEAD to be viewable too. But the lists that name the collection versions holding a concept or mapping checked only each version's ownpublic_access. They didn't look at its HEAD, or at whether it was active. So a signed-out user still saw those versions' URLs, which name the private collection and say which of its versions hold the resource.What changes
filter_by_viewable_collection_version(incore/common/mixins.py) now appliesCollection.get_viewable_versions_criteria(user)from OpenConceptLab/ocl_online#718 | A collection named in the query string counts only through versions the requester can view #1027, the query form ofhas_view_access:It runs as one correlated
EXISTSper expansion row, looked up by the collection version's primary key. That one function covers every path the ticket lists:collection_versionson concept and mapping version details, and on their versions lists withincludeCollectionVersions=true;/concepts/X/collection-versions/and the mapping route like it;$cascadebundles, which use the same serializers./collections/?contains=<expression>(Collection.get_base_queryset) took any version with public access. It now takes only versions that are publicly viewable: public, active, and under a public HEAD. That's the same criteria for a signed-out user. As before, it doesn't depend on who's asking.Tests
core/collections/tests/tests_viewable_collection_versions.pysets up a public release under a public HEAD, then makes the HEAD private. It checks concepts and mappings on:collection-versions/route;contains.Signed-out users and outsiders no longer see the release. An org member and staff still do. Four of the five tests fail against master's code; the fifth checks that a public HEAD still shows its release.
Locally, with Redis unreachable as in CI, 800 tests in
core.concepts,core.mappings,core.collectionsandtests_access_controlpass, except four. The same four also fail on master in that setup: they're source-version search tests, one answering 400 on a?q=search. The new tests also pass, and pylint is clean on the changed files.Detail-page timing
The ticket asks for this to be checked, because the filter runs on every concept and mapping detail. To check it, a read-only
EXPLAIN (ANALYZE, BUFFERS)can be run on production, using a concept that many collection versions hold. The SQL is in the PR comment.🤖 Generated with Claude Code