Skip to content

Commit

Permalink
Hide attributes related to downloading files. (#3382)
Browse files Browse the repository at this point in the history
* Hide attributes related to downloading files.

* Revert spacing.
  • Loading branch information
jkmarx committed May 16, 2019
1 parent 43a810b commit e7b90d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions refinery/data_set_manager/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ def _is_active_attribute(attribute):


def _is_exposed_attribute(attribute):
return True # TODO: Could we get rid of this?
return True


def _is_ignored_attribute(attribute):
Expand Down Expand Up @@ -952,13 +952,16 @@ def _is_facet_attribute(attribute, study, assay):
facet attribute values is smaller than
settings.DEFAULT_FACET_ATTRIBUTE_VALUES_RATIO, false otherwise.
"""
# download_url custom attribute which should not be treated as a facet
if data_set_manager.search_indexes.NodeIndex.DOWNLOAD_URL == attribute:
return False

ratio = 0.5
results = _query_solr(attribute=attribute, study=study, assay=assay)
items = results['response']['numFound']
attribute_values = len(
results['facet_counts']['facet_fields'][attribute]
) / 2

return (attribute_values / items) < ratio


Expand Down
5 changes: 4 additions & 1 deletion refinery/data_set_manager/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

from .models import (AnnotatedNode, Assay, Attribute, AttributeOrder, Node,
Study)
from .search_indexes import NodeIndex
from .serializers import (AssaySerializer, AttributeOrderSerializer,
NodeSerializer, StudySerializer)
from .single_file_column_parser import process_metadata_table
Expand Down Expand Up @@ -954,7 +955,9 @@ def get_objects(self, uuid):
raise Http404

def get(self, request, uuid, format=None):
attribute_order = self.get_objects(uuid)
attribute_order = self.get_objects(uuid).exclude(
solr_field__in=[NodeIndex.DOWNLOAD_URL, NodeIndex.DATAFILE]
)
serializer = AttributeOrderSerializer(attribute_order, many=True)
owner = get_owner_from_assay(uuid)
request_user = request.user
Expand Down

0 comments on commit e7b90d0

Please sign in to comment.