Hi, I have a custom query that I’m using just when the application starts, but when applying filters using the rest of the visualizations I could notice that in the network tab there are some additional calls to the service that obtains the data from the provider, is this correct? or what should I do?
Aditional network items for custom queries
emoya
#2
Actually yes there is a way to solve that, just removing the visualization you dont need after taking their data, like this:
cf.create("my query")
.provider("My provider")
.source("my_source")
.groupby(group1)
.metrics(m1)
.element("dummy")
.on("execute:stop", data => {
console.log("use your data...", data);
cf.remove("dummy"); // here you can remove your query visualization
})
.execute();
But in order to give you a better answer, please include your code so I can see what you are doing
steven
#3
Actually i tried and it works good, but I’m removing 2 visualizations, this is my code:
let m1 = cf.Metric("price", "sum");
let group1 = cf.Attribute("created")
.func("MONTH")
.limit(1000)
.sort("asc", "created");
let group2 = cf.Attribute("date_created")
.limit(1000).func("MONTH")
.sort("asc", "date_created");
let m2 = cf.Metric("stock", "sum");
var eventsHandler = function(result) {
result.keep = true;
return result;
};
cf.create("prices")
.provider("Elasticsearch")
.source("item_prices")
.groupby(group1)
.metrics(m1)
.create("inventory")
.provider("Elasticsearch")
.source("product_inventory")
.groupby(group2)
.metrics(m2)
.element("dummy")
.processWith(eventsHandler)
.on("execute:stop", data => {
// I'm using my data here...
cf.remove("dummy");
cf.remove("dummy2");
})
.element("dummy2")
.execute();
emoya
#4
Got it, you are mixing two query results and you are deleting both queries at the end, so, that’s good, you code is good.