Solved

Where to find the tutorial to learn backend side?


  • Known Participant
  • 10 replies

Hello!

I am a front-end developer. On the front-end side we just take the respective variable and put it into the component, provided by GoodData - we don’t write some queries to get dynamic data - GoodData does all of that.

But I was asked to work with data, which come with variables, generated in the ‘full.js’ file. I need to know where the chart data are formed and how to do that.
Could you please direct me, where I would be able to find the tutorials for that and what I need else if need?

Thank you
 

icon

Best answer by Jan Rehanek 2 September 2022, 13:49

View original

12 replies

Userlevel 3

Hello,

I am not sure if I understand your question correctly, but if you are asking about retrieving data as an object that can then be worked with rather than an insight, it can be done via the various Execute components.

Code examples are available here: https://gdui-examples.herokuapp.com/execute/execute-component

For example, using the useExecutionDataView hook:

const CustomExecutionExample: React.FC = () => {
//measure points to a metric defined in my workspace: QuantityAvg.
const measure = md.QuantityAvg;
//sliceBy points to the name of an attribute which the measure will be sliced by.
const sliceBy = [md.ProductName];
//sortBy is an optional sorting property which takes in a measure and a keyword: "asc" or "desc"
const sortBy = [newMeasureSort(md.QuantityAvg, "desc")];
//seriesBy is a data series which will be built using the provided measure.
const seriesBy = [measure];

//execution is a property of the executionDataView config.
//It can be defined during the actual execution, but is here for clarity.
const execution: IExecutionConfiguration = {
seriesBy: seriesBy,
slicesBy: sliceBy,
sortBy: sortBy
};

//useExecutionDataView does the actual computation in a polling link. The status of the poll is in the status variable.
//Proper error handling and loading visualisations are possible using the status and error variables.
//Once finished, result contains the full dataView as defined by the parameters above.
const { result, error, status } = useExecutionDataView({ execution: execution });
//...

Does this help?

Hi

Thanks for answer

No, I meant another thing

I retrieve the data but I don’t form the data. I assume the data comes from somewhere. And I would like to know from where the data comes to the front-end.  On the front-end we just get data and by using respective variable output our chart.

I want to know how to form them as on the back-end. Do we have to make the back end for the data. Or does GoodData provides the mechanism to create data with it, maybe it plays a role of the server regarding to the data, which we take on the front-end side? Beacuse I earlier I just ran the command ‘npm run refresh-md’ to update variables in the ‘full.js’ file, but recently I was asked to create the data themseves.

This what I meant. I wanted to figure out how to work with that if that is provided by the GoodData or to understand the conjunction between GoodData and server if it is a separate entity.
Thanks  

Userlevel 3

I am not sure I fully understand the question, but I think it’s probably one of two alternatives.

1/ If you’re talking about how GoodData internally processes the actual BI data from the time that it is uploaded to the time users access it, I am afraid that’s not open source.

2/ If you’d like to know how the full.js file is composed out of the catalog, that is available as part of the sdk.

The full.js file is created as a result of the code found in the catalog-export repository, which can be examined here: https://github.com/gooddata/gooddata-ui-sdk/tree/f874c8517a8c0f0169ebc0bc6cf71cc72dd9c905/tools/catalog-export

There’s also notes on this here: https://sdk.gooddata.com/gooddata-ui/docs/export_catalog.html.

Thank you, Jan!

I was interested at the second one.

May I ask you one more question?

Is there ability to provide URL query params for cases, when user uses filters?

For example, we have filter by some criteria - and in case, when user chooses some options of that criteria - we see in the URL string of the browser something like ‘tal=US&tal=EU’
Thank you

Userlevel 3

What do you mean by ‘provide’ in this case? Could you describe an approximate start-end flow of what this should do and accomplish?

Sure

For example, we have chart and filter in the top. Filter contains some options in according with which user can filter data, which we have in the chart.

And when user chooses some options in the filter in order to filter the chart data (or excludes some of them) - we see changes in the URL - we see there respective query params with essence of what filtering we have after that. We also want to provide the ability to load the filtered data if we have let’s say the URL string with those query params.

Does that make sense? 

Userlevel 3

I don’t think we provide support for anything like that ouf-of-the-box.

You could build a custom solution by retrieving the filter values and interacting with the URL through react-router-dom and changing the filter’s initial state from them when loading the data.

It’s important to be mindful of the fact that different browsers have different limitations on the max length of the URL, though.

I have worked on the custom solution. 

But I faced the problem.

In the ‘full.js’ file I have the variable for filtering:

export const CustomDimension1 = newAttribute("label.gd_out_all_accounts.customdimension1");

I pass it to to the ‘newNegativeAttributeFilter’ to create filter object, which forwards to the ‘AttributeFilterButton’ component.

But nor ‘CustomDimension1’, no ‘filter’ variable have all filter options data. If I would have them I would provide the dynamic logic, but not now.

I logged in the console options data, when was choosing them, took their identifiers and hardcoded them in the file system to observe the option and extract the part of identifier in the URL as query param.

Like this:

export const CUSTOM_DIMENSION_PARAM_PATH = "/gdc/md/vsr1rwnp6zhce7y79yliy6mfsdkctpmr/obj/675/elements?id=";

 

But this is not what I want - probably in the future options can be changed. 

And I wonder if I can get all options list data in the variable, generated by the GoodData (‘CustomDimension1’ in this example)
Could you please say if it is possible to do?

Thanks

 

And attached the logged ‘CustomDimension1’ variable object

 

Userlevel 3

Retrieving the possible options of a filter is doable via the validElements API.

For example, by sending a request (further described here: https://help.gooddata.com/doc/enterprise/en/expand-your-gooddata-platform/api-reference#operation/listAnattributeLabelValues) to:

https://example.gooddata.com/gdc/md/workspace_id/obj/attribute_id/validElements?limit=50&offset=0

It returns a JSON object like this (assuming that the possible options are Clothing, Electronics, Home, and Outdoor):

{
"validElements": {
"items": [
{
"element": {
"uri": "/gdc/md/jpigc5ejzqcw38kkw9xkcj2jnx6pg2z9/obj/454/elements?id=3",
"title": "Clothing"
}
},
{
"element": {
"uri": "/gdc/md/jpigc5ejzqcw38kkw9xkcj2jnx6pg2z9/obj/454/elements?id=6",
"title": "Electronics"
}
},
{
"element": {
"uri": "/gdc/md/jpigc5ejzqcw38kkw9xkcj2jnx6pg2z9/obj/454/elements?id=20",
"title": "Home"
}
},
{
"element": {
"uri": "/gdc/md/jpigc5ejzqcw38kkw9xkcj2jnx6pg2z9/obj/454/elements?id=11",
"title": "Outdoor"
}
}
],
"paging": {
"count": 4,
"offset": "0",
"total": "4"
},
"elementsMeta": {
"filter": "",
"order": "asc",
"attributeDisplayForm": "/gdc/md/jpigc5ejzqcw38kkw9xkcj2jnx6pg2z9/obj/455",
"attribute": "/gdc/md/jpigc5ejzqcw38kkw9xkcj2jnx6pg2z9/obj/454"
}
}
}

That is how the filter itself determines its values that are then displayed to the end user.

Thanks
When I send the query:

fetch("https://secure.gooddata.com/gdc/md/<project_id>/obj/<attr_id>/elements", {

       mode: "no-cors",

})
It throws an error that I am not authorized
But I was authorized. Should I pass any headers into query? I haven’t found the authorization token there

Userlevel 3

Are you sure https://secure.gooddata.com is where you should be sending the request? That is the default example provided in our documentation, but if you’re accessing your workspaces through a different link, you should be using that one.

For example, my domain is jreh.internal.gooddata.com, so I would be sending: fetch("https://jreh.internal.gooddata.com/gdc/md/<project_id>/obj/<attr_id>/elements" etc etc.

Reply