mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-09 14:37:36 +01:00
Fix query sorting further
This commit is contained in:
parent
2e3a9035c4
commit
2faa0e4219
@ -340,7 +340,7 @@ provides = db.Table("provides",
|
||||
db.Column("metapackage_id", db.Integer, db.ForeignKey("meta_package.id"), primary_key=True)
|
||||
)
|
||||
|
||||
tags = db.Table("tags",
|
||||
Tags = db.Table("tags",
|
||||
db.Column("tag_id", db.Integer, db.ForeignKey("tag.id"), primary_key=True),
|
||||
db.Column("package_id", db.Integer, db.ForeignKey("package.id"), primary_key=True)
|
||||
)
|
||||
@ -472,7 +472,7 @@ class Package(db.Model):
|
||||
|
||||
dependencies = db.relationship("Dependency", backref="depender", lazy="dynamic", foreign_keys=[Dependency.depender_id])
|
||||
|
||||
tags = db.relationship("Tag", secondary=tags, lazy="select",
|
||||
tags = db.relationship("Tag", secondary=Tags, lazy="select",
|
||||
backref=db.backref("packages", lazy=True))
|
||||
|
||||
releases = db.relationship("PackageRelease", backref="package",
|
||||
|
@ -70,7 +70,7 @@ class QueryBuilder:
|
||||
query = query.filter(Package.type.in_(self.types))
|
||||
|
||||
if self.search:
|
||||
query = query.search(self.search, sort=True)
|
||||
query = query.search(self.search, sort=self.order_by is None)
|
||||
|
||||
if self.random:
|
||||
query = query.order_by(func.random())
|
||||
@ -78,7 +78,7 @@ class QueryBuilder:
|
||||
to_order = None
|
||||
if self.order_by is None and self.search:
|
||||
pass
|
||||
if self.order_by is None or self.order_by == "score":
|
||||
elif self.order_by is None or self.order_by == "score":
|
||||
to_order = Package.score
|
||||
elif self.order_by == "name":
|
||||
to_order = Package.name
|
||||
@ -91,6 +91,7 @@ class QueryBuilder:
|
||||
else:
|
||||
abort(400)
|
||||
|
||||
if to_order:
|
||||
if self.order_dir == "asc":
|
||||
to_order = db.asc(to_order)
|
||||
elif self.order_dir == "desc":
|
||||
|
Loading…
Reference in New Issue
Block a user