Skip to content

Commit

Permalink
minor(release): ontology performance & content updates (#1772)
Browse files Browse the repository at this point in the history
  • Loading branch information
JackScanlon authored Jan 15, 2025
1 parent c962539 commit 55ac7b1
Show file tree
Hide file tree
Showing 43 changed files with 2,026 additions and 724 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def get_generic_entities(request):

groups = list(user.groups.all().values_list('id', flat=True))
if len(groups) > 0:
group_ids = [ gen_utils.parse_int(group) for group in groups ]
group_ids = [ int(group) for group in groups if gen_utils.parse_int(group, default=None) ]
user_clause = f'''{user_clause} or (entity.group_id = any(%(group_ids)s) and entity.group_access = any(array[2, 3]))'''

accessible_clauses.append(f'({user_clause})')
Expand Down
6 changes: 2 additions & 4 deletions CodeListLibrary_project/clinicalcode/api/views/Ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

@api_view(['GET'])
@permission_classes([IsAuthenticatedOrReadOnly])
@cache_page(60 * 60 * 2)
@cache_page(60 * 60 * 8)
def get_ontologies(request):
"""
Get all ontology groups and their root
Expand All @@ -29,7 +29,7 @@ def get_ontologies(request):

@api_view(['GET'])
@permission_classes([IsAuthenticatedOrReadOnly])
@cache_page(60 * 60 * 2)
@cache_page(60 * 60 * 8)
def get_ontology_detail(request, ontology_id):
"""
Get specified ontology group type detail by the given `ontology_id`
Expand Down Expand Up @@ -61,7 +61,6 @@ def get_ontology_detail(request, ontology_id):

@api_view(['GET'])
@permission_classes([IsAuthenticatedOrReadOnly])
@cache_page(60 * 60 * 2)
def get_ontology_node(request, node_id):
"""
Gets an Ontology node by the given request
Expand All @@ -86,7 +85,6 @@ def get_ontology_node(request, node_id):

@api_view(['GET'])
@permission_classes([IsAuthenticatedOrReadOnly])
@cache_page(60 * 60 * 2)
def get_ontology_nodes(request):
"""
Queries Ontology nodes by the given request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def build_template_subquery_from_string(param, data, top_ref, sub_ref, validatio
ltype = '::bigint'
datatype = '::bigint'
elif sub_type == 'string_array':
data = [ str(x).lower() for x in data.split(',') if gen_utils.try_value_as_type(x, 'string') ]
data = [ str(x).lower() for x in data.split(',') if gen_utils.try_value_as_type(x, 'string') is not None ]
ltype = '::text'
datatype = ''
processor = 'lower'
Expand Down Expand Up @@ -520,7 +520,7 @@ def build_template_subquery_from_string(param, data, top_ref, sub_ref, validatio
data = [ int(x) for x in data.split(',') if isinstance(gen_utils.parse_int(x, default=None), int) ]
datatype = 'bigint'
elif sub_type == 'string_array':
data = [ str(x).lower() for x in data.split(',') if gen_utils.try_value_as_type(x, 'string') ]
data = [ str(x).lower() for x in data.split(',') if gen_utils.try_value_as_type(x, 'string') is not None ]
datatype = 'text'
processor = 'lower'

Expand Down Expand Up @@ -651,7 +651,7 @@ def build_query_string_from_param(param, data, validation, field_type, is_dynami
source = validation.get('source')
trees = source.get('trees') if source and 'trees' in validation.get('source') else None
if trees:
data = [ str(x) for x in data.split(',') if gen_utils.try_value_as_type(x, 'string') ]
data = [ str(x) for x in data.split(',') if gen_utils.try_value_as_type(x, 'string') is not None ]
model = source.get('model') if isinstance(source.get('model'), str) else None

if model:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def is_concept_published(concept_id, version_id):
version_id (int): the Concept's history_id
Returns:
bool: Reflects published status
bool: Reflects publish status
"""
concept_id = gen_utils.parse_int(concept_id, None)
Expand Down Expand Up @@ -95,7 +95,7 @@ def was_concept_ever_published(concept_id, version_id=None):
version_id (int|null): the Concept's history_id
Returns:
bool: Reflects all-time published status
bool: Reflects all-time publish status
"""
concept_id = gen_utils.parse_int(concept_id, None)
Expand Down Expand Up @@ -298,7 +298,7 @@ def get_concept_headers(concept_information, default=None):
columns = [col[0] for col in cursor.description]
results = [dict(zip(columns, row)) for row in cursor.fetchall()]

if len(results) < 0:
if len(results) < 1:
return default

return results
Expand Down Expand Up @@ -377,7 +377,7 @@ def get_concept_dataset(packet, field_name='concept_information', default=None):
columns = [col[0] for col in cursor.description]
results = [dict(zip(columns, row)) for row in cursor.fetchall()]

if len(results) < 0:
if len(results) < 1:
return default

return results
Expand Down
Loading

0 comments on commit 55ac7b1

Please sign in to comment.