From c13b13268be0fac1d5ee81562b7c50d74f12fa7a Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Thu, 25 Nov 2021 15:48:23 +0000 Subject: [PATCH] Update topic queries API doc --- app/flatpages/help/api.md | 11 +++++------ app/querybuilder.py | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/flatpages/help/api.md b/app/flatpages/help/api.md index b7e88476..75d3cdeb 100644 --- a/app/flatpages/help/api.md +++ b/app/flatpages/help/api.md @@ -264,21 +264,20 @@ Example: ## Topics -* GET `/api/topics/` ([View](/api/topics/)): Supports [Package Queries](#package-queries), and the following two options: - * `show_added`: Show topics which exist as packages, default true. - * `show_discarded`: Show topics which have been marked as outdated, default false. +* GET `/api/topics/` ([View](/api/topics/)) + * See [Topic Queries](#topic-queries) ### Topic Queries Example: - /api/topics/?q=mobs + /api/topics/?q=mobs&type=mod&type=game Supported query parameters: * `q`: Query string. -* `sort`: Sort by (`name`, `views`, `date`). -* `order`: Sort ascending (`asc`) or descending (`desc`). +* `type`: Package types (`mod`, `game`, `txp`). +* `sort`: Sort by (`name`, `views`, `created_at`). * `show_added`: Show topics that have an existing package. * `show_discarded`: Show topics marked as discarded. * `limit`: Return at most `limit` topics. diff --git a/app/querybuilder.py b/app/querybuilder.py index 3ae5f700..bac036db 100644 --- a/app/querybuilder.py +++ b/app/querybuilder.py @@ -37,7 +37,7 @@ class QueryBuilder: self.random = "random" in args self.lucky = "lucky" in args - self.limit = 1 if self.lucky else None + self.limit = 1 if self.lucky else args.get("limit") self.order_by = args.get("sort") self.order_dir = args.get("order") or "desc"