Ejemplo n.º 1
0
 def sort_columns(self) -> Dict[str, Tuple[SaColumn, str]]:
     return util.unalias_dict([
         (['random'], (sa.sql.expression.func.random(), self.SORT_NONE)),
         (['id'], (model.Post.post_id, self.SORT_DESC)),
         (['score'], (model.Post.score, self.SORT_DESC)),
         (['tag-count'], (model.Post.tag_count, self.SORT_DESC)),
         (['comment-count'], (model.Post.comment_count, self.SORT_DESC)),
         (['fav-count'], (model.Post.favorite_count, self.SORT_DESC)),
         (['note-count'], (model.Post.note_count, self.SORT_DESC)),
         (['relation-count'], (model.Post.relation_count, self.SORT_DESC)),
         (['feature-count'], (model.Post.feature_count, self.SORT_DESC)),
         (['file-size'], (model.Post.file_size, self.SORT_DESC)),
         (['image-width',
           'width'], (model.Post.canvas_width, self.SORT_DESC)),
         (['image-height',
           'height'], (model.Post.canvas_height, self.SORT_DESC)),
         (['image-area', 'area'], (model.Post.canvas_area, self.SORT_DESC)),
         (['creation-date', 'creation-time', 'date',
           'time'], (model.Post.creation_time, self.SORT_DESC)),
         (['last-edit-date', 'last-edit-time', 'edit-date',
           'edit-time'], (model.Post.last_edit_time, self.SORT_DESC)),
         (['comment-date', 'comment-time'],
          (model.Post.last_comment_creation_time, self.SORT_DESC)),
         (['fav-date',
           'fav-time'], (model.Post.last_favorite_time, self.SORT_DESC)),
         (['feature-date',
           'feature-time'], (model.Post.last_feature_time, self.SORT_DESC)),
     ])
Ejemplo n.º 2
0
 def sort_columns(self) -> Dict[str, Tuple[SaColumn, str]]:
     return util.unalias_dict([
         (
             ["random"],
             (sa.sql.expression.func.random(), self.SORT_NONE),
         ),
         (["name"], (model.Tag.first_name, self.SORT_ASC)),
         (["category"], (model.TagCategory.name, self.SORT_ASC)),
         (
             ["creation-date", "creation-time"],
             (model.Tag.creation_time, self.SORT_DESC),
         ),
         (
             [
                 "last-edit-date",
                 "last-edit-time",
                 "edit-date",
                 "edit-time",
             ],
             (model.Tag.last_edit_time, self.SORT_DESC),
         ),
         (
             ["usage-count", "post-count", "usages"],
             (model.Tag.post_count, self.SORT_DESC),
         ),
         (
             ["suggestion-count"],
             (model.Tag.suggestion_count, self.SORT_DESC),
         ),
         (
             ["implication-count"],
             (model.Tag.implication_count, self.SORT_DESC),
         ),
     ])
Ejemplo n.º 3
0
 def sort_columns(self):
     return util.unalias_dict({
         'random': (func.random(), None),
         'id': (db.Post.post_id, self.SORT_DESC),
         'score': (db.Post.score, self.SORT_DESC),
         'tag-count': (db.Post.tag_count, self.SORT_DESC),
         '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),
         '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),
         ('image-height', 'height'): (db.Post.canvas_height, self.SORT_DESC),
         ('image-area', 'area'): (db.Post.canvas_area, self.SORT_DESC),
         ('creation-date', 'creation-time', 'date', 'time'):
             (db.Post.creation_time, self.SORT_DESC),
         ('last-edit-date', 'last-edit-time', 'edit-date', 'edit-time'):
             (db.Post.last_edit_time, self.SORT_DESC),
         ('comment-date', 'comment-time'):
             (db.Post.last_comment_edit_time, self.SORT_DESC),
         ('fav-date', 'fav-time'):
             (db.Post.last_favorite_time, self.SORT_DESC),
         ('feature-date', 'feature-time'):
             (db.Post.last_feature_time, self.SORT_DESC),
     })
Ejemplo n.º 4
0
 def sort_columns(self):
     return util.unalias_dict({
         'random': (func.random(), None),
         'id': (db.Post.post_id, self.SORT_DESC),
         'score': (db.Post.score, self.SORT_DESC),
         'tag-count': (db.Post.tag_count, self.SORT_DESC),
         '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),
         ('image-height', 'height'):
             (db.Post.canvas_height, self.SORT_DESC),
         ('image-area', 'area'):
             (db.Post.canvas_area, self.SORT_DESC),
         ('creation-date', 'creation-time', 'date', 'time'):
             (db.Post.creation_time, self.SORT_DESC),
         ('last-edit-date', 'last-edit-time', 'edit-date', 'edit-time'):
             (db.Post.last_edit_time, self.SORT_DESC),
         ('comment-date', 'comment-time'):
             (db.Post.last_comment_creation_time, self.SORT_DESC),
         ('fav-date', 'fav-time'):
             (db.Post.last_favorite_time, self.SORT_DESC),
         ('feature-date', 'feature-time'):
             (db.Post.last_feature_time, self.SORT_DESC),
     })
Ejemplo n.º 5
0
 def named_filters(self):
     return util.unalias_dict({
         'id': self._create_num_filter(db.Post.post_id),
         'tag': self._create_subquery_filter(
             db.Post.post_id,
             db.PostTag.post_id,
             db.TagName.name,
             self._create_str_filter,
             lambda subquery: subquery.join(db.Tag).join(db.TagName)),
         'score': self._create_num_filter(db.Post.score),
         ('uploader', 'upload', 'submit'):
             self._create_subquery_filter(
                 db.Post.user_id,
                 db.User.user_id,
                 db.User.name,
                 self._create_str_filter),
         'comment': self._create_subquery_filter(
             db.Post.post_id,
             db.Comment.post_id,
             db.User.name,
             self._create_str_filter,
             lambda subquery: subquery.join(db.User)),
         'fav': self._create_subquery_filter(
             db.Post.post_id,
             db.PostFavorite.post_id,
             db.User.name,
             self._create_str_filter,
             lambda subquery: subquery.join(db.User)),
         'tag-count': self._create_num_filter(db.Post.tag_count),
         'comment-count': self._create_num_filter(db.Post.comment_count),
         'fav-count': self._create_num_filter(db.Post.favorite_count),
         'note-count': self._create_num_filter(db.Post.note_count),
         'feature-count': self._create_num_filter(db.Post.feature_count),
         'type': self._create_str_filter(db.Post.type, _type_transformer),
         'file-size': self._create_num_filter(db.Post.file_size),
         ('image-width', 'width'):
             self._create_num_filter(db.Post.canvas_width),
         ('image-height', 'height'):
             self._create_num_filter(db.Post.canvas_height),
         ('image-area', 'area'):
             self._create_num_filter(db.Post.canvas_area),
         ('creation-date', 'creation-time', 'date', 'time'):
             self._create_date_filter(db.Post.creation_time),
         ('last-edit-date', 'last-edit-time', 'edit-date', 'edit-time'):
             self._create_date_filter(db.Post.last_edit_time),
         ('comment-date', 'comment-time'):
             self._create_date_filter(db.Post.last_comment_edit_time),
         ('fav-date', 'fav-time'):
             self._create_date_filter(db.Post.last_favorite_time),
         ('feature-date', 'feature-time'):
             self._create_date_filter(db.Post.last_feature_time),
     })
Ejemplo n.º 6
0
 def sort_columns(self):
     return util.unalias_dict({
         'random': (func.random(), None),
         'name': (db.Tag.first_name, self.SORT_ASC),
         'category': (db.TagCategory.name, self.SORT_ASC),
         ('creation-date', 'creation-time'):
         (db.Tag.creation_time, self.SORT_DESC),
         ('last-edit-date', 'last-edit-time', 'edit-date', 'edit-time'):
         (db.Tag.last_edit_time, self.SORT_DESC),
         ('usage-count', 'post-count', 'usages'):
         (db.Tag.post_count, self.SORT_DESC),
         'suggestion-count': (db.Tag.suggestion_count, self.SORT_DESC),
         'implication-count': (db.Tag.implication_count, self.SORT_DESC),
     })
Ejemplo n.º 7
0
 def sort_columns(self):
     return util.unalias_dict({
         'random': (func.random(), None),
         'name': (db.Tag.first_name, self.SORT_ASC),
         'category': (db.TagCategory.name, self.SORT_ASC),
         ('creation-date', 'creation-time'):
             (db.Tag.creation_time, self.SORT_DESC),
         ('last-edit-date', 'last-edit-time', 'edit-date', 'edit-time'):
             (db.Tag.last_edit_time, self.SORT_DESC),
         ('usage-count', 'post-count', 'usages'):
             (db.Tag.post_count, self.SORT_DESC),
         'suggestion-count': (db.Tag.suggestion_count, self.SORT_DESC),
         'implication-count': (db.Tag.implication_count, self.SORT_DESC),
     })
Ejemplo n.º 8
0
 def sort_columns(self) -> Dict[str, Tuple[SaColumn, str]]:
     return util.unalias_dict([
         (['random'], (sa.sql.expression.func.random(), self.SORT_NONE)),
         (['name'], (model.Tag.first_name, self.SORT_ASC)),
         (['category'], (model.TagCategory.name, self.SORT_ASC)),
         (['creation-date',
           'creation-time'], (model.Tag.creation_time, self.SORT_DESC)),
         (['last-edit-date', 'last-edit-time', 'edit-date',
           'edit-time'], (model.Tag.last_edit_time, self.SORT_DESC)),
         (['usage-count', 'post-count',
           'usages'], (model.Tag.post_count, self.SORT_DESC)),
         (['suggestion-count'], (model.Tag.suggestion_count,
                                 self.SORT_DESC)),
         (['implication-count'], (model.Tag.implication_count,
                                  self.SORT_DESC)),
     ])
Ejemplo n.º 9
0
 def named_filters(self) -> Dict[str, Filter]:
     return util.unalias_dict([
         (
             ["name"],
             search_util.create_subquery_filter(
                 model.Tag.tag_id,
                 model.TagName.tag_id,
                 model.TagName.name,
                 search_util.create_str_filter,
             ),
         ),
         (
             ["category"],
             search_util.create_subquery_filter(
                 model.Tag.category_id,
                 model.TagCategory.tag_category_id,
                 model.TagCategory.name,
                 search_util.create_str_filter,
             ),
         ),
         (
             ["creation-date", "creation-time"],
             search_util.create_date_filter(model.Tag.creation_time),
         ),
         (
             [
                 "last-edit-date",
                 "last-edit-time",
                 "edit-date",
                 "edit-time",
             ],
             search_util.create_date_filter(model.Tag.last_edit_time),
         ),
         (
             ["usage-count", "post-count", "usages"],
             search_util.create_num_filter(model.Tag.post_count),
         ),
         (
             ["suggestion-count"],
             search_util.create_num_filter(model.Tag.suggestion_count),
         ),
         (
             ["implication-count"],
             search_util.create_num_filter(model.Tag.implication_count),
         ),
     ])
Ejemplo n.º 10
0
    def named_filters(self) -> Dict[str, Filter]:
        return util.unalias_dict([
            (
                ['name'],
                search_util.create_subquery_filter(
                    model.Tag.tag_id,
                    model.TagName.tag_id,
                    model.TagName.name,
                    search_util.create_str_filter)
            ),

            (
                ['category'],
                search_util.create_subquery_filter(
                    model.Tag.category_id,
                    model.TagCategory.tag_category_id,
                    model.TagCategory.name,
                    search_util.create_str_filter)
            ),

            (
                ['creation-date', 'creation-time'],
                search_util.create_date_filter(model.Tag.creation_time)
            ),

            (
                ['last-edit-date', 'last-edit-time', 'edit-date', 'edit-time'],
                search_util.create_date_filter(model.Tag.last_edit_time)
            ),

            (
                ['usage-count', 'post-count', 'usages'],
                search_util.create_num_filter(model.Tag.post_count)
            ),

            (
                ['suggestion-count'],
                search_util.create_num_filter(model.Tag.suggestion_count)
            ),

            (
                ['implication-count'],
                search_util.create_num_filter(model.Tag.implication_count)
            ),
        ])
Ejemplo n.º 11
0
    def named_filters(self) -> Dict[str, Filter]:
        return util.unalias_dict([
            (
                ['name'],
                search_util.create_subquery_filter(
                    model.Tag.tag_id,
                    model.TagName.tag_id,
                    model.TagName.name,
                    search_util.create_str_filter)
            ),

            (
                ['category'],
                search_util.create_subquery_filter(
                    model.Tag.category_id,
                    model.TagCategory.tag_category_id,
                    model.TagCategory.name,
                    search_util.create_str_filter)
            ),

            (
                ['creation-date', 'creation-time'],
                search_util.create_date_filter(model.Tag.creation_time)
            ),

            (
                ['last-edit-date', 'last-edit-time', 'edit-date', 'edit-time'],
                search_util.create_date_filter(model.Tag.last_edit_time)
            ),

            (
                ['usage-count', 'post-count', 'usages'],
                search_util.create_num_filter(model.Tag.post_count)
            ),

            (
                ['suggestion-count'],
                search_util.create_num_filter(model.Tag.suggestion_count)
            ),

            (
                ['implication-count'],
                search_util.create_num_filter(model.Tag.implication_count)
            ),
        ])
Ejemplo n.º 12
0
    def sort_columns(self) -> Dict[str, Tuple[SaColumn, str]]:
        return util.unalias_dict([
            (
                ['random'],
                (sa.sql.expression.func.random(), self.SORT_NONE)
            ),

            (
                ['name'],
                (model.Tag.first_name, self.SORT_ASC)
            ),

            (
                ['category'],
                (model.TagCategory.name, self.SORT_ASC)
            ),

            (
                ['creation-date', 'creation-time'],
                (model.Tag.creation_time, self.SORT_DESC)
            ),

            (
                ['last-edit-date', 'last-edit-time', 'edit-date', 'edit-time'],
                (model.Tag.last_edit_time, self.SORT_DESC)
            ),

            (
                ['usage-count', 'post-count', 'usages'],
                (model.Tag.post_count, self.SORT_DESC)
            ),

            (
                ['suggestion-count'],
                (model.Tag.suggestion_count, self.SORT_DESC)
            ),

            (
                ['implication-count'],
                (model.Tag.implication_count, self.SORT_DESC)
            ),
        ])
Ejemplo n.º 13
0
 def named_filters(self):
     return util.unalias_dict({
         'name':
         self._create_subquery_filter(db.Tag.tag_id, db.TagName.tag_id,
                                      db.TagName.name,
                                      self._create_str_filter),
         'category':
         self._create_subquery_filter(db.Tag.category_id,
                                      db.TagCategory.tag_category_id,
                                      db.TagCategory.name,
                                      self._create_str_filter),
         ('creation-date', 'creation-time'):
         self._create_date_filter(db.Tag.creation_time),
         ('last-edit-date', 'last-edit-time', 'edit-date', 'edit-time'):
         self._create_date_filter(db.Tag.last_edit_time),
         ('usage-count', 'post-count', 'usages'):
         self._create_num_filter(db.Tag.post_count),
         'suggestion-count':
         self._create_num_filter(db.Tag.suggestion_count),
         'implication-count':
         self._create_num_filter(db.Tag.implication_count),
     })
Ejemplo n.º 14
0
 def named_filters(self) -> Dict[str, Filter]:
     return util.unalias_dict([
         (
             ["name"],
             search_util.create_subquery_filter(
                 model.Pool.pool_id,
                 model.PoolName.pool_id,
                 model.PoolName.name,
                 search_util.create_str_filter,
             ),
         ),
         (
             ["category"],
             search_util.create_subquery_filter(
                 model.Pool.category_id,
                 model.PoolCategory.pool_category_id,
                 model.PoolCategory.name,
                 search_util.create_str_filter,
             ),
         ),
         (
             ["creation-date", "creation-time"],
             search_util.create_date_filter(model.Pool.creation_time),
         ),
         (
             [
                 "last-edit-date",
                 "last-edit-time",
                 "edit-date",
                 "edit-time",
             ],
             search_util.create_date_filter(model.Pool.last_edit_time),
         ),
         (
             ["post-count"],
             search_util.create_num_filter(model.Pool.post_count),
         ),
     ])
Ejemplo n.º 15
0
 def named_filters(self):
     return util.unalias_dict({
         'name': search_util.create_subquery_filter(
             db.Tag.tag_id,
             db.TagName.tag_id,
             db.TagName.name,
             search_util.create_str_filter),
         'category': search_util.create_subquery_filter(
             db.Tag.category_id,
             db.TagCategory.tag_category_id,
             db.TagCategory.name,
             search_util.create_str_filter),
         ('creation-date', 'creation-time'):
             search_util.create_date_filter(db.Tag.creation_time),
         ('last-edit-date', 'last-edit-time', 'edit-date', 'edit-time'):
             search_util.create_date_filter(db.Tag.last_edit_time),
         ('usage-count', 'post-count', 'usages'):
             search_util.create_num_filter(db.Tag.post_count),
         'suggestion-count':
             search_util.create_num_filter(db.Tag.suggestion_count),
         'implication-count':
             search_util.create_num_filter(db.Tag.implication_count),
     })
Ejemplo n.º 16
0
 def named_filters(self):
     return util.unalias_dict({
         'id': search_util.create_num_filter(db.Post.post_id),
         'tag': search_util.create_subquery_filter(
             db.Post.post_id,
             db.PostTag.post_id,
             db.TagName.name,
             search_util.create_str_filter,
             lambda subquery: subquery.join(db.Tag).join(db.TagName)),
         'score': search_util.create_num_filter(db.Post.score),
         ('uploader', 'upload', 'submit'):
             _create_user_filter(),
         'comment': search_util.create_subquery_filter(
             db.Post.post_id,
             db.Comment.post_id,
             db.User.name,
             search_util.create_str_filter,
             lambda subquery: subquery.join(db.User)),
         'fav': search_util.create_subquery_filter(
             db.Post.post_id,
             db.PostFavorite.post_id,
             db.User.name,
             search_util.create_str_filter,
             lambda subquery: subquery.join(db.User)),
         'liked': _create_score_filter(1),
         'disliked': _create_score_filter(-1),
         'tag-count': search_util.create_num_filter(db.Post.tag_count),
         '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),
         'content-checksum': search_util.create_str_filter(
             db.Post.checksum),
         'file-size': search_util.create_num_filter(db.Post.file_size),
         ('image-width', 'width'):
             search_util.create_num_filter(db.Post.canvas_width),
         ('image-height', 'height'):
             search_util.create_num_filter(db.Post.canvas_height),
         ('image-area', 'area'):
             search_util.create_num_filter(db.Post.canvas_area),
         ('creation-date', 'creation-time', 'date', 'time'):
             search_util.create_date_filter(db.Post.creation_time),
         ('last-edit-date', 'last-edit-time', 'edit-date', 'edit-time'):
             search_util.create_date_filter(db.Post.last_edit_time),
         ('comment-date', 'comment-time'):
             search_util.create_date_filter(
                 db.Post.last_comment_creation_time),
         ('fav-date', 'fav-time'):
             search_util.create_date_filter(db.Post.last_favorite_time),
         ('feature-date', 'feature-time'):
             search_util.create_date_filter(db.Post.last_feature_time),
         ('safety', 'rating'):
             search_util.create_str_filter(
                 db.Post.safety, _safety_transformer),
     })
Ejemplo n.º 17
0
 def named_filters(self) -> Dict[str, Filter]:
     return util.unalias_dict([
         (["id"], search_util.create_num_filter(model.Post.post_id)),
         (
             ["tag"],
             search_util.create_subquery_filter(
                 model.Post.post_id,
                 model.PostTag.post_id,
                 model.TagName.name,
                 search_util.create_str_filter,
                 lambda subquery: subquery.join(model.Tag).join(model.
                                                                TagName),
             ),
         ),
         (["score"], search_util.create_num_filter(model.Post.score)),
         (["uploader", "upload", "submit"], _user_filter),
         (
             ["comment"],
             search_util.create_subquery_filter(
                 model.Post.post_id,
                 model.Comment.post_id,
                 model.User.name,
                 search_util.create_str_filter,
                 lambda subquery: subquery.join(model.User),
             ),
         ),
         (
             ["fav"],
             search_util.create_subquery_filter(
                 model.Post.post_id,
                 model.PostFavorite.post_id,
                 model.User.name,
                 search_util.create_str_filter,
                 lambda subquery: subquery.join(model.User),
             ),
         ),
         (["liked"], _create_score_filter(1)),
         (["disliked"], _create_score_filter(-1)),
         (
             ["source"],
             search_util.create_str_filter(model.Post.source,
                                           _source_transformer),
         ),
         (
             ["tag-count"],
             search_util.create_num_filter(model.Post.tag_count),
         ),
         (
             ["comment-count"],
             search_util.create_num_filter(model.Post.comment_count),
         ),
         (
             ["fav-count"],
             search_util.create_num_filter(model.Post.favorite_count),
         ),
         (
             ["note-count"],
             search_util.create_num_filter(model.Post.note_count),
         ),
         (
             ["relation-count"],
             search_util.create_num_filter(model.Post.relation_count),
         ),
         (
             ["feature-count"],
             search_util.create_num_filter(model.Post.feature_count),
         ),
         (
             ["type"],
             search_util.create_str_filter(model.Post.type,
                                           _type_transformer),
         ),
         (
             ["content-checksum", "sha1"],
             search_util.create_str_filter(model.Post.checksum),
         ),
         (
             ["md5"],
             search_util.create_str_filter(model.Post.checksum_md5),
         ),
         (
             ["file-size"],
             search_util.create_num_filter(model.Post.file_size),
         ),
         (
             ["image-width", "width"],
             search_util.create_num_filter(model.Post.canvas_width),
         ),
         (
             ["image-height", "height"],
             search_util.create_num_filter(model.Post.canvas_height),
         ),
         (
             ["image-area", "area"],
             search_util.create_num_filter(model.Post.canvas_area),
         ),
         (
             ["image-aspect-ratio", "image-ar", "aspect-ratio", "ar"],
             search_util.create_num_filter(
                 model.Post.canvas_aspect_ratio,
                 transformer=search_util.float_transformer,
             ),
         ),
         (
             [
                 "creation-date",
                 "creation-time",
                 "date",
                 "time",
                 "posted",
             ],
             search_util.create_date_filter(model.Post.creation_time),
         ),
         (
             [
                 "last-edit-date",
                 "last-edit-time",
                 "edit-date",
                 "edit-time",
                 "edited",
             ],
             search_util.create_date_filter(model.Post.last_edit_time),
         ),
         (
             ["date-taken", "time-taken", "taken"],
             search_util.create_date_filter(model.Post.date_taken),
         ),
         (
             ["comment-date", "comment-time"],
             search_util.create_date_filter(
                 model.Post.last_comment_creation_time),
         ),
         (
             ["fav-date", "fav-time"],
             search_util.create_date_filter(model.Post.last_favorite_time),
         ),
         (
             ["feature-date", "feature-time"],
             search_util.create_date_filter(model.Post.last_feature_time),
         ),
         (
             ["safety", "rating"],
             search_util.create_str_filter(model.Post.safety,
                                           _safety_transformer),
         ),
         (["note-text"], _note_filter),
         (
             ["flag"],
             search_util.create_str_filter(model.Post.flags_string,
                                           _flag_transformer),
         ),
         (["pool"], _pool_filter),
     ])
Ejemplo n.º 18
0
 def sort_columns(self) -> Dict[str, Tuple[SaColumn, str]]:
     return util.unalias_dict([
         (
             ["random"],
             (sa.sql.expression.func.random(), self.SORT_NONE),
         ),
         (["id"], (model.Post.post_id, self.SORT_DESC)),
         (["score"], (model.Post.score, self.SORT_DESC)),
         (["tag-count"], (model.Post.tag_count, self.SORT_DESC)),
         (
             ["comment-count"],
             (model.Post.comment_count, self.SORT_DESC),
         ),
         (["fav-count"], (model.Post.favorite_count, self.SORT_DESC)),
         (["note-count"], (model.Post.note_count, self.SORT_DESC)),
         (
             ["relation-count"],
             (model.Post.relation_count, self.SORT_DESC),
         ),
         (
             ["feature-count"],
             (model.Post.feature_count, self.SORT_DESC),
         ),
         (["file-size"], (model.Post.file_size, self.SORT_DESC)),
         (
             ["image-width", "width"],
             (model.Post.canvas_width, self.SORT_DESC),
         ),
         (
             ["image-height", "height"],
             (model.Post.canvas_height, self.SORT_DESC),
         ),
         (
             ["image-area", "area"],
             (model.Post.canvas_area, self.SORT_DESC),
         ),
         (
             ["creation-date", "creation-time", "date", "time"],
             (model.Post.creation_time, self.SORT_DESC),
         ),
         (
             [
                 "last-edit-date",
                 "last-edit-time",
                 "edit-date",
                 "edit-time",
             ],
             (model.Post.last_edit_time, self.SORT_DESC),
         ),
         (
             ["date-taken", "taken"],
             (model.Post.date_taken, self.SORT_DESC_NULL_LAST),
         ),
         (
             ["comment-date", "comment-time"],
             (model.Post.last_comment_creation_time, self.SORT_DESC),
         ),
         (
             ["fav-date", "fav-time"],
             (model.Post.last_favorite_time, self.SORT_DESC),
         ),
         (
             ["feature-date", "feature-time"],
             (model.Post.last_feature_time, self.SORT_DESC),
         ),
     ])
Ejemplo n.º 19
0
    def sort_columns(self) -> Dict[str, Tuple[SaColumn, str]]:
        return util.unalias_dict([
            (
                ['random'],
                (sa.sql.expression.func.random(), self.SORT_NONE)
            ),

            (
                ['id'],
                (model.Post.post_id, self.SORT_DESC)
            ),

            (
                ['score'],
                (model.Post.score, self.SORT_DESC)
            ),

            (
                ['tag-count'],
                (model.Post.tag_count, self.SORT_DESC)
            ),

            (
                ['comment-count'],
                (model.Post.comment_count, self.SORT_DESC)
            ),

            (
                ['fav-count'],
                (model.Post.favorite_count, self.SORT_DESC)
            ),

            (
                ['note-count'],
                (model.Post.note_count, self.SORT_DESC)
            ),

            (
                ['relation-count'],
                (model.Post.relation_count, self.SORT_DESC)
            ),

            (
                ['feature-count'],
                (model.Post.feature_count, self.SORT_DESC)
            ),

            (
                ['file-size'],
                (model.Post.file_size, self.SORT_DESC)
            ),

            (
                ['image-width', 'width'],
                (model.Post.canvas_width, self.SORT_DESC)
            ),

            (
                ['image-height', 'height'],
                (model.Post.canvas_height, self.SORT_DESC)
            ),

            (
                ['image-area', 'area'],
                (model.Post.canvas_area, self.SORT_DESC)
            ),

            (
                ['creation-date', 'creation-time', 'date', 'time'],
                (model.Post.creation_time, self.SORT_DESC)
            ),

            (
                ['last-edit-date', 'last-edit-time', 'edit-date', 'edit-time'],
                (model.Post.last_edit_time, self.SORT_DESC)
            ),

            (
                ['comment-date', 'comment-time'],
                (model.Post.last_comment_creation_time, self.SORT_DESC)
            ),

            (
                ['fav-date', 'fav-time'],
                (model.Post.last_favorite_time, self.SORT_DESC)
            ),

            (
                ['feature-date', 'feature-time'],
                (model.Post.last_feature_time, self.SORT_DESC)
            ),
        ])
Ejemplo n.º 20
0
    def named_filters(self) -> Dict[str, Filter]:
        return util.unalias_dict([
            (
                ['id'],
                search_util.create_num_filter(model.Post.post_id)
            ),

            (
                ['tag'],
                search_util.create_subquery_filter(
                    model.Post.post_id,
                    model.PostTag.post_id,
                    model.TagName.name,
                    search_util.create_str_filter,
                    lambda subquery:
                        subquery.join(model.Tag).join(model.TagName))
            ),

            (
                ['score'],
                search_util.create_num_filter(model.Post.score)
            ),

            (
                ['uploader', 'upload', 'submit'],
                _user_filter
            ),

            (
                ['comment'],
                search_util.create_subquery_filter(
                    model.Post.post_id,
                    model.Comment.post_id,
                    model.User.name,
                    search_util.create_str_filter,
                    lambda subquery: subquery.join(model.User))
            ),

            (
                ['fav'],
                search_util.create_subquery_filter(
                    model.Post.post_id,
                    model.PostFavorite.post_id,
                    model.User.name,
                    search_util.create_str_filter,
                    lambda subquery: subquery.join(model.User))
            ),

            (
                ['liked'],
                _create_score_filter(1)
            ),
            (
                ['disliked'],
                _create_score_filter(-1)
            ),

            (
                ['tag-count'],
                search_util.create_num_filter(model.Post.tag_count)
            ),

            (
                ['comment-count'],
                search_util.create_num_filter(model.Post.comment_count)
            ),

            (
                ['fav-count'],
                search_util.create_num_filter(model.Post.favorite_count)
            ),

            (
                ['note-count'],
                search_util.create_num_filter(model.Post.note_count)
            ),

            (
                ['relation-count'],
                search_util.create_num_filter(model.Post.relation_count)
            ),

            (
                ['feature-count'],
                search_util.create_num_filter(model.Post.feature_count)
            ),

            (
                ['type'],
                search_util.create_str_filter(
                    model.Post.type, _type_transformer)
            ),

            (
                ['content-checksum'],
                search_util.create_str_filter(model.Post.checksum)
            ),

            (
                ['file-size'],
                search_util.create_num_filter(model.Post.file_size)
            ),

            (
                ['image-width', 'width'],
                search_util.create_num_filter(model.Post.canvas_width)
            ),

            (
                ['image-height', 'height'],
                search_util.create_num_filter(model.Post.canvas_height)
            ),

            (
                ['image-area', 'area'],
                search_util.create_num_filter(model.Post.canvas_area)
            ),

            (
                ['image-aspect-ratio', 'image-ar', 'aspect-ratio', 'ar'],
                search_util.create_num_filter(
                    model.Post.canvas_aspect_ratio,
                    transformer=search_util.float_transformer)
            ),

            (
                ['creation-date', 'creation-time', 'date', 'time'],
                search_util.create_date_filter(model.Post.creation_time)
            ),

            (
                ['last-edit-date', 'last-edit-time', 'edit-date', 'edit-time'],
                search_util.create_date_filter(model.Post.last_edit_time)
            ),

            (
                ['comment-date', 'comment-time'],
                search_util.create_date_filter(
                    model.Post.last_comment_creation_time)
            ),

            (
                ['fav-date', 'fav-time'],
                search_util.create_date_filter(model.Post.last_favorite_time)
            ),

            (
                ['feature-date', 'feature-time'],
                search_util.create_date_filter(model.Post.last_feature_time)
            ),

            (
                ['safety', 'rating'],
                search_util.create_str_filter(
                    model.Post.safety, _safety_transformer)
            ),

            (
                ['note-text'],
                _note_filter
            ),

            (
                ['flag'],
                search_util.create_str_filter(
                    model.Post.flags, _flag_transformer)
            ),
        ])
Ejemplo n.º 21
0
    def named_filters(self) -> Dict[str, Filter]:
        return util.unalias_dict([
            (
                ['id'],
                search_util.create_num_filter(model.Post.post_id)
            ),

            (
                ['tag'],
                search_util.create_subquery_filter(
                    model.Post.post_id,
                    model.PostTag.post_id,
                    model.TagName.name,
                    search_util.create_str_filter,
                    lambda subquery:
                        subquery.join(model.Tag).join(model.TagName))
            ),

            (
                ['score'],
                search_util.create_num_filter(model.Post.score)
            ),

            (
                ['uploader', 'upload', 'submit'],
                _user_filter
            ),

            (
                ['comment'],
                search_util.create_subquery_filter(
                    model.Post.post_id,
                    model.Comment.post_id,
                    model.User.name,
                    search_util.create_str_filter,
                    lambda subquery: subquery.join(model.User))
            ),

            (
                ['fav'],
                search_util.create_subquery_filter(
                    model.Post.post_id,
                    model.PostFavorite.post_id,
                    model.User.name,
                    search_util.create_str_filter,
                    lambda subquery: subquery.join(model.User))
            ),

            (
                ['liked'],
                _create_score_filter(1)
            ),
            (
                ['disliked'],
                _create_score_filter(-1)
            ),

            (
                ['source'],
                search_util.create_str_filter(
                    model.Post.source, _source_transformer)
            ),

            (
                ['tag-count'],
                search_util.create_num_filter(model.Post.tag_count)
            ),

            (
                ['comment-count'],
                search_util.create_num_filter(model.Post.comment_count)
            ),

            (
                ['fav-count'],
                search_util.create_num_filter(model.Post.favorite_count)
            ),

            (
                ['note-count'],
                search_util.create_num_filter(model.Post.note_count)
            ),

            (
                ['relation-count'],
                search_util.create_num_filter(model.Post.relation_count)
            ),

            (
                ['feature-count'],
                search_util.create_num_filter(model.Post.feature_count)
            ),

            (
                ['type'],
                search_util.create_str_filter(
                    model.Post.type, _type_transformer)
            ),

            (
                ['content-checksum'],
                search_util.create_str_filter(model.Post.checksum)
            ),

            (
                ['file-size'],
                search_util.create_num_filter(model.Post.file_size)
            ),

            (
                ['image-width', 'width'],
                search_util.create_num_filter(model.Post.canvas_width)
            ),

            (
                ['image-height', 'height'],
                search_util.create_num_filter(model.Post.canvas_height)
            ),

            (
                ['image-area', 'area'],
                search_util.create_num_filter(model.Post.canvas_area)
            ),

            (
                ['image-aspect-ratio', 'image-ar', 'aspect-ratio', 'ar'],
                search_util.create_num_filter(
                    model.Post.canvas_aspect_ratio,
                    transformer=search_util.float_transformer)
            ),

            (
                ['creation-date', 'creation-time', 'date', 'time'],
                search_util.create_date_filter(model.Post.creation_time)
            ),

            (
                ['last-edit-date', 'last-edit-time', 'edit-date', 'edit-time'],
                search_util.create_date_filter(model.Post.last_edit_time)
            ),

            (
                ['comment-date', 'comment-time'],
                search_util.create_date_filter(
                    model.Post.last_comment_creation_time)
            ),

            (
                ['fav-date', 'fav-time'],
                search_util.create_date_filter(model.Post.last_favorite_time)
            ),

            (
                ['feature-date', 'feature-time'],
                search_util.create_date_filter(model.Post.last_feature_time)
            ),

            (
                ['safety', 'rating'],
                search_util.create_str_filter(
                    model.Post.safety, _safety_transformer)
            ),

            (
                ['note-text'],
                _note_filter
            ),

            (
                ['flag'],
                search_util.create_str_filter(
                    model.Post.flags_string, _flag_transformer)
            ),
        ])