1144f6e frontend, python, cli: more effective query of packages with their latest builds

Authored and Committed by frostyx 3 years ago
    frontend, python, cli: more effective query of packages with their latest builds
    
    Fix #757
    
    Instead obtaining a list of packages in copr-cli and then sending
    another request per package to obtain their latest or latest succeeded
    build, let's just send a `builds` dictionary within every package.
    
    This addition is not required by every user, so let's make it opt-in.
    When any build are requested, then the `builds` field will contain
    `None` values, such as
    
        [
          {
            "name": "foo",
            ...
            "builds": {
              "latest": null,
              "latest_succeeded": null
            },
          }
        ]
    
    When a request from client contains either of
    
        "with_latest_build": True,
        "with_latest_succeeded_build": True,
    
    the particular build information is going to be filled with a build
    dictionary, that has the exact same structure as a build queried through
    `BuildProxy`.
    
    Lastly, copr-cli provides also `--with-all-builds` for obtaining a
    package with all it's builds. This option is not (yet) reworked and
    added to the API, so this will still send an additional request per
    package. The list of the package builds will be then appended to the
    `builds` dictionary and accessible by e.g. `package["builds"]["all"]`.
    
    Some measurements at the end. The speed of both
    
        $ copr-cli list-packages foo/bar
        $ copr-cli list-packages foo/bar --with-all-builds
    
    remains unchanged. However, these
    
        $ copr-cli list-packages foo/bar --with-latest-build
        $ copr-cli list-packages foo/bar --with-latest-succeeded
    
    are now finished within 30-40s for the most gigantic projects with 15k+
    packages. That is a big improvement and huge drop from previous ~12
    minutes. Speed of those commands is now comparable with rendering the
    packages page in a browser, which takes about the same time (~40s).
    
        
file modified
+4 -11