mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-09 22:47:36 +01:00
Add support for randomly sorting queries
This commit is contained in:
parent
5b68e494db
commit
94426e97aa
@ -36,7 +36,7 @@ from sqlalchemy import or_
|
|||||||
@menu.register_menu(bp, ".mods", "Mods", order=11, endpoint_arguments_constructor=lambda: { 'type': 'mod' })
|
@menu.register_menu(bp, ".mods", "Mods", order=11, endpoint_arguments_constructor=lambda: { 'type': 'mod' })
|
||||||
@menu.register_menu(bp, ".games", "Games", order=12, endpoint_arguments_constructor=lambda: { 'type': 'game' })
|
@menu.register_menu(bp, ".games", "Games", order=12, endpoint_arguments_constructor=lambda: { 'type': 'game' })
|
||||||
@menu.register_menu(bp, ".txp", "Texture Packs", order=13, endpoint_arguments_constructor=lambda: { 'type': 'txp' })
|
@menu.register_menu(bp, ".txp", "Texture Packs", order=13, endpoint_arguments_constructor=lambda: { 'type': 'txp' })
|
||||||
@menu.register_menu(bp, ".random", "Random", order=14, endpoint_arguments_constructor=lambda: { 'random': '1' })
|
@menu.register_menu(bp, ".random", "Random", order=14, endpoint_arguments_constructor=lambda: { 'random': '1', 'lucky': '1' })
|
||||||
@bp.route("/packages/")
|
@bp.route("/packages/")
|
||||||
def list_all():
|
def list_all():
|
||||||
qb = QueryBuilder(request.args)
|
qb = QueryBuilder(request.args)
|
||||||
|
@ -25,7 +25,7 @@ class QueryBuilder:
|
|||||||
self.types = types
|
self.types = types
|
||||||
self.search = args.get("q")
|
self.search = args.get("q")
|
||||||
self.random = "random" in args
|
self.random = "random" in args
|
||||||
self.lucky = self.random or "lucky" in args
|
self.lucky = "lucky" in args
|
||||||
self.hide_nonfree = "nonfree" in hide_flags
|
self.hide_nonfree = "nonfree" in hide_flags
|
||||||
self.limit = 1 if self.lucky else None
|
self.limit = 1 if self.lucky else None
|
||||||
self.order_by = args.get("sort")
|
self.order_by = args.get("sort")
|
||||||
|
Loading…
Reference in New Issue
Block a user