diff --git a/server/szurubooru/api/post_api.py b/server/szurubooru/api/post_api.py index 96588ce5..ea034a8f 100644 --- a/server/szurubooru/api/post_api.py +++ b/server/szurubooru/api/post_api.py @@ -291,7 +291,6 @@ def get_pool_posts_around( auth.verify_privilege(ctx.user, "posts:list") auth.verify_privilege(ctx.user, "pools:list") auth.verify_privilege(ctx.user, "pools:view") - _search_executor_config.user = ctx.user # never calling _search_executor so why are we setting user? post = _get_post(params) results = posts.get_pool_posts_around(post) return posts.serialize_pool_posts_around(ctx, results) diff --git a/server/szurubooru/func/posts.py b/server/szurubooru/func/posts.py index 069d4009..7098e894 100644 --- a/server/szurubooru/func/posts.py +++ b/server/szurubooru/func/posts.py @@ -991,7 +991,6 @@ def get_pool_posts_around(post: model.Post) -> List[PoolPostsAround]: last_post = pool.posts[-1] around = PoolPostsAround(pool, first_post, prev_post, next_post, last_post) - logger.info("===============> WE NOW HAVE: %s", around) results.append(around) return results diff --git a/server/szurubooru/migrations/functions.py b/server/szurubooru/migrations/functions.py deleted file mode 100644 index ae39e62b..00000000 --- a/server/szurubooru/migrations/functions.py +++ /dev/null @@ -1,68 +0,0 @@ -from alembic_utils.pg_function import PGFunction - -get_pool_posts_around = PGFunction.from_sql(""" -CREATE OR REPLACE FUNCTION public.get_pool_posts_around( - P_POOL_ID int, - P_POST_ID int -) - RETURNS TABLE ( - ORD int, - POOL_ID int, - POST_ID int, - DELTA int - ) - LANGUAGE PLPGSQL -AS $$ -BEGIN - RETURN QUERY WITH main AS ( - SELECT * FROM pool_post WHERE pool_post.pool_id = P_POOL_ID AND pool_post.post_id = P_POST_ID - ), - around AS ( - (SELECT pool_post.ord, - pool_post.pool_id, - pool_post.post_id, - 1 as delta, - main.ord AS target_ord, - main.pool_id AS target_pool_id - FROM pool_post, main - WHERE pool_post.ord > main.ord - AND pool_post.pool_id = main.pool_id - ORDER BY pool_post.ord ASC LIMIT 1) - UNION - (SELECT pool_post.ord, - pool_post.pool_id, - pool_post.post_id, - -1 as delta, - main.ord AS target_ord, - main.pool_id AS target_pool_id - FROM pool_post, main - WHERE pool_post.ord < main.ord - AND pool_post.pool_id = main.pool_id - ORDER BY pool_post.ord DESC LIMIT 1) - UNION - (SELECT pool_post.ord, - pool_post.pool_id, - pool_post.post_id, - 2 as delta, - main.ord AS target_ord, - main.pool_id AS target_pool_id - FROM pool_post, main - WHERE pool_post.ord = (SELECT MAX(pool_post.ord) FROM pool_post) - AND pool_post.pool_id = main.pool_id - ORDER BY pool_post.ord DESC LIMIT 1) - UNION - (SELECT pool_post.ord, - pool_post.pool_id, - pool_post.post_id, - -2 as delta, - main.ord AS target_ord, - main.pool_id AS target_pool_id - FROM pool_post, main - WHERE pool_post.ord = (SELECT MIN(pool_post.ord) FROM pool_post) - AND pool_post.pool_id = main.pool_id - ORDER BY pool_post.ord DESC LIMIT 1) - ) - SELECT around.ord, around.pool_id, around.post_id, around.delta FROM around; -END -$$ -""") diff --git a/server/szurubooru/search/configs/post_search_config.py b/server/szurubooru/search/configs/post_search_config.py index ad98421a..b1de2476 100644 --- a/server/szurubooru/search/configs/post_search_config.py +++ b/server/szurubooru/search/configs/post_search_config.py @@ -114,7 +114,6 @@ def _pool_filter( query: SaQuery, criterion: Optional[criteria.BaseCriterion], negated: bool ) -> SaQuery: assert criterion - from szurubooru.search.configs import util as search_util subquery = db.session.query(model.PoolPost.post_id.label("foreign_id")) subquery = subquery.options(sa.orm.lazyload("*")) subquery = search_util.create_num_filter(model.PoolPost.pool_id)(subquery, criterion, False)