Added category count to print-statistics output.
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 4 Feb 2006 14:35:46 +0000 (14:35 +0000)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 4 Feb 2006 14:35:46 +0000 (14:35 +0000)
src/packages/kofoto/commandline/main.py
src/packages/kofoto/shelf.py

index 11a7937..a6b7bf7 100755 (executable)
@@ -855,6 +855,7 @@ def cmdPrintStatistics(env, dummy):
     """Handler for the print-statistics command."""
     stats = env.shelf.getStatistics()
     env.out("Number of albums: %d\n" % stats["nalbums"])
+    env.out("Number of categories: %d\n" % stats["ncategories"])
     env.out("Number of images: %d\n" % stats["nimages"])
     env.out("Number of image versions: %d\n" % stats["nimageversions"])
 
index 85e638a..6afd09a 100644 (file)
@@ -301,6 +301,7 @@ class Shelf:
         The returned value is a mapping with the following keys:
 
         nalbums        -- Number of albums.
+        ncategories    -- Number of categories.
         nimages        -- Number of images.
         nimageversions -- Number of image versions.
         """
@@ -310,6 +311,10 @@ class Shelf:
             " select count(*)"
             " from   album")
         nalbums = int(cursor.fetchone()[0])
+        cursor.execute(
+            " select count(*)"
+            " from   category")
+        ncategories = int(cursor.fetchone()[0])
         cursor.execute(
             " select count(*)"
             " from   image")
@@ -320,6 +325,7 @@ class Shelf:
         nimageversions = int(cursor.fetchone()[0])
         return {
             "nalbums": nalbums,
+            "ncategories": ncategories,
             "nimages": nimages,
             "nimageversions": nimageversions,
             }