server/tags: output tag usage count
This commit is contained in:
parent
21fd25dd12
commit
c55fb2ef41
4
API.md
4
API.md
|
@ -1273,7 +1273,8 @@ A single tag. Tags are used to let users search for posts.
|
|||
"implications": <implications>,
|
||||
"suggestions": <suggestions>,
|
||||
"creationTime": <creation-time>,
|
||||
"lastEditTime": <last-edit-time>
|
||||
"lastEditTime": <last-edit-time>,
|
||||
"usages": <usage-count>
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -1288,6 +1289,7 @@ A single tag. Tags are used to let users search for posts.
|
|||
the user by the web client on usage.
|
||||
- `<creation-time>`: time the tag was created, formatted as per RFC 3339.
|
||||
- `<last-edit-time>`: time the tag was edited, formatted as per RFC 3339.
|
||||
- `<usage-count>`: the number of posts the tag was used in.
|
||||
|
||||
## Detailed tag
|
||||
**Description**
|
||||
|
|
|
@ -36,6 +36,7 @@ def serialize_tag(tag):
|
|||
relation.names[0].name for relation in tag.implications],
|
||||
'creationTime': tag.creation_time,
|
||||
'lastEditTime': tag.last_edit_time,
|
||||
'usages': tag.post_count,
|
||||
}
|
||||
|
||||
def serialize_tag_with_details(tag):
|
||||
|
|
|
@ -46,6 +46,7 @@ def test_creating_simple_tags(test_ctx, fake_datetime):
|
|||
'implications': [],
|
||||
'creationTime': datetime.datetime(1997, 12, 1),
|
||||
'lastEditTime': None,
|
||||
'usages': 0,
|
||||
}
|
||||
assert len(result['snapshots']) == 1
|
||||
tag = tags.get_tag_by_name('tag1')
|
||||
|
|
|
@ -41,6 +41,7 @@ def test_merging_without_usages(test_ctx, fake_datetime):
|
|||
'implications': [],
|
||||
'creationTime': datetime.datetime(1996, 1, 1),
|
||||
'lastEditTime': None,
|
||||
'usages': 0,
|
||||
}
|
||||
assert 'snapshots' in result
|
||||
assert tags.try_get_tag_by_name('source') is None
|
||||
|
|
|
@ -57,6 +57,7 @@ def test_retrieving_single(test_ctx):
|
|||
'lastEditTime': None,
|
||||
'suggestions': [],
|
||||
'implications': [],
|
||||
'usages': 0,
|
||||
},
|
||||
'snapshots': [],
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ def test_simple_updating(test_ctx, fake_datetime):
|
|||
'implications': [],
|
||||
'creationTime': datetime.datetime(1996, 1, 1),
|
||||
'lastEditTime': datetime.datetime(1997, 12, 1),
|
||||
'usages': 0,
|
||||
}
|
||||
assert len(result['snapshots']) == 1
|
||||
assert tags.try_get_tag_by_name('tag1') is None
|
||||
|
|
Loading…
Reference in New Issue