コード例 #1
0
ファイル: clean.py プロジェクト: cklzqw/gaeaib
def do_clean(cursor=None):

  bq = BlobInfo.all()

  if cursor:
    bq.with_cursor(cursor)

  blob = bq.get()

  if not blob:
    return

  key = str(blob.key())

  thq = Thread.all(keys_only=True)
  thq.filter("images", key)

  th = thq.get()

  if th:
    logging.info("thread: %r" % th)
  else:
    logging.info("no thread for image %r" % key)

    blob.delete()

  deferred.defer(do_clean, bq.cursor(), _countdown=30)
コード例 #2
0
ファイル: clean.py プロジェクト: a37912/gaeaib
def do_clean_board(cursor=None):
  thq = Board.all()

  if cursor:
    thq.with_cursor(cursor)

  board = thq.get()

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

  """
  board_c = BoardCounter(key_name=board.key().name())
  board_c.counter = board._entity.get('counter')
  board_c.put()
  """
  keys = board.linked
  if not keys:
    keys = [ (board.code, th) for th in board.thread]

  threads = Thread.load_list(keys)

  board.linked = [th for (th,data) in zip(keys, threads) if data]
  fill_board(board)

  board.put()
  #Cache.remove("board", board.key().name())

  deferred.defer(do_clean_board, thq.cursor())
コード例 #3
0
ファイル: clean.py プロジェクト: strogo/gaeaib
def fill_board(board):
  threads = Thread.all(keys_only=True)
  threads.filter("board", board)
  threads.order("-__key__")

  for thread in threads.fetch(TMAX):

    if len(board.thread) >= TMAX:
      return

    if thread.id() not in board.thread:
      board.thread.append(  thread.id() )
コード例 #4
0
ファイル: clean.py プロジェクト: a37912/gaeaib
def fill_board(board):
  logging.info("fill board %s" % board.code)
  threads = Thread.all()
  threads.filter("boards", board.code)
  threads.order("-id")

  for thread in threads.fetch(TMAX):

    logging.info("here is thread %r" % thread)

    if len(board.linked) >= TMAX:
      return

    if (thread.board,thread.id) not in board.linked:
      logging.info("add now")
      board.linked.append( (thread.board,thread.id) )
コード例 #5
0
ファイル: clean.py プロジェクト: cklzqw/gaeaib
def do_clean_board(cursor=None):
  thq = Board.all()

  if cursor:
    thq.with_cursor(cursor)

  board = thq.get()

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

  threads = Thread.load_list(board.thread, board.key().name())

  board.thread = [th for (th,data) in threads if data]
  board.put()

  deferred.defer(do_clean_board, thq.cursor())
コード例 #6
0
ファイル: clean.py プロジェクト: cklzqw/gaeaib
def do_clean_thread(cursor=None):
  thq = Thread.all(keys_only=True)

  if cursor:
    thq.with_cursor(cursor)

  thread = thq.get()

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

  board = Board.get(thread.parent())

  if not board or thread.id() not in board.thread:
    db.delete(thread)
    logging.info("purged thread")

  deferred.defer(do_clean_thread, thq.cursor(), _countdown=10)
コード例 #7
0
ファイル: clean.py プロジェクト: strogo/gaeaib
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())