Exemplo n.º 1
0
    def cleanup(self):
        query = OAuthRequestToken.all().filter("created <", datetime.now() - EXPIRATION_WINDOW)
        token_count = query.count(CLEANUP_BATCH_SIZE)
        db.delete(query.fetch(CLEANUP_BATCH_SIZE))

        EXPIRATION_STATUS_CODES = timedelta(seconds=60 * 60 * 24 * 3)  # 3 days
        query = OAuthStatusCodes.all().filter("date <", datetime.now() - EXPIRATION_STATUS_CODES)
        codes_count = query.count(CLEANUP_BATCH_SIZE)
        db.delete(query.fetch(CLEANUP_BATCH_SIZE))
        return "Cleaned Token:%i Codes:%i entries" % (token_count, codes_count)
Exemplo n.º 2
0
 def logging_cleanup(self):
     EXPIRATION_WINDOW = timedelta(seconds=60 * 60 * 24)  # 1 hour
     query = OAuthStatusCodes.all().filter("date <", datetime.now() - EXPIRATION_WINDOW)
     count = query.count(CLEANUP_BATCH_SIZE)
     db.delete(query.fetch(CLEANUP_BATCH_SIZE))
     return "Cleaned %i entries" % count