diff options
| author | Frederick Muriuki Muriithi | 2026-04-16 14:49:50 -0500 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2026-04-16 14:49:50 -0500 |
| commit | e734e61219e1e23784cf137c24f5102e6feac8ca (patch) | |
| tree | 9b9333b24dfa3dac9cc6630d1ccf7466c00ddc1e /uploader/publications | |
| parent | d6d093f89bb4ed041e63376f42628a1e3f143b5c (diff) | |
| download | gn-uploader-e734e61219e1e23784cf137c24f5102e6feac8ca.tar.gz | |
Attach publication details to each phenotype trait.
Diffstat (limited to 'uploader/publications')
| -rw-r--r-- | uploader/publications/models.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/uploader/publications/models.py b/uploader/publications/models.py index dcfa02b..d913144 100644 --- a/uploader/publications/models.py +++ b/uploader/publications/models.py @@ -101,6 +101,20 @@ def fetch_publication_by_id(conn: Connection, publication_id: int) -> dict: return dict(_res) if _res else {} +def fetch_publications_by_ids( + conn: Connection, publications_ids: tuple[int, ...] +) -> tuple[dict, ...]: + """Fetch publications with the given IDs.""" + if len(publications_ids) == 0: + return tuple() + + with conn.cursor(cursorclass=DictCursor) as cursor: + paramstr = ", ".join(["%s"] * len(publications_ids)) + cursor.execute(f"SELECT * FROM Publication WHERE Id IN ({paramstr})", + tuple(publications_ids)) + return tuple(dict(row) for row in cursor.fetchall()) + + def fetch_publication_phenotypes( conn: Connection, publication_id: int) -> Iterable[dict]: """Fetch all phenotypes linked to this publication.""" |
