Skip to content

Commit

Permalink
Merge branch 'release/2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
peichman-umd committed Jun 3, 2024
2 parents 41d893c + 4a1104a commit 3bb1945
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
18 changes: 10 additions & 8 deletions fedora4/core/conf/index-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,13 +405,15 @@ function setPublicationAndDiscoveryStatusFields(doc) {
is_top_level = true;
}
}
doc.setField(SOLR_IS_PUBLISHED, is_published);
doc.setField(SOLR_IS_HIDDEN, is_hidden);
doc.setField(SOLR_IS_TOP_LEVEL, is_top_level);
// facet fields
doc.setField(SOLR_PUBLICATION_STATUS, publication_status);
doc.setField(SOLR_VISIBILITY, visibility);

var is_discoverable = is_top_level && is_published && !is_hidden;
doc.setField(SOLR_IS_DISCOVERABLE, is_discoverable);
if (is_top_level) {
doc.setField(SOLR_IS_PUBLISHED, is_published);
doc.setField(SOLR_IS_HIDDEN, is_hidden);
// facet fields
doc.setField(SOLR_PUBLICATION_STATUS, publication_status);
doc.setField(SOLR_VISIBILITY, visibility);

var is_discoverable = is_top_level && is_published && !is_hidden;
doc.setField(SOLR_IS_DISCOVERABLE, is_discoverable);
}
}
19 changes: 13 additions & 6 deletions tests/test_publish_and_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
@pytest.mark.parametrize(
('rdf_types', 'is_published', 'is_top_level', 'is_hidden', 'is_discoverable'),
[
# Published, but not top-level or hidden
([published_type], True, False, False, False),
# Top level, but not published or hidden
([top_level_type], False, True, False, False),
# Published and top-level, but not hidden, so discoverable
Expand All @@ -25,13 +23,22 @@ def test_publish_and_discovery_flags(index, rdf_types, is_published, is_top_leve
assert doc['is_discoverable'] == is_discoverable


def test_only_top_level_have_flags(index):
# Not top-level, should not have the "is_*" flags other than "is_top_level:false"
doc = index({})
assert not doc['is_top_level']
assert 'is_published' not in doc
assert 'is_hidden' not in doc
assert 'is_discoverable' not in doc


@pytest.mark.parametrize(
('rdf_types', 'publication_status', 'visibility'),
[
([], 'Unpublished', 'Visible'),
([published_type], 'Published', 'Visible'),
([hidden_type], 'Unpublished', 'Hidden'),
([published_type, hidden_type], 'Published', 'Hidden'),
([top_level_type], 'Unpublished', 'Visible'),
([top_level_type, published_type], 'Published', 'Visible'),
([top_level_type, hidden_type], 'Unpublished', 'Hidden'),
([top_level_type, published_type, hidden_type], 'Published', 'Hidden'),
]
)
def test_publish_and_discovery_facets(index, rdf_types, publication_status, visibility):
Expand Down

0 comments on commit 3bb1945

Please sign in to comment.