diff options
author | Bryan Newbold <bnewbold@archive.org> | 2021-01-14 23:30:00 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@archive.org> | 2021-01-14 23:30:06 -0800 |
commit | 677a66ca0deebaa001b7946c35d41e25ada0fc1f (patch) | |
tree | 736a436906512c821f27680db53d86c2b41d3b82 /fatcat_scholar | |
parent | 9da8e36c9360ec63e161ac92f455b48614d8b636 (diff) | |
download | fatcat-scholar-677a66ca0deebaa001b7946c35d41e25ada0fc1f.tar.gz fatcat-scholar-677a66ca0deebaa001b7946c35d41e25ada0fc1f.zip |
search: parse and embed a copy of ScholarDoc object in results
Maybe should refactor this to simply replace the object? Hrm.
Diffstat (limited to 'fatcat_scholar')
-rw-r--r-- | fatcat_scholar/search.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/fatcat_scholar/search.py b/fatcat_scholar/search.py index d3cca80..e586bee 100644 --- a/fatcat_scholar/search.py +++ b/fatcat_scholar/search.py @@ -18,6 +18,7 @@ from pydantic import BaseModel from fatcat_scholar.config import settings from fatcat_scholar.identifiers import * +from fatcat_scholar.schema import ScholarDoc # i18n note: the use of gettext below doesn't actually do the translation here, # it just ensures that the strings are caught by babel for translation later @@ -129,7 +130,11 @@ def transform_es_results(resp: Response) -> List[dict]: # ensure collapse_key is a single value, not an array if type(h["collapse_key"]) == list: h["collapse_key"] = h["collapse_key"][0] - + # add ScholarDoc object as a helper (eg, to call python helpers) + try: + h["_obj"] = ScholarDoc.parse_obj(h) + except: + pass return results |