Community Portal

Integrate image in reference space database field

Created on Wednesday 18 November 2020, 07:29

Back to task list
  • ID
    513418
  • Project
    Metabolism of Cities Data Hub
  • Status
    Completed
  • Priority
    Medium
  • Type
    Programming work
  • Assigned to
    Paul Hoekman
  • Subscribers
    Paul Hoekman

You are not logged in

Log In Register

Please join us and let's build things, together!

Description

Right now, we have a dynamically generated @property in the ReferenceSpace model, which in fact is a lookup of the Photo table, and it selects the first pic there. So far, so good. However, it does mean that we do a single lookup for every space that we loop through. And we can't do prefetch_related as this isn't a regular foreign key relationship. What we should do instead is copy that photo URL to the image field which exists on every Record (of which ReferenceSpace is a derived model), and simply use signals to update them where needed. Would save a lot of queries.

Discussion and updates


New task was created


Task was assigned to Paul Hoekman


Status change: Open → In Progress


This was done. I have still left the @photo property that generates the db call as it may still be used somewhere -- I'll keep my eyes out for it in the coming months and then phase it out completely. But this change should save a whole lot db requests and wasn't even that tricky. Good good good.


Status change: In Progress → Completed