diff options
author | Arun Isaac | 2022-09-29 16:05:11 +0530 |
---|---|---|
committer | Arun Isaac | 2022-09-29 16:15:48 +0530 |
commit | ef17e6b57b267922ad0af2423e5d6d523458c8ed (patch) | |
tree | 170faab6da129caeacec3bfc1db824bfe4967eae /wqflask | |
parent | d47977406a8c86e9e3afbfeb6b1779b041f7f4f6 (diff) | |
download | genenetwork2-ef17e6b57b267922ad0af2423e5d6d523458c8ed.tar.gz |
Retrieve year as integer.
* wqflask/scripts/index.py (main): Retrieve year as an integer from
the SQL database.
* wqflask/wqflask/gsearch.py (GSearch.__init__): Convert year from
integer to string.
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/scripts/index.py | 5 | ||||
-rw-r--r-- | wqflask/wqflask/gsearch.py | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/wqflask/scripts/index.py b/wqflask/scripts/index.py index 447cc157..14e93dd1 100644 --- a/wqflask/scripts/index.py +++ b/wqflask/scripts/index.py @@ -120,6 +120,9 @@ def main(): write_document(db, trait["name"].bind(lambda name: f"Q{name}"), "gene", doc) with database_connection() as conn: + # FIXME: Some years are blank strings or strings that + # contain text other than the year. These should be fixed + # in the database and the year field must be made an integer. for i, trait in enumerate(sql_query_mdict(conn, """ SELECT Species.Name AS species, InbredSet.Name AS `group`, @@ -132,7 +135,7 @@ def main(): Publication.Abstract, Publication.Title, Publication.Authors AS authors, - IF(Publication.Year='', 0, Publication.Year) AS year, + IF(CONVERT(Publication.Year, UNSIGNED)=0, NULL, CONVERT(Publication.Year, UNSIGNED)) AS year, Publication.PubMed_ID AS pubmed_id, PublishXRef.LRS as lrs, PublishXRef.additive, diff --git a/wqflask/wqflask/gsearch.py b/wqflask/wqflask/gsearch.py index 861d8c9d..17c6c519 100644 --- a/wqflask/wqflask/gsearch.py +++ b/wqflask/wqflask/gsearch.py @@ -82,8 +82,7 @@ class GSearch: trait["authors_display"] = (trait.pop("authors").map( lambda authors: ", ".join(authors[:2] + ["et al."] if len(authors) >=2 else authors))) - trait["pubmed_text"] = (trait["year"].bind( - lambda year: Just(year) if year.isdigit() else Nothing)) + trait["pubmed_text"] = trait["year"].map(str) trait["pubmed_link"] = (trait["pubmed_id"].map( lambda pubmedid: webqtlConfig.PUBMEDLINK_URL % pubmedid)) self.trait_list.append(trait.data) |