xiaohui-sun commented on a change in pull request #5011: [TE] endpoint -
harleyjj/yamlresource - add dataset as an optional pa…
URL: https://github.com/apache/incubator-pinot/pull/5011#discussion_r371459410
##########
File path:
thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/YamlResource.java
##########
@@ -900,15 +900,64 @@ public Response toggleActivation(
return Response.ok(responseMessage).build();
}
+ /**
+ * Implements filter for detection config.
+ * Client can filter by dataset or metric or both. It only filters if they
are not null in params and config
+ *
+ * @param detectionConfig The detection configuration after being enhanced
by DetectionConfigFormatter::format.
+ * @param dataset The dataset param passed by the client in the REST API
call.
+ * @param metric The metric param passed by the client in the REST API call.
+ * @return true if the config matches query params that are passed by client.
+ */
+ private boolean filterConfigsBy(Map<String, Object> detectionConfig, String
dataset, String metric) {
+ List datasetList = (List) detectionConfig.get("datasetNames");
+ String metricString = (String) detectionConfig.get("metric");
+ // defaults are true so we filter only if the params are passed
+ boolean metricMatch = true;
+ boolean datasetMatch = true;
+ // check metric only if it was passed
+ if (metric != null ) {
+ // equals method should not be called on null
+ metricMatch = (metricString != null) && metricString.equals(metric);
Review comment:
metricMatch = metricString != null && metricString.equals(metric);
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]