Changeset 4091199


Ignore:
Timestamp:
Feb 26, 2012, 4:13:40 PM (14 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, space-access, stable, stage
Children:
80a8145
Parents:
99747bd
git-author:
Alex Dehnert <adehnert@…> (02/26/12 16:13:40)
git-committer:
Alex Dehnert <adehnert@…> (02/26/12 16:13:40)
Message:

Summarize the groups/diffs.py output more

File:
1 edited

Legend:

Unmodified
Added
Removed
  • asadb/groups/diffs.py

    r99747bd r4091199  
    6464        self.since = since
    6565        self.now = now
     66        self.stats = collections.defaultdict(lambda: 0)
    6667
    6768    def handle_group(self, before, after, before_fields, after_fields, ):
     
    102103                prev_group = signatory.group
    103104            else:
    104                 print "Ignoring role %s (signatory %s)" % (signatory.role.slug, signatory, )
     105                self.stats["role." + signatory.role.slug] += 1
     106                #print "Ignoring role %s (signatory %s)" % (signatory.role.slug, signatory, )
    105107
    106108    def end_run(self, ):
     109        print "\nChange stats for email to %s:" % (self.address, )
     110        for stat_key, stat_val in self.stats.items():
     111            print "%20s:\t%6d" % (stat_key, stat_val, )
     112        print ""
     113
    107114        message = "\n\n".join(self.updates)
    108115        signatories_message = "\n".join(self.signatory_updates)
     
    199206    return objs
    200207
    201 def diff_objects(objs, since, callbacks):
     208def diff_objects(objs, since, callbacks, stats, ):
    202209    revs  = reversion.models.Revision.objects.all()
    203210    old_revs = revs.filter(date_created__lte=since)
     
    213220            if len(before_versions) > 0:
    214221                before = before_versions[0]
     222                stats['change_old'] += 1
    215223            else:
    216224                # New group that's been edited since. Diff against the creation
    217225                # (since creation sent mail, but later changes haven't)
    218226                after = after_versions[-1]
    219             print "Change?: before=%s (%d), after=%s (%d), type=%s, new=%s" % (
    220                 before, before.pk,
    221                 after, after.pk,
    222                 after.type, after.field_dict,
    223             )
     227                stats['change_new'] += 1
     228            stats['change_total'] += 1
     229            #print "Change?: before=%s (%d), after=%s (%d), type=%s, new=%s" % (
     230            #    before, before.pk,
     231            #    after, after.pk,
     232            #    after.type, after.field_dict,
     233            #)
    224234            before_fields = before.field_dict
    225235            after_fields = after.field_dict
     
    228238        else:
    229239            # New group that's only been edited once
    230             pass
     240            stats['new_group'] += 1
    231241
    232242def diff_signatories(since, now, callbacks):
     
    245255    objs = recent_groups(since=recent)
    246256    callbacks = build_callbacks()
     257    stats = collections.defaultdict(lambda: 0)
    247258    for callback in callbacks: callback.start_run(since=recent, now=now, )
    248     diff_objects(objs, since=recent, callbacks=callbacks)
     259    diff_objects(objs, since=recent, callbacks=callbacks, stats=stats)
    249260    diff_signatories(recent, now, callbacks=callbacks, )
    250261    for callback in callbacks: callback.end_run()
    251262
     263    print "\nOverall change stats:"
     264    for stat_key, stat_val in stats.items():
     265        print "%20s:\t%6d" % (stat_key, stat_val, )
     266    print ""
     267
    252268if __name__ == '__main__':
    253269    generate_diffs()
Note: See TracChangeset for help on using the changeset viewer.