Skip to content

Commit

Permalink
Merge pull request #51 from ola-t/master
Browse files Browse the repository at this point in the history
minor fixes
  • Loading branch information
atarkowska authored Jan 18, 2018
2 parents b8aa942 + 4a9e488 commit 669c2dd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 7 additions & 7 deletions emgapi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from __future__ import unicode_literals

from django.db import models
from django.db.models import Count, Case, When, IntegerField
from django.db.models import Sum, Count, Case, When, IntegerField
from django.db.models import Q
from django.db.models import Prefetch

Expand Down Expand Up @@ -140,7 +140,7 @@ class PipelineManager(models.Manager):
def get_queryset(self):
return PipelineQuerySet(self.model, using=self._db) \
.annotate(analysis_count=Count('analysis', distinct=True)) \
.annotate(samples_count=Count(Case(
.annotate(samples_count=Sum(Case(
When(analysis__sample__is_public=1, then=1),
default=0,
output_field=IntegerField()
Expand Down Expand Up @@ -214,7 +214,7 @@ class BiomeManager(models.Manager):

def get_queryset(self):
return BiomeQuerySet(self.model, using=self._db) \
.annotate(samples_count=Count(Case(
.annotate(samples_count=Sum(Case(
When(samples__is_public=1, then=1),
default=0,
output_field=IntegerField()
Expand Down Expand Up @@ -258,12 +258,12 @@ class PublicationManager(models.Manager):

def get_queryset(self):
return PublicationQuerySet(self.model, using=self._db) \
.annotate(studies_count=Count(Case(
.annotate(studies_count=Sum(Case(
When(studies__is_public=1, then=1),
default=0,
output_field=IntegerField()
))) \
.annotate(samples_count=Count(Case(
.annotate(samples_count=Sum(Case(
When(studies__samples__is_public=1, then=1),
default=0,
output_field=IntegerField()
Expand Down Expand Up @@ -345,7 +345,7 @@ def get_queryset(self):
# TODO: remove biome when schema updated
return StudyQuerySet(self.model, using=self._db) \
.defer('biome') \
.annotate(samples_count=Count(Case(
.annotate(samples_count=Sum(Case(
When(samples__is_public=1, then=1),
default=0,
output_field=IntegerField()
Expand Down Expand Up @@ -582,7 +582,7 @@ class ExperimentTypeManager(models.Manager):
def get_queryset(self):
return ExperimentTypeQuerySet(self.model, using=self._db) \
.annotate(runs_count=Count('runs', distinct=True)) \
.annotate(samples_count=Count(Case(
.annotate(samples_count=Sum(Case(
When(runs__sample__is_public=1, then=1),
default=0,
output_field=IntegerField()
Expand Down
2 changes: 2 additions & 0 deletions emgapianns/management/commands/import_taxonomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
'species'],
'4.0': ['super kingdom', 'kingdom', 'phylum', 'class', 'order', 'family',
'genus', 'species'],
'4.1': ['super kingdom', 'kingdom', 'phylum', 'class', 'order', 'family',
'genus', 'species'],
}


Expand Down

0 comments on commit 669c2dd

Please sign in to comment.