Commits

Ada Young committed 63b4476

Updated NSTAT to use single db query

Comments (0)

Files changed (1)

         Note("NewDB: There are no results in the buffer, try searching for something first with newsdb:search <org> <search expression>")
 
 def NStat():
-    cursor.execute("SELECT orgname FROM orgs")
+    cursor.execute("SELECT orgname, COUNT(newsid) from org_news n join orgs o on n.orgid = o.id group by orgname")
     results = cursor.fetchall()
     if len(results) > 0:
         orgnames = {}
         for i in results:
-            cursor.execute("SELECT COUNT(newsid) FROM org_news n JOIN orgs o ON n.orgid=o.id WHERE orgname=?", (i[0], ))
-            orgnames[i[0]] = cursor.fetchone()[0]
+            orgnames[i[0]] = i[1]
         for i in orgnames.keys():
             if len(i) > 30:
                 o_name = i[30:]