Code Monkey home page Code Monkey logo

django-bird-colony's People

Contributors

dependabot[bot] avatar dmeliza avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

gaybro8777

django-bird-colony's Issues

Add form for adding events

It's tedious to add events for birds with the current solution, which bops you over to the database admin site. It'd be nice to have a prepopulated form.

birds with no parents aren't showing up in living list

Unclear if this is the causal factor, but we just added some new birds from another lab who don't have parents, and they're not showing up in the living list even though their living attribute is true. possibly an issue with how livingness is calculated by summing up the event count fields.

add link to event list to edit

Need to be able to edit events sometimes. Would be useful to have a link in the event list that either points to the admin for that event or to a dedicated form.

add nest check functionality

Currently we're using a google spreadsheet to do daily nest checks, and there's a lot of duplicated effort and opportunities for error. It would be nice to have nest checks integrated with the colony database.

Simplest implementation I can think of is with a Nest model, then add a ForeignKey to Animal so that birds can be added or removed from a nest. The Nest model itself would have a location, a name, and an egg count. But this would only hold the current state of the nest, whereas we want to keep a record. Among other reasons, having a date when eggs are laid would allow predicting when they will hatch.

We already keep records in the form of Event objects, but these are linked to animals and locations, so it wouldn't be trivial to make them work for a separate model. Thus, another option is to extend the Location model so that it can be used as a nest. Eggs probably have to be tracked as unique objects, whether as weird Animal instances or using their own somewhat simpler model. In this approach, a lot of the logic would be in the views.

The problem I see here is that Animals don't have a unique Location; instead, this is inferred by joining to the Event table and finding the most recent event. This works nicely for 90% of the logic, but it's not simple to go in the reverse direction, from Location to Animal, at least not with the Django ORM.

summary views

counts of various events (births, deaths) in a month
counts of animals at various ages right now

Cache age-group table to speed up looking up birds' age groups.

Looking up which age group an animal belongs to requires a join on the Age table via Species. This is pretty quick but some views require it to be done for a lot of animals - all the living birds or all the birds in nests.

One solution would be to annotate the animal query with the age and age group, instead of the current implementation as object-level methods. This would need to be optional as queries to count children don't need the annotation (see #31).

Another possibility would be to cache Species x Age. This would have a fairly small number of rows and would usually not change at all after initial database setup. This wouldn't help the age lookup itself (which requires Animal x Event) but would probably speed the age-group lookup even more than an annotation.

Rethink reservation system

The current reservation system is pretty clunky. It requires using the admin interface, and there's no record of when the reservation was created. Sometimes users forget to release the reservation, so there are birds that get reserved, and then it's not clear if the reservation is no longer needed.

The general idea would be to create a Reservation model that tracks creation date. It could also include optional expiration and comment fields.

Make "alive" annotation optional for Animal model to speed up counts of children.

The default manager for this class annotates queries with an 'alive' field that's calculated by summing "adds" vs "removes" over the events associated with the animal. This field is used in a lot of views, but it's not needed to for example count the number of children (including the number of living and unhatched, as that can be done with a simple exclude or filter on the status.

I think this annotation is costing a lot for some views because a children query gets called for every animal in a list. It affects not just the top-level lists of animals but also the list of children shown for views of individual animals.

I'm actually a little surprised that the annotation comes through on a related object query. But the SQL queries suggest that the children queries are getting hit a lot.

I'm not sure the best way to solve this, because the "alive" annotation is needed whenever we do a list of birds. It just doesn't need to be known when we look up the number of children. Maybe a separate method to do the child counts on unannotated queries. Alternatively, calculate these numbers in the database. Essentially every animal view requires joins against the event table, both directly and via its children and/or parents.

Children count includes unhatched eggs

The "children" field in the bird tables gives a count of the number of children the bird has, but this includes unhatched eggs, which makes it less useful in determining if a bird has descendants.

pairing view should not display lost eggs

It would be great if the Eggs and Progeny list did not show eggs that had been lost, and if the count of eggs on the list of pairings did not reflect lost eggs as well.

refactoring: genealogy is broken

Bird status information is not getting annotated correctly - birds are showing up as alive in the genealogy when they are not.

Add form for sexing animals.

Currently, entering sex information for a bird requires using the admin interface. Typically the user creates a note as well. A form could streamline this.

Add age of oldest chick to pairing model

It would be useful to be able to display the age of the oldest chick for active breeding pairs. This would avoid the need to look at the detail view to make plans around when birds will reach a certain age.

Age is a fairly complicated calculation, however, that currently involves a lot of python code, so it might be slow to compute for more than a few pairings.

Add table for recordings

It should be possible to associate data files with birds so that users can browse and query by available data. The data itself would not be stored in django, just a canonical identifier that would be used to retrieve the file through some other interface (e.g., neurobank).

It may make sense to store some additional fields, like the type of data (neural or acoustic) and timestamp. These would be duplicates of the canonical data, but would allow many basic queries to be made through django.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.