You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: OPENAPI_DOC.yml
+43-1Lines changed: 43 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -23394,7 +23394,7 @@ paths:
23394
23394
- name: parent_id
23395
23395
in: query
23396
23396
description: only return zones who have this zone as a parent (supports comma-separated
23397
-
list)
23397
+
list). Use 'root' to get zones with no parent
23398
23398
example: zone-1234,zone-5678
23399
23399
schema:
23400
23400
type: array
@@ -23410,6 +23410,12 @@ paths:
23410
23410
items:
23411
23411
type: string
23412
23412
nullable: true
23413
+
- name: include_children_count
23414
+
in: query
23415
+
description: include children_count for each zone (useful for tree views)
23416
+
example: "true"
23417
+
schema:
23418
+
type: boolean
23413
23419
- name: q
23414
23420
in: query
23415
23421
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)
@[AC::Param::Info(description:"only return zones who have this zone as a parent (supports comma-separated list)", example:"zone-1234,zone-5678")]
100
+
@[AC::Param::Info(description:"only return zones who have this zone as a parent (supports comma-separated list). Use 'root' to get zones with no parent", example:"zone-1234,zone-5678")]
100
101
parent_id : Array(String)? =nil,
101
102
@[AC::Param::Info(description:"return zones with particular tags", example:"building,level")]
102
103
tags : Array(String)? =nil,
104
+
@[AC::Param::Info(description:"include children_count for each zone (useful for tree views)", example:"true")]
105
+
include_children_count : Bool=false,
103
106
) : Array(::PlaceOS::Model::Zone)
104
107
elastic = ::PlaceOS::Model::Zone.elastic
105
108
query = elastic.query(search_params)
106
109
query.sort(NAME_SORT_ASC)
107
110
108
-
#Limit results to the children of these parents (OR logic)
111
+
#Handle tree view queries
109
112
if parent_id
110
-
query.should({
111
-
"parent_id" => parent_id,
112
-
})
113
-
query.minimum_should_match(1)
113
+
# Special case: "root" means zones with no parent
114
+
if parent_id.includes?("root")
115
+
# Remove "root" and add any other parent_ids if present
116
+
other_parents = parent_id.reject("root")
117
+
if!other_parents.empty?
118
+
# Mix of root and specific parents: use OR logic
119
+
# Build array with nil and other parent IDs
120
+
parent_values =Array(String?).new
121
+
parent_values <<nil
122
+
other_parents.each { |p| parent_values <<p }
123
+
query.should({
124
+
"parent_id" => parent_values,
125
+
})
126
+
query.minimum_should_match(1)
127
+
else
128
+
# Only root zones: filter for missing parent_id
129
+
parent_values =Array(String?).new
130
+
parent_values <<nil
131
+
query.filter({
132
+
"parent_id" => parent_values,
133
+
})
134
+
end
135
+
else
136
+
# Limit results to the children of these parents (OR logic)
137
+
query.should({
138
+
"parent_id" => parent_id,
139
+
})
140
+
query.minimum_should_match(1)
141
+
end
114
142
end
115
143
116
144
# Limit results to zones containing the passed list of tags
0 commit comments