server/posts: add relation-count token
This commit is contained in:
parent
c508d37d54
commit
6b68c77e17
4 changed files with 17 additions and 0 deletions
2
API.md
2
API.md
|
@ -593,6 +593,7 @@ data.
|
|||
| `comment-count` | having given number of comments |
|
||||
| `fav-count` | favorited by given number of users |
|
||||
| `note-count` | having given number of annotations |
|
||||
| `relation-count` | having given number of relations |
|
||||
| `feature-count` | having been featured given number of times |
|
||||
| `type` | given type of posts. `<value>` can be either `image`, `animation` (or `animated` or `anim`), `flash` (or `swf`) or `video` (or `webm`). |
|
||||
| `file-size` | having given file size (in bytes) |
|
||||
|
@ -630,6 +631,7 @@ data.
|
|||
| `comment-count` | most commented first |
|
||||
| `fav-count` | loved by most |
|
||||
| `note-count` | with most annotations |
|
||||
| `relation-count` | with most relations |
|
||||
| `feature-count` | most often featured |
|
||||
| `file-size` | largest files first |
|
||||
| `image-width` | widest images first |
|
||||
|
|
|
@ -54,6 +54,10 @@
|
|||
<td><code>note-count</code></td>
|
||||
<td>having given number of annotations</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>relation-count</code></td>
|
||||
<td>having given number of relations</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>feature-count</code></td>
|
||||
<td>having been featured given number of times</td>
|
||||
|
@ -189,6 +193,10 @@
|
|||
<td><code>note-count</code></td>
|
||||
<td>with most annotations</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>relation-count</code></td>
|
||||
<td>with most relations</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>feature-count</code></td>
|
||||
<td>most often featured</td>
|
||||
|
|
|
@ -187,3 +187,8 @@ class Post(Base):
|
|||
select([func.count(PostNote.post_id)]) \
|
||||
.where(PostNote.post_id == post_id) \
|
||||
.correlate_except(PostNote))
|
||||
|
||||
relation_count = column_property(
|
||||
select([func.count(PostRelation.child_id)]) \
|
||||
.where(PostRelation.parent_id == post_id) \
|
||||
.correlate_except(PostRelation))
|
||||
|
|
|
@ -153,6 +153,7 @@ class PostSearchConfig(BaseSearchConfig):
|
|||
'comment-count': search_util.create_num_filter(db.Post.comment_count),
|
||||
'fav-count': search_util.create_num_filter(db.Post.favorite_count),
|
||||
'note-count': search_util.create_num_filter(db.Post.note_count),
|
||||
'relation-count': search_util.create_num_filter(db.Post.relation_count),
|
||||
'feature-count': search_util.create_num_filter(db.Post.feature_count),
|
||||
'type': search_util.create_str_filter(db.Post.type, _type_transformer),
|
||||
'file-size': search_util.create_num_filter(db.Post.file_size),
|
||||
|
@ -186,6 +187,7 @@ class PostSearchConfig(BaseSearchConfig):
|
|||
'comment-count': (db.Post.comment_count, self.SORT_DESC),
|
||||
'fav-count': (db.Post.favorite_count, self.SORT_DESC),
|
||||
'note-count': (db.Post.note_count, self.SORT_DESC),
|
||||
'relation-count': (db.Post.relation_count, self.SORT_DESC),
|
||||
'feature-count': (db.Post.feature_count, self.SORT_DESC),
|
||||
'file-size': (db.Post.file_size, self.SORT_DESC),
|
||||
('image-width', 'width'): (db.Post.canvas_width, self.SORT_DESC),
|
||||
|
|
Loading…
Reference in a new issue