Changeset 1769 for pykota/trunk
- Timestamp:
- 10/04/04 18:01:15 (20 years ago)
- Location:
- pykota/trunk
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/NEWS
r1768 r1769 24 24 - 1.20alpha19 : 25 25 26 - Improved user groups and user groups quotas dumps in dumpykota. 27 26 28 - Finished implementation of LDAP support in dumpykota. 27 29 -
pykota/trunk/pykota/storages/sql.py
r1762 r1769 22 22 # 23 23 # $Log$ 24 # Revision 1.50 2004/10/04 16:01:15 jalet 25 # More complete dumps for groups and groups quotas 26 # 24 27 # Revision 1.49 2004/10/02 13:33:13 jalet 25 28 # Some work done of user's charset handling in database dumps. … … 115 118 def extractGroups(self) : 116 119 """Extracts all group records.""" 117 result = self.doRawSearch("SELECT * FROM groups ORDER BYid ASC")120 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") 118 121 return self.prepareRawResult(result) 119 122 … … 182 185 """Extracts group information given its name.""" 183 186 group = StorageGroup(self, groupname) 184 result = self.doSearch("SELECT * FROM groups WHERE groupname=%sLIMIT 1" % self.doQuote(groupname))187 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)) 185 188 if result : 186 189 fields = result[0] … … 188 191 group.Name = fields.get("groupname", groupname) 189 192 group.LimitBy = fields.get("limitby") 190 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)) 191 if result : 192 fields = result[0] 193 group.AccountBalance = fields.get("balance") 194 group.LifeTimePaid = fields.get("lifetimepaid") 193 group.AccountBalance = fields.get("balance") 194 group.LifeTimePaid = fields.get("lifetimepaid") 195 195 group.Exists = 1 196 196 return group … … 230 230 grouppquota = StorageGroupPQuota(self, group, printer) 231 231 if group.Exists : 232 result = self.doSearch("SELECT id, softlimit, hardlimit, datelimit FROM grouppquota WHERE groupid=%s AND printerid=%s" % (self.doQuote(group.ident), self.doQuote(printer.ident)))232 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))) 233 233 if result : 234 234 fields = result[0] … … 237 237 grouppquota.HardLimit = fields.get("hardlimit") 238 238 grouppquota.DateLimit = fields.get("datelimit") 239 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))) 240 if result : 241 fields = result[0] 242 grouppquota.PageCounter = fields.get("pagecounter") 243 grouppquota.LifePageCounter = fields.get("lifepagecounter") 239 grouppquota.PageCounter = fields.get("pagecounter") 240 grouppquota.LifePageCounter = fields.get("lifepagecounter") 244 241 grouppquota.Exists = 1 245 242 return grouppquota