Skip to content

Commit

Permalink
Merge pull request #531 from oakdbca/ocr-bulk-import
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
xzzy authored Oct 17, 2024
2 parents 46a1b66 + 56dd727 commit 59ebef2
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions boranga/components/occurrence/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6775,11 +6775,6 @@ def related_model_qs(self):
if issubclass(self.related_model, ArchivableModel):
related_model_qs = self.related_model.objects.exclude(archived=True)

if hasattr(self.related_model, "group_type"):
related_model_qs = related_model_qs.only(display_field, "group_type")
else:
related_model_qs = related_model_qs.only(display_field)

return related_model_qs.order_by(display_field)

@cached_property
Expand Down Expand Up @@ -6926,7 +6921,7 @@ def get_sample_value(self, errors, species_or_community_identifier=None):
related_model_qs = related_model_qs.annotate(
occurrence_count=Subquery(
Occurrence.objects.filter(community__pk=OuterRef("pk"))
.values("species")
.values("community")
.annotate(count=Count("id"))
.values("count")
)
Expand Down Expand Up @@ -7048,7 +7043,7 @@ def get_sample_value(self, errors, species_or_community_identifier=None):
filter_field = {
"community__taxonomy__community_migrated_id": species_or_community_identifier
}
if not random_occurrence.exists():
if not random_occurrence.filter(**filter_field).exists():
error_message = (
f"No occurrences found where species or community identifier = "
f"{species_or_community_identifier}"
Expand Down

0 comments on commit 59ebef2

Please sign in to comment.