Changeset 1769 for pykota/trunk

Show
Ignore:
Timestamp:
10/04/04 18:01:15 (20 years ago)
Author:
jalet
Message:

More complete dumps for groups and groups quotas

Location:
pykota/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/NEWS

    r1768 r1769  
    2424    - 1.20alpha19 : 
    2525     
     26        - Improved user groups and user groups quotas dumps in dumpykota. 
     27         
    2628        - Finished implementation of LDAP support in dumpykota. 
    2729         
  • pykota/trunk/pykota/storages/sql.py

    r1762 r1769  
    2222# 
    2323# $Log$ 
     24# Revision 1.50  2004/10/04 16:01:15  jalet 
     25# More complete dumps for groups and groups quotas 
     26# 
    2427# Revision 1.49  2004/10/02 13:33:13  jalet 
    2528# Some work done of user's charset handling in database dumps. 
     
    115118    def extractGroups(self) : 
    116119        """Extracts all group records.""" 
    117         result = self.doRawSearch("SELECT * FROM groups ORDER BY id 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") 
    118121        return self.prepareRawResult(result) 
    119122         
     
    182185        """Extracts group information given its name.""" 
    183186        group = StorageGroup(self, groupname) 
    184         result = self.doSearch("SELECT * FROM groups WHERE groupname=%s LIMIT 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)) 
    185188        if result : 
    186189            fields = result[0] 
     
    188191            group.Name = fields.get("groupname", groupname) 
    189192            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") 
    195195            group.Exists = 1 
    196196        return group 
     
    230230        grouppquota = StorageGroupPQuota(self, group, printer) 
    231231        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))) 
    233233            if result : 
    234234                fields = result[0] 
     
    237237                grouppquota.HardLimit = fields.get("hardlimit") 
    238238                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") 
    244241                grouppquota.Exists = 1 
    245242        return grouppquota