From 782f0690318d21e9e09ac88984afc59a1812b888 Mon Sep 17 00:00:00 2001 From: Shyam Sunder Date: Mon, 17 Apr 2023 19:50:40 -0400 Subject: [PATCH 1/5] client/upload: fix thumbnail width in post uploads Fixes regression caused by 648121d7 --- client/css/post-upload.styl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client/css/post-upload.styl b/client/css/post-upload.styl index ea79fcac..cb6b0067 100644 --- a/client/css/post-upload.styl +++ b/client/css/post-upload.styl @@ -62,6 +62,14 @@ $cancel-button-color = tomato margin: 0 0 1.2em 0 padding-left: 13em + img + width: 100% + height: 100% + + video + width: 100% + height: 100% + &>.thumbnail-wrapper float: left width: 12em From ffdf115714f06f7c28b3898ccd04415ac0037fb6 Mon Sep 17 00:00:00 2001 From: Yochyo Date: Mon, 20 Mar 2023 15:47:56 +0100 Subject: [PATCH 2/5] docs (api): change micro post attribute name to id --- doc/API.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/API.md b/doc/API.md index 63a50a2f..c8b88fef 100644 --- a/doc/API.md +++ b/doc/API.md @@ -2491,7 +2491,7 @@ One file together with its metadata posted to the site. ## Micro post **Description** -A [post resource](#post) stripped down to `name` and `thumbnailUrl` fields. +A [post resource](#post) stripped down to `id` and `thumbnailUrl` fields. ## Note **Description** From c2fdc2d0707640c4a7b21e76244645240f6a9c51 Mon Sep 17 00:00:00 2001 From: Yochyo Date: Mon, 3 Apr 2023 20:27:35 +0200 Subject: [PATCH 3/5] docs (tag categories): order is required when creating tag category --- doc/API.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/API.md b/doc/API.md index c8b88fef..f588c89d 100644 --- a/doc/API.md +++ b/doc/API.md @@ -323,7 +323,7 @@ data. { "name": , "color": , - "order": // optional + "order": } ``` From 4806bbe0eda3a6c2f76800200a60d7f19971150c Mon Sep 17 00:00:00 2001 From: neobooru <50623835+neobooru@users.noreply.github.com> Date: Thu, 7 Oct 2021 16:28:06 +0200 Subject: [PATCH 4/5] server: post category filter --- .../search/configs/post_search_config.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/server/szurubooru/search/configs/post_search_config.py b/server/szurubooru/search/configs/post_search_config.py index ddc003b7..8d4672d4 100644 --- a/server/szurubooru/search/configs/post_search_config.py +++ b/server/szurubooru/search/configs/post_search_config.py @@ -122,6 +122,34 @@ def _pool_filter( )(query, criterion, negated) +def _category_filter( + query: SaQuery, criterion: Optional[criteria.BaseCriterion], negated: bool +) -> SaQuery: + assert criterion + + # Step 1. find the id for the category + q1 = db.session.query(model.TagCategory.tag_category_id).filter( + model.TagCategory.name == criterion.value + ) + + # Step 2. find the tags with that category + q2 = db.session.query(model.Tag.tag_id).filter( + model.Tag.category_id.in_(q1) + ) + + # Step 3. find all posts that have at least one of those tags + q3 = db.session.query(model.PostTag.post_id).filter( + model.PostTag.tag_id.in_(q2) + ) + + # Step 4. profit + expr = model.Post.post_id.in_(q3) + if negated: + expr = ~expr + + return query.filter(expr) + + class PostSearchConfig(BaseSearchConfig): def __init__(self) -> None: self.user = None # type: Optional[model.User] @@ -349,6 +377,7 @@ class PostSearchConfig(BaseSearchConfig): ), ), (["pool"], _pool_filter), + (["category"], _category_filter), ] ) From 7a82e9d5813d8b88e2f49ebdabbf19957b2f393a Mon Sep 17 00:00:00 2001 From: neobooru <50623835+neobooru@users.noreply.github.com> Date: Mon, 26 Jun 2023 20:32:41 +0200 Subject: [PATCH 5/5] tests/server: post category filter --- .../search/configs/test_post_search_config.py | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/server/szurubooru/tests/search/configs/test_post_search_config.py b/server/szurubooru/tests/search/configs/test_post_search_config.py index 4fb8191a..b86fa273 100644 --- a/server/szurubooru/tests/search/configs/test_post_search_config.py +++ b/server/szurubooru/tests/search/configs/test_post_search_config.py @@ -863,3 +863,55 @@ def test_tumbleweed( db.session.flush() verify_unpaged("special:tumbleweed", [4]) verify_unpaged("-special:tumbleweed", [1, 2, 3]) + + +@pytest.mark.parametrize( + "input,expected_post_ids", + [ + ("category:cat1", [1, 2, 3]), + ("category:cat2", [3, 4]), + ], +) +def test_search_by_tag_category( + verify_unpaged, + post_factory, + tag_factory, + tag_category_factory, + input, + expected_post_ids, +): + cat1 = tag_category_factory(name="cat1") + cat2 = tag_category_factory(name="cat2") + tag1 = tag_factory(names=["t1"], category=cat1) + tag2 = tag_factory(names=["t2"], category=cat1) + tag3 = tag_factory(names=["t3"], category=cat2) + + post1 = post_factory(id=1) + post1.tags.append(tag1) + + post2 = post_factory(id=2) + post2.tags.append(tag2) + + post3 = post_factory(id=3) + post3.tags.append(tag1) + post3.tags.append(tag3) + + post4 = post_factory(id=4) + post4.tags.append(tag3) + + post5 = post_factory(id=5) + + db.session.add_all( + [ + tag1, + tag2, + tag3, + post1, + post2, + post3, + post4, + post5, + ] + ) + db.session.flush() + verify_unpaged(input, expected_post_ids)