server/posts: add relationCount field
This commit is contained in:
parent
c21494be25
commit
c472229bae
3 changed files with 4 additions and 0 deletions
2
API.md
2
API.md
|
@ -1576,6 +1576,7 @@ One file together with its metadata posted to the site.
|
|||
"commentCount": <comment-count>,
|
||||
"noteCount": <note-count>,
|
||||
"featureCount": <feature-count>,
|
||||
"relationCount": <relation-count>,
|
||||
"lastFeatureTime": <last-feature-time>,
|
||||
"favoritedBy": <favorited-by>,
|
||||
"hasCustomThumbnail": <has-custom-thumbnail>,
|
||||
|
@ -1642,6 +1643,7 @@ One file together with its metadata posted to the site.
|
|||
- `<comment-count>`: how many comments are filed under that post
|
||||
- `<note-count>`: how many notes the post has
|
||||
- `<feature-count>`: how many times has the post been featured.
|
||||
- `<relation-count>`: how many posts are related to this post.
|
||||
- `<last-feature-time>`: the last time the post was featured, formatted as per
|
||||
RFC 3339.
|
||||
- `<favorited-by>`: list of users, serialized as [micro user resources](#micro-user).
|
||||
|
|
|
@ -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: [
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue