mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
server/posts: add relation-count token
This commit is contained in:
@ -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),
|
||||
|
Reference in New Issue
Block a user