aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
Diffstat (limited to 'backend')
-rwxr-xr-xbackend/tilo.py7
-rw-r--r--backend/tolData/README.md4
2 files changed, 8 insertions, 3 deletions
diff --git a/backend/tilo.py b/backend/tilo.py
index bb7af16..196f193 100755
--- a/backend/tilo.py
+++ b/backend/tilo.py
@@ -36,7 +36,7 @@ ROOT_NAME = "cellular organisms"
# Classes for objects sent as responses (matches lib.ts types in client-side code)
class TolNode:
" Used when responding to 'node' and 'chain' requests "
- def __init__(self, otolId, children, parent=None, tips=0, pSupport=False, commonName=None, imgName=None):
+ def __init__(self, otolId, children, parent=None, tips=0, pSupport=False, commonName=None, imgName=None, iucn=None):
self.otolId = otolId # string | null
self.children = children # string[]
self.parent = parent # string | null
@@ -44,6 +44,7 @@ class TolNode:
self.pSupport = pSupport # boolean
self.commonName = commonName # null | string
self.imgName = imgName # null | string | [string,string] | [null, string] | [string, null]
+ self.iucn = iucn # null | string
class SearchSugg:
" Represents a search suggestion "
def __init__(self, name, canonicalName=None):
@@ -133,6 +134,10 @@ def lookupNodes(names, tree, dbCur):
query = f"SELECT name, alt_name FROM names WHERE pref_alt = 1 AND name IN ({queryParamStr})"
for (name, altName) in dbCur.execute(query, names):
nameToNodes[name].commonName = altName
+ # Get IUCN status
+ query = f"SELECT name, iucn FROM node_iucn WHERE name IN ({queryParamStr})"
+ for (name, iucn) in dbCur.execute(query, names):
+ nameToNodes[name].iucn = iucn
#
return nameToNodes
def lookupSuggs(searchStr, suggLimit, tree, dbCur):
diff --git a/backend/tolData/README.md b/backend/tolData/README.md
index 1248098..ece07b4 100644
--- a/backend/tolData/README.md
+++ b/backend/tolData/README.md
@@ -74,8 +74,8 @@ Some of the scripts use third-party packages:
files in wikidata/, and 'dump-index files' in enwiki/, as specified
in their READMEs.
2. Run genMappingData.py, which adds the `eol_ids` and `wiki_ids` tables,
- using the files obtained above, and the `nodes` table. It also uses
- 'picked mappings' files, if they exist.
+ as well as `node_iucn`. It uses the files obtained above, the `nodes` table,
+ and 'picked mappings' files, if they exist.
- pickedEolIds.txt contains lines like `3785967|405349`, specifying
an otol ID and an eol ID to map it to. The eol ID can be empty,
in which case the otol ID won't be mapped.