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)
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() )
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) )
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)
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())