Skip to content

Commit

Permalink
Fixed: Limited view size to 100 instead of 1000 while fetching produc…
Browse files Browse the repository at this point in the history
…ts to apply atp rules. Also fetching selected fields only in order to keep data size minimal (#22).
  • Loading branch information
ravilodhi committed Jun 20, 2024
1 parent e2652bd commit a145886
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions service/co/hotwax/product/ProductFacilityServices.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@
productFacilityDetail = [:]
</script>

<set field="viewSize" value="1000" type="Integer"/>
<set field="viewSize" value="100" type="Integer"/>
<set field="viewIndex" value="0" type="Integer"/>
<set field="fieldsToSelect" value="productId,tags,productFeatures"/>
<service-call name="co.hotwax.product.ProductFacilityServices.get#Products"
in-map="[viewIndex: viewIndex, viewSize: viewSize]"
in-map="[viewIndex: viewIndex, viewSize: viewSize, fieldsToSelect: fieldsToSelect]"
out-map="productResult"/>
<if condition="!productResult.productDetail">
<return error="true" message="No products found."/>
Expand Down Expand Up @@ -77,7 +78,7 @@
</script>
<iterate list="viewIndexList" entry="viewIndex">
<service-call name="co.hotwax.product.ProductFacilityServices.get#Products"
in-map="[viewIndex: viewIndex*viewSize, viewSize: viewSize]"
in-map="[viewIndex: viewIndex*viewSize, viewSize: viewSize, fieldsToSelect: fieldsToSelect]"
out-map="productResult"/>
<if condition="productResult.productDetail">
<set field="products" from="productResult.productDetail.products"/>
Expand Down Expand Up @@ -166,6 +167,7 @@
<description>Get products</description>
<in-parameters>
<parameter name="query" type="String" required="false"/>
<parameter name="fieldsToSelect" type="String" required="false"/>
<parameter name="filter" type="String" required="false"/>
<parameter name="viewIndex" type="Integer" required="false"/>
<parameter name="viewSize" type="Integer" required="false"/>
Expand Down Expand Up @@ -206,6 +208,9 @@
filterConditions.append(" AND " + filter)
}
queryObject = [query: query ?: "*:*", filter: filterConditions.toString(), params: [rows: viewSize ?: 10, start: viewIndex ?: 0]]
if (fieldsToSelect) {
queryObject.fields = fieldsToSelect;
}
RestClient restClient = ec.service.rest().method("POST").uri(endPointUri.toString())
restClient.jsonObject([json: queryObject])
Expand Down

0 comments on commit a145886

Please sign in to comment.