Skip to content

Commit

Permalink
Alphabetical order genomes, labs and tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
neoformit committed Aug 17, 2024
1 parent d070e75 commit 4652183
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions app/genomes/api/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@api_view(['GET'])
def labs(request):
"""Return requested labs as json."""
labs = Lab.objects.all()
labs = Lab.objects.all().order_by(Lower('name'))
filter_labs_str = request.GET.get('labs')
if filter_labs_str:
filter_labs = [
Expand All @@ -34,8 +34,13 @@ def labs(request):

@api_view(['GET'])
def genomes(request):
"""Return requested genomes as json."""
genomes = Genome.objects.all()
"""Return requested genomes as json.
Optionally filter by GET parameters, where `group` matches
`genome.group.name` and `lab` is a comma-joined list of lab names which
matching `genome.lab.name`.
"""
genomes = Genome.objects.all().order_by(Lower('name'))
filter_group = request.GET.get('group')
if filter_group:
# Case insensitive filter by genome.group.name
Expand All @@ -62,7 +67,7 @@ def genomes(request):
@api_view(['GET'])
def tracks(request):
"""Return requested genomes as json."""
tracks = Track.objects.all()
tracks = Track.objects.all().order_by(Lower('name'))
filter_keywords = {
'group': 'genome__group__name__iexact',
'genome_id': 'genome__id',
Expand Down

0 comments on commit 4652183

Please sign in to comment.