def populate_reverse_search() -> None: excluded_post_ids = image_hash.get_all_paths() post_ids_to_hash = (db.session.query(model.Post.post_id).filter( (model.Post.type == model.Post.TYPE_IMAGE) | (model.Post.type == model.Post.TYPE_ANIMATION)).filter( ~model.Post.post_id.in_(excluded_post_ids)).order_by( model.Post.post_id.asc()).all()) for post_ids_chunk in util.chunks(post_ids_to_hash, 100): posts_chunk = (db.session.query(model.Post).filter( model.Post.post_id.in_(post_ids_chunk)).all()) for post in posts_chunk: content_path = get_post_content_path(post) if files.has(content_path): image_hash.add_image(post.post_id, files.get(content_path))
def populate_reverse_search(): excluded_post_ids = image_hash.get_all_paths() post_ids_to_hash = (db.session .query(db.Post.post_id) .filter( (db.Post.type == db.Post.TYPE_IMAGE) | (db.Post.type == db.Post.TYPE_ANIMATION)) .filter(~db.Post.post_id.in_(excluded_post_ids)) .order_by(db.Post.post_id.asc()) .all()) for post_ids_chunk in util.chunks(post_ids_to_hash, 100): posts_chunk = (db.session .query(db.Post) .filter(db.Post.post_id.in_(post_ids_chunk)) .all()) for post in posts_chunk: content_path = get_post_content_path(post) if files.has(content_path): image_hash.add_image(post.post_id, files.get(content_path))