-
Notifications
You must be signed in to change notification settings - Fork 11
Add support for species charts #993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for antenna-preview canceled.
|
|
Some things to discuss:
|
|
After discussing, we (Anna and Michael) agreed this is a good start and we will try merge it. Some thoughts for next steps:
|
| qs = Occurrence.objects.filter(project=project_pk) | ||
|
|
||
| if taxon_pk: | ||
| qs = qs.filter(determination_id=taxon_pk) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mihow one thing I forgot to mention is that this means we will present direct occurrences. I guess since the main focus for this task is species, it's perhaps not a big concern, but just FIY.
I think it would be more useful to consider all occurrences, not just direct. But I also know a bit tricker and slower, so maybe not for now? Let me know what you think!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh thanks for calling that out, we have a generic filter for getting the recursive count. The performance should be fine for the detail view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mohamedelabbas1996 here! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add the recursive count in a follow-up! I will merge this as-is now.
| return TagSerializer(tag_list, many=True, context=self.context).data | ||
|
|
||
| def get_summary_data(self, obj: Taxon): | ||
| project = get_active_project(request=self.context["request"], required=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@annavik I couldn't help it. I made the get_active_project helper reusable here.
| Occurrence.objects.filter(project=project_pk) | ||
| .values("event__start__month") | ||
| .annotate( | ||
| total_occurrences=models.Count("id"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@annavik here is alternative query to get all of the data you need in a single query. it's less important on detail views than list views, but I try to reduce when I can! it probably is possible to even do the division within the db query, but it's only 12 items (12 months) to divide, so in python is fine.
mihow
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have fight charts! I know they will continue to be revised, but this is a great milestone. Merging!
Woho, thank you!! |




Summary
In this PR we add support for species charts. To be more specific, we make it possible to see average occurrence per month for a specific species (or taxon).
List of Changes
Related Issues
Related to #864
Detailed Description
How to Test the Changes
Changes must be tested locally since they include backend updates.
Screenshots
Deployment Notes
Remember to deploy the backend after merge.