コード例 #1
0
    def get(self):
        two_weeks_ago = datetime.now() - timedelta(
            days=guru_globals.default_question_scan_lifespan_days)
        old_questions_followers = QuestionFollower.all().filter(
            'created < ', two_weeks_ago)
        db.delete(old_questions_followers)

        old_questions = Question.all().filter('end_time < ', datetime.now())
        db.delete(old_questions)
コード例 #2
0
    def _scan(self):
        domain_ids = {}
        for question in Question.all().order('domain'):
            domain_ids.setdefault(question.domain,
                                  []).append(str(question.question_id))

        for domain in domain_ids:
            for chunk in chunks(domain_ids[domain],
                                guru_globals.question_batch_size):
                AnswerTask.create_and_queue(domain, chunk)
                CommentTask.create_and_queue(domain, chunk)