Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
add number individuals
Browse files Browse the repository at this point in the history
  • Loading branch information
naknomum committed Oct 24, 2023
1 parent 52ccbf4 commit c8c009e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/modules/sightings/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,9 @@ def individuals(self):
indivs.add(enc.individual)
return indivs

def get_number_individuals(self):
return len(self.individuals)

def get_individual_names(self):
names = set()
for indiv in self.individuals:
Expand Down
2 changes: 2 additions & 0 deletions app/modules/sightings/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class ElasticsearchSightingSchema(BaseSightingSchema):
encounters = base_fields.Function(lambda s: s.get_encounters_elasticsearch())
numberImages = base_fields.Function(lambda s: s.get_number_assets())
numberAnnotations = base_fields.Function(lambda s: s.get_number_annotations())
numberIndividuals = base_fields.Function(lambda s: s.get_number_individuals())
# apparently sets do NOT work well, so we need to name-sets to lists here
individualNames = base_fields.Function(lambda s: list(s.get_individual_names()))
individualNamesWithContexts = base_fields.Function(
Expand Down Expand Up @@ -116,6 +117,7 @@ class Meta:
'encounters',
'numberImages',
'numberAnnotations',
'numberIndividuals',
'individualNames',
'individualNamesWithContexts',
)
Expand Down

0 comments on commit c8c009e

Please sign in to comment.