Skip to content

Commit

Permalink
always suggest filtering by "creator"
Browse files Browse the repository at this point in the history
  • Loading branch information
aaxelb committed Oct 13, 2023
1 parent 5a15ece commit 10a168f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
1 change: 0 additions & 1 deletion share/models/feature_flag.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class FeatureFlag(models.Model):
# flag name constants
ELASTIC_EIGHT_DEFAULT = 'elastic_eight_default'
IGNORE_SHAREV2_INGEST = 'ignore_sharev2_ingest'
SUGGEST_CREATOR_FACET = 'suggest_creator_facet'

# name _should_ be one of the constants above, but that is not enforced by `choices`
name = models.TextField(unique=True)
Expand Down
33 changes: 16 additions & 17 deletions trove/vocab/osfmap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from gather import primitive_rdf, gathering

from share.models.feature_flag import FeatureFlag
from trove.util.iri_labeler import IriLabeler
from trove.vocab.trove import JSONAPI_MEMBERNAME
from trove.vocab.namespaces import (
Expand Down Expand Up @@ -725,6 +724,7 @@


ALL_SUGGESTED_PROPERTY_PATHS = (
(DCTERMS.creator,),
(DCTERMS.created,),
(OSFMAP.funder,),
(DCTERMS.subject,),
Expand All @@ -737,6 +737,7 @@


PROJECT_SUGGESTED_PROPERTY_PATHS = (
(DCTERMS.creator,),
(DCTERMS.created,),
(OSFMAP.funder,),
(DCTERMS.rights,),
Expand All @@ -748,6 +749,7 @@


REGISTRATION_SUGGESTED_PROPERTY_PATHS = (
(DCTERMS.creator,),
(DCTERMS.created,),
(OSFMAP.funder,),
(DCTERMS.publisher,),
Expand All @@ -766,6 +768,7 @@


PREPRINT_SUGGESTED_PROPERTY_PATHS = (
(DCTERMS.creator,),
(DCTERMS.created,),
(DCTERMS.subject,),
(DCTERMS.rights,),
Expand Down Expand Up @@ -818,22 +821,18 @@

def suggested_property_paths(type_iris: set[str]) -> tuple[tuple[str, ...]]:
if not type_iris or not type_iris.issubset(OSFMAP_NORMS.focustype_iris):
_suggested = ()
elif type_iris == {DCTERMS.Agent}:
_suggested = AGENT_SUGGESTED_PROPERTY_PATHS
elif type_iris == {OSFMAP.Preprint}:
_suggested = PREPRINT_SUGGESTED_PROPERTY_PATHS
elif type_iris == {OSFMAP.File}:
_suggested = FILE_SUGGESTED_PROPERTY_PATHS
elif type_iris <= {OSFMAP.Project, OSFMAP.ProjectComponent}:
_suggested = PROJECT_SUGGESTED_PROPERTY_PATHS
elif type_iris <= {OSFMAP.Registration, OSFMAP.RegistrationComponent}:
_suggested = REGISTRATION_SUGGESTED_PROPERTY_PATHS
else:
_suggested = ALL_SUGGESTED_PROPERTY_PATHS
if FeatureFlag.objects.flag_is_up(FeatureFlag.SUGGEST_CREATOR_FACET):
return ((DCTERMS.creator,), *_suggested)
return _suggested
return ()
if type_iris == {DCTERMS.Agent}:
return AGENT_SUGGESTED_PROPERTY_PATHS
if type_iris == {OSFMAP.Preprint}:
return PREPRINT_SUGGESTED_PROPERTY_PATHS
if type_iris == {OSFMAP.File}:
return FILE_SUGGESTED_PROPERTY_PATHS
if type_iris <= {OSFMAP.Project, OSFMAP.ProjectComponent}:
return PROJECT_SUGGESTED_PROPERTY_PATHS
if type_iris <= {OSFMAP.Registration, OSFMAP.RegistrationComponent}:
return REGISTRATION_SUGGESTED_PROPERTY_PATHS
return ALL_SUGGESTED_PROPERTY_PATHS


def suggested_filter_operator(property_iri: str):
Expand Down

0 comments on commit 10a168f

Please sign in to comment.