~nataliabidart/canonical-identity-provider/better-preferredemail

« back to all changes in this revision

Viewing changes to src/identityprovider/management/commands/clean_sessions.py

  • Committer: Tarmac
  • Author(s): Diogo Baeder de Paula Pinto
  • Date: 2013-10-25 18:51:19 UTC
  • mfrom: (1063.2.34 security)
  • Revision ID: tarmac-20131025185119-yega6aq0n0luge8z
[r=diogobaeder,ricardokirkner] Dynamically evaluating the session keys to clean, when a limit is given, to optimize the query

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
                    action='store',
22
22
                    help='Cleanup records created until this date. The format '
23
23
                    'should be %Y-%m-%d'),
 
24
        make_option('--dry-run', dest='dry_run', default=False,
 
25
                    action='store_true', help='Do not delete for real, just '
 
26
                    'print what would have been done.'),
24
27
    )
25
28
    help = _("""Clean sessions created until provided date.""")
26
29
 
27
30
    def handle(self, *args, **options):
28
31
        creation_date = datetime.strptime(options['creation_date'], '%Y-%m-%d')
29
 
        clean_sessions_until(creation_date, limit=options['limit'])
 
32
        result = clean_sessions_until(creation_date, limit=options['limit'],
 
33
                                      dry_run=options['dry_run'])
 
34
        if result is not None:
 
35
            self.stdout.write(result)