Beispiel #1
0
def do_clean_thread(cursor=None):
  thq = ThreadIndex.all(keys_only=True)
  thq.filter("post_count", 1)

  if cursor:
    thq.with_cursor(cursor)

  thread_idx = thq.get()

  if not thread_idx:
    logging.info("stop thread clean")
    return

  thread = db.get(thread_idx.parent())

  if thread:

    board = Board.get_by_key_name(thread.board)

    if len(thread.posts) == 1:
      db.delete(thread)
    else:
      logging.error("crap, post count %d, %r" % (len(thread.posts), thread_idx))
  else:
    logging.error("crap, no thread for %r" % thread_idx)

  deferred.defer(do_clean_thread, thq.cursor())
Beispiel #2
0
def do_clean_thread(cursor=None):
  thq = Thread.all()
  thq.filter("posts_count <", 5)

  if cursor:
    thq.with_cursor(cursor)

  thread = thq.get()

  if not thread:
    logging.info("stop thread clean")
    return

  board = Board.get_by_key_name(thread.board)

  if len(thread.posts) < 5: # FIXME: magic number
    db.delete(thread)
    logging.info("purged thread")
  else:
    assert False, "oops invalid post count"

  deferred.defer(do_clean_thread, thq.cursor())