diff --git a/API.md b/API.md index 56e5fe20..e5b8571c 100644 --- a/API.md +++ b/API.md @@ -1576,6 +1576,7 @@ One file together with its metadata posted to the site. "commentCount": , "noteCount": , "featureCount": , + "relationCount": , "lastFeatureTime": , "favoritedBy": , "hasCustomThumbnail": , @@ -1642,6 +1643,7 @@ One file together with its metadata posted to the site. - ``: how many comments are filed under that post - ``: how many notes the post has - ``: how many times has the post been featured. +- ``: how many posts are related to this post. - ``: the last time the post was featured, formatted as per RFC 3339. - ``: list of users, serialized as [micro user resources](#micro-user). diff --git a/server/szurubooru/func/posts.py b/server/szurubooru/func/posts.py index 5d12cb4b..87b1cbee 100644 --- a/server/szurubooru/func/posts.py +++ b/server/szurubooru/func/posts.py @@ -109,6 +109,7 @@ def serialize_post(post, authenticated_user, options=None): 'favoriteCount': lambda: post.favorite_count, 'commentCount': lambda: post.comment_count, 'noteCount': lambda: post.note_count, + 'relationCount': lambda: post.relation_count, 'featureCount': lambda: post.feature_count, 'lastFeatureTime': lambda: post.last_feature_time, 'favoritedBy': lambda: [ diff --git a/server/szurubooru/tests/func/test_posts.py b/server/szurubooru/tests/func/test_posts.py index 899ee9e4..1fde0013 100644 --- a/server/szurubooru/tests/func/test_posts.py +++ b/server/szurubooru/tests/func/test_posts.py @@ -154,6 +154,7 @@ def test_serialize_post( 'commentCount': 2, 'noteCount': 0, 'featureCount': 1, + 'relationCount': 0, 'lastFeatureTime': datetime.datetime(1999, 1, 1), 'favoritedBy': ['fav1'], 'hasCustomThumbnail': True,