churchyard / copr / copr

Forked from copr/copr 6 years ago
Clone

a8f4001 frontend: bettter preload /pending-jobs/ queries

2 files Authored by praiskup 3 years ago, Committed by praiskup 3 years ago,
    frontend: bettter preload /pending-jobs/ queries
    
    First, we don't have to do the 'joinedload' action for normal single-row
    queries (like /get-srpm-build-task/<51816>) where we (a) can rely on
    lazy-loads and we (b) need a full info about the task (all fields).
    So let's stop doing so (when for_backend=False, aka "for builder").
    
    Then, backend needs only a very limited info about the task, like the
    task sandbox, project name, etc. so it can correctly calculate the task
    priority.  It doesn't make sense to load all the fields into ORM:
    https://docs.sqlalchemy.org/en/13/faq/performance.html .
    Therefore, when `for_backend=True`, we only lazy load those fields that
    are really necessary.
    
    While I'm on it, I also made the 'joinedload' more careful - so really
    no other queries (except for batches, see previous patch) is needed.