Skip to content

Commit 0f4d472

Browse files
committed
Refactor get_templates query: adjust Cypher pattern and improve license and thumbnail handling
1 parent fe6454f commit 0f4d472

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/vfbquery/vfb_queries.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,18 +1503,19 @@ def get_templates(limit: int = -1, return_dataframe: bool = False):
15031503
return _get_templates_minimal(limit, return_dataframe)
15041504

15051505
# Define the main Cypher query
1506+
# Match full pattern to exclude template channel nodes
15061507
query = f"""
1507-
MATCH (t:Template)-[:INSTANCEOF]->(p:Class)
1508-
OPTIONAL MATCH (t)<-[:depicts]-(tc:Template)-[r:in_register_with]->(tc:Template)
1509-
OPTIONAL MATCH (t)-[:has_source]->(ds:DataSet)-[:has_license|license]->(lic:License)
1508+
MATCH (p:Class)<-[:INSTANCEOF]-(t:Template)<-[:depicts]-(tc:Template)-[r:in_register_with]->(tc)
1509+
OPTIONAL MATCH (t)-[:has_source]->(ds:DataSet)
1510+
OPTIONAL MATCH (ds)-[:has_license|license]->(lic:License)
15101511
RETURN t.short_form as id,
15111512
apoc.text.format("[%s](%s)",[COALESCE(t.symbol[0],t.label),t.short_form]) AS name,
15121513
apoc.text.join(t.uniqueFacets, '|') AS tags,
15131514
COALESCE(apoc.text.format("[%s](%s)",[COALESCE(ds.symbol[0],ds.label),ds.short_form]), '') AS dataset,
15141515
COALESCE(REPLACE(apoc.text.format("[%s](%s)",[COALESCE(lic.symbol[0],lic.label),lic.short_form]), '[null](null)', ''), '') AS license,
15151516
COALESCE(REPLACE(apoc.text.format("[![%s](%s '%s')](%s)",[COALESCE(t.symbol[0],t.label), REPLACE(COALESCE(r.thumbnail[0],""),"thumbnailT.png","thumbnail.png"), COALESCE(t.symbol[0],t.label), t.short_form]), "[![null]( 'null')](null)", ""), "") as thumbnail,
15161517
99 as order
1517-
ORDER BY id Desc
1518+
ORDER BY id DESC
15181519
"""
15191520

15201521
if limit != -1:

0 commit comments

Comments
 (0)