Skip to content

ResultSet returned by subscribe() in production mode is different from dev mode: return requestId in production mode #7805

Open
@Sephirus

Description

@Sephirus

Hi guys,

For the last months I've been working on an analytics platform that's using Cube in the background. I've configured many dashboards, with the majority having real time indicators. I've built everything while working with dev mode = true but recently, due to the proximity to the client delivery I've started making tests with Cube configured in production mode. For that I've followed the steps you have in the documentation but one problem appeared.
I'm using the subscribe function to listen on changes related to the real time indicators and I've noticed that the resultSet that is returned have less fields in production mode.

Here you can see, the result set returned with dev mode = true
image

And here you can see the result set returned with dev mode = false
image

The problem is, I'm in need of the requestId of every single indicator, because it is the only way i know so later i can unsubscribe that request.

One real use case that I have is, I have one real time indicator with the time filter "today", and for this I subscribe it. If I change the time filter for yesterday, i will create a new subscription, because it's a new query, and for this I need to unsubscribe the previous one.

I'll leave a peace of my code and note that I use the requestId so I can store the messageId associated in the html so later I can use sendMessage to unsubscribe.

cubejsApiWebTransport.subscribe(request, {}, (error, resultSet) => {
  var requestId;
  
  if(resultSet != null && resultSet.loadResponses[0] != null){
	  requestId = resultSet.loadResponses[0].requestId;
	  
	  var messages = cubejsApiWebTransport.transport.messageIdToSubscription;
	  
	  Object.keys(messages).forEach(function(key,index) {
		  var newMessageId = key;
		  var newRequestId;
		  
		  if(messages[newMessageId] != null && messages[newMessageId].message != null){
			  newRequestId = messages[newMessageId].message.requestId;
			  
			  if(requestId != null && requestId.indexOf(newRequestId) >= 0){
				  indContainer.attr('data-messageId', newMessageId);
			  }
		  }
	  });
  }
...

As I said in the beginning, this is working fine with dev mode = true and I would like to understand if in production mode there is a way to force cube to send the requestId or to get it in other way.

Version:
0.33.38

Thanks in advance,
Filipe

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature proposalhelp wantedCommunity contributions are welcome.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions