Index: pykota/trunk/pykota/storages/sql.py
===================================================================
--- pykota/trunk/pykota/storages/sql.py (revision 1762)
+++ pykota/trunk/pykota/storages/sql.py (revision 1769)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.50  2004/10/04 16:01:15  jalet
+# More complete dumps for groups and groups quotas
+#
 # Revision 1.49  2004/10/02 13:33:13  jalet
 # Some work done of user's charset handling in database dumps.
@@ -115,5 +118,5 @@
     def extractGroups(self) :
         """Extracts all group records."""
-        result = self.doRawSearch("SELECT * FROM groups ORDER BY id ASC")
+        result = self.doRawSearch("SELECT groups.*,sum(balance) AS balance, sum(lifetimepaid) as lifetimepaid FROM groups,users WHERE users.id IN (SELECT userid FROM groupsmembers WHERE groupid=groups.id) GROUP BY groups.id,groups.groupname,groups.limitby ORDER BY groups.id ASC")
         return self.prepareRawResult(result)
         
@@ -182,5 +185,5 @@
         """Extracts group information given its name."""
         group = StorageGroup(self, groupname)
-        result = self.doSearch("SELECT * FROM groups WHERE groupname=%s LIMIT 1" % self.doQuote(groupname))
+        result = self.doSearch("SELECT groups.*,sum(balance) AS balance, sum(lifetimepaid) AS lifetimepaid FROM groups,users WHERE groupname=%s AND users.id IN (SELECT userid FROM groupsmembers WHERE groupid=groups.id) GROUP BY groups.id,groups.groupname,groups.limitby LIMIT 1" % self.doQuote(groupname))
         if result :
             fields = result[0]
@@ -188,9 +191,6 @@
             group.Name = fields.get("groupname", groupname)
             group.LimitBy = fields.get("limitby")
-            result = self.doSearch("SELECT SUM(balance) AS balance, SUM(lifetimepaid) AS lifetimepaid FROM users WHERE id IN (SELECT userid FROM groupsmembers WHERE groupid=%s)" % self.doQuote(group.ident))
-            if result :
-                fields = result[0]
-                group.AccountBalance = fields.get("balance")
-                group.LifeTimePaid = fields.get("lifetimepaid")
+            group.AccountBalance = fields.get("balance")
+            group.LifeTimePaid = fields.get("lifetimepaid")
             group.Exists = 1
         return group
@@ -230,5 +230,5 @@
         grouppquota = StorageGroupPQuota(self, group, printer)
         if group.Exists :
-            result = self.doSearch("SELECT id, softlimit, hardlimit, datelimit FROM grouppquota WHERE groupid=%s AND printerid=%s" % (self.doQuote(group.ident), self.doQuote(printer.ident)))
+            result = self.doSearch("SELECT grouppquota.*,sum(pagecounter) AS pagecounter,sum(lifepagecounter) AS lifepagecounter FROM grouppquota,userpquota WHERE groupid=%s AND grouppquota.printerid=%s AND userpquota.printerid=%s AND userid IN (SELECT userid FROM groupsmembers WHERE groupsmembers.groupid=grouppquota.groupid) GROUP BY grouppquota.id,grouppquota.groupid,grouppquota.printerid,grouppquota.softlimit,grouppquota.hardlimit,grouppquota.datelimit" % (self.doQuote(group.ident), self.doQuote(printer.ident), self.doQuote(printer.ident)))
             if result :
                 fields = result[0]
@@ -237,9 +237,6 @@
                 grouppquota.HardLimit = fields.get("hardlimit")
                 grouppquota.DateLimit = fields.get("datelimit")
-                result = self.doSearch("SELECT SUM(lifepagecounter) AS lifepagecounter, SUM(pagecounter) AS pagecounter FROM userpquota WHERE printerid=%s AND userid IN (SELECT userid FROM groupsmembers WHERE groupid=%s)" % (self.doQuote(printer.ident), self.doQuote(group.ident)))
-                if result :
-                    fields = result[0]
-                    grouppquota.PageCounter = fields.get("pagecounter")
-                    grouppquota.LifePageCounter = fields.get("lifepagecounter")
+                grouppquota.PageCounter = fields.get("pagecounter")
+                grouppquota.LifePageCounter = fields.get("lifepagecounter")
                 grouppquota.Exists = 1
         return grouppquota
Index: pykota/trunk/NEWS
===================================================================
--- pykota/trunk/NEWS (revision 1768)
+++ pykota/trunk/NEWS (revision 1769)
@@ -24,4 +24,6 @@
     - 1.20alpha19 :
     
+        - Improved user groups and user groups quotas dumps in dumpykota.
+        
         - Finished implementation of LDAP support in dumpykota.
         
