From be5325508cc6943b93656dd53c281ff56b73f20b Mon Sep 17 00:00:00 2001 From: Ali Naqvi Date: Tue, 23 Sep 2025 10:59:19 +0800 Subject: [PATCH] feat: [PPT-2176] Updated index endpoint to filter results by hidden flag --- OPENAPI_DOC.yml | 116 ++++++++++++++++++ shard.lock | 6 +- .../controllers/asset_categories.cr | 12 +- 3 files changed, 130 insertions(+), 4 deletions(-) diff --git a/OPENAPI_DOC.yml b/OPENAPI_DOC.yml index 155e79e9..023ac3db 100644 --- a/OPENAPI_DOC.yml +++ b/OPENAPI_DOC.yml @@ -1550,6 +1550,15 @@ paths: - AssetCategories operationId: PlaceOS::Api::AssetCategories_index parameters: + - name: hidden + in: query + description: Filter categories by hidden status. `true` returns only hidden + categories, `false` returns only non-hidden categories, and `nil` returns + all categories. + example: "true" + schema: + type: boolean + nullable: true - name: q in: query description: returns results based on a [simple query string](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html) @@ -23073,6 +23082,9 @@ components: description: type: string nullable: true + hidden: + type: boolean + nullable: true parent_category_id: type: string nullable: true @@ -23175,6 +23187,58 @@ components: barcode: type: string nullable: true + name: + type: string + nullable: true + client_ids: + type: object + nullable: true + map_id: + type: string + nullable: true + bookable: + type: boolean + nullable: true + accessible: + type: boolean + nullable: true + zones: + type: array + items: + type: string + nullable: true + place_groups: + type: array + items: + type: string + nullable: true + assigned_to: + type: string + nullable: true + assigned_name: + type: string + nullable: true + features: + type: array + items: + type: string + nullable: true + images: + type: array + items: + type: string + nullable: true + notes: + type: string + nullable: true + security_system_groups: + type: array + items: + type: string + nullable: true + parent_id: + type: string + nullable: true asset_type_id: type: string nullable: true @@ -23212,6 +23276,58 @@ components: barcode: type: string nullable: true + name: + type: string + nullable: true + client_ids: + type: object + nullable: true + map_id: + type: string + nullable: true + bookable: + type: boolean + nullable: true + accessible: + type: boolean + nullable: true + zones: + type: array + items: + type: string + nullable: true + place_groups: + type: array + items: + type: string + nullable: true + assigned_to: + type: string + nullable: true + assigned_name: + type: string + nullable: true + features: + type: array + items: + type: string + nullable: true + images: + type: array + items: + type: string + nullable: true + notes: + type: string + nullable: true + security_system_groups: + type: array + items: + type: string + nullable: true + parent_id: + type: string + nullable: true asset_type_id: type: string nullable: true diff --git a/shard.lock b/shard.lock index ddb64e1b..f8c93727 100644 --- a/shard.lock +++ b/shard.lock @@ -207,7 +207,7 @@ shards: placeos-frontend-loader: git: https://github.com/placeos/frontend-loader.git - version: 2.7.1+git.commit.2159535a3132a6db257f4b0d37a0261510240023 + version: 2.7.1+git.commit.57f36cfb54f4ff1088ea9e76b000951ade401466 placeos-log-backend: git: https://github.com/place-labs/log-backend.git @@ -215,7 +215,7 @@ shards: placeos-models: git: https://github.com/placeos/models.git - version: 9.76.0 + version: 9.76.1 placeos-resource: git: https://github.com/place-labs/resource.git @@ -263,7 +263,7 @@ shards: search-ingest: git: https://github.com/placeos/search-ingest.git - version: 2.11.2+git.commit.af0796e3f4d695ad304ab24eb4f06b9b529134e7 + version: 2.11.2+git.commit.158f5838832c1f1219ace0d12b63fa84a6490570 secrets-env: # Overridden git: https://github.com/spider-gazelle/secrets-env.git diff --git a/src/placeos-rest-api/controllers/asset_categories.cr b/src/placeos-rest-api/controllers/asset_categories.cr index 2faaf904..c18cda38 100644 --- a/src/placeos-rest-api/controllers/asset_categories.cr +++ b/src/placeos-rest-api/controllers/asset_categories.cr @@ -41,9 +41,19 @@ module PlaceOS::Api # list the asset categories @[AC::Route::GET("/")] - def index : Array(::PlaceOS::Model::AssetCategory) + def index( + @[AC::Param::Info(description: "Filter categories by hidden status. `true` returns only hidden categories, `false` returns only non-hidden categories, and `nil` returns all categories.", + example: "true")] + hidden : Bool? = nil, + ) : Array(::PlaceOS::Model::AssetCategory) elastic = ::PlaceOS::Model::AssetCategory.elastic query = elastic.query(search_params) + + if value = hidden + query.must({ + "hidden" => [value], + }) + end query.sort(NAME_SORT_ASC) paginate_results(elastic, query) end