changeset 56:42d7888272a0 default tip

Implement fetch_classifications().
author David A. Holland
date Sun, 10 Apr 2022 19:37:18 -0400
parents 40f64a96481f
children
files shelltools/query-pr/query.py
diffstat 1 files changed, 44 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/shelltools/query-pr/query.py	Sun Apr 10 19:36:29 2022 -0400
+++ b/shelltools/query-pr/query.py	Sun Apr 10 19:37:18 2022 -0400
@@ -40,6 +40,12 @@
 # be present.
 #
 
+# loaded below
+hierclasses = []
+flatclasses = []
+textclasses = []
+tagclasses = []
+
 class QueryBuilder:
         # these fields are in the PRs table
         prtable_fields = [
@@ -270,6 +276,41 @@
 # end querydb
 
 ############################################################
+# classification schemes
+
+#
+# Load the available classification schemes from the database.
+# We only need their names up front.
+#
+def fetch_classifications():
+        global hierclasses, flatclasses, textclasses, tagclasses
+        hierclasses = querydb('''
+------------------------------
+        SELECT name FROM hierclass_names ORDER BY ordering;
+------------------------------
+''', [])
+        flatclasses = querydb('''
+------------------------------
+        SELECT name FROM flatclass_names ORDER BY ordering;
+------------------------------
+''', [])
+        textclasses = querydb('''
+------------------------------
+        SELECT name FROM textclass_names ORDER BY ordering;
+------------------------------
+''', [])
+        tagclasses = querydb('''
+------------------------------
+        SELECT name FROM tagclass_names ORDER BY ordering;
+------------------------------
+''', [])
+        # The results come back as monoples, unwrap that
+        hierclasses = [name for (name,) in hierclasses]
+        flatclasses = [name for (name,) in flatclasses]
+        textclasses = [name for (name,) in textclasses]
+        tagclasses = [name for (name,) in tagclasses]
+
+############################################################
 # query class for searches
 # XXX: obsolete, remove
 
@@ -1337,16 +1378,16 @@
                         sys.stderr.write(msg)
                         exit(1)
 
-        return Invocation(ops)
+        return (Invocation(ops), paranoid)
 # end getargs
 
 ############################################################
 # main
 
-todo = getargs(sys.argv)
+(todo, paranoid) = getargs(sys.argv)
 #todo.dump(Dumper(sys.stdout))
 
-opendb()
+opendb(paranoid)
 fetch_classifications()
 todo = compile(todo)
 run(todo)