From 120ba33ff99c092464e485b11080297eddd6a186 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Apr 02 2020 09:41:18 +0000 Subject: Simplify co-package query. It fetches 10 extra fields, so drop those, and then let sqlite handle uniqueness. --- diff --git a/mdapi/__init__.py b/mdapi/__init__.py index e5b482a..4dfc286 100644 --- a/mdapi/__init__.py +++ b/mdapi/__init__.py @@ -153,7 +153,7 @@ async def _expand_pkg_info(pkgs, branch, repotype=None): if pkg.rpm_sourcerpm: async with db.execute(GET_CO_PACKAGE, (pkg.rpm_sourcerpm,)) as cursor: copkgs = await cursor.fetchall() - out['co-packages'] = list({cpkg[2] for cpkg in copkgs}) + out['co-packages'] = [cpkg[0] for cpkg in copkgs] else: out['co-packages'] = [] out['repo'] = repotype if repotype else 'release' diff --git a/mdapi/db.py b/mdapi/db.py index 95c6d90..4f132d5 100644 --- a/mdapi/db.py +++ b/mdapi/db.py @@ -46,17 +46,7 @@ GET_PACKAGE_INFO = """SELECT rowid, FROM {} WHERE pkgKey = ?""" -GET_CO_PACKAGE = """SELECT pkgKey, - pkgId, - name, - rpm_sourcerpm, - epoch, - version, - release, - arch, - summary, - description, - url +GET_CO_PACKAGE = """SELECT DISTINCT(name) FROM packages WHERE rpm_sourcerpm = ?"""