Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Resource type" filter does not work in production #26

Closed
fabiovinci opened this issue Aug 3, 2022 · 2 comments · Fixed by #38
Closed

"Resource type" filter does not work in production #26

fabiovinci opened this issue Aug 3, 2022 · 2 comments · Fixed by #38
Assignees

Comments

@fabiovinci
Copy link
Member

fabiovinci commented Aug 3, 2022

It seems the "Resource type" filter does not work in the production instance.

Whichever values you select it always returns a blank list, even if there are resources of that type.

image

It works fine in the staging instance.

@jenriquesoriano
Copy link
Contributor

jenriquesoriano commented Nov 21, 2022

To resolve the issue about the "Resource Type" filter that does not work on Production environment.

Analyzing the problem through the Dev Console of the browser, I verified that the filter doesn't work because the "config.js" file in production is not correctly configured. It would therefore be necessary to correct this file or otherwise the "controller.js" file in the "js/results" directory of the Validator UI would have to be changed.

Here is the piece of code that applies the filter (I have omitted all the list of static IDs to simplify the visualization of the code):

// Search by resource type
if ($scope.searchParameters.resourceType != 'any') {
    keyFoundResources = false;
    if ($scope.searchParameters.resourceType == "metadata") var arrayTestSuiteId = ["EIDec7323d5-d8f0-4cfe-b23a-b826df86d58c", ......., "EIDa593a7ad-42d9-46d0-985d-9dff3e684428"];
    if ($scope.searchParameters.resourceType == "viewservice") var arrayTestSuiteId = ["EIDeec9d674-d94b-4d8d-b744-1309c6cae1d2", "EID550ceacf-b3cb-47a0-b2dd-d3edb18344a9"];
    if ($scope.searchParameters.resourceType == "downloadservice") var arrayTestSuiteId = ["EIDed2d3501-d700-4ff9-b9bf-070dece8ddbd", ......., "EID0ff73873-5601-41ff-8d92-3fb1fbba3cf2"];
    if ($scope.searchParameters.resourceType == "discoveryservice") var arrayTestSuiteId = ["EIDc837298f-a10e-42d1-88f2-f1415cbbb463"];
    if ($scope.searchParameters.resourceType == "dataset") var arrayTestSuiteId = ["EID545f9e49-009b-4114-9333-7ca26413b5d4", ......., "EID9d35024d-9dd7-43a9-afff-d5aea5f51595"];
    if (Array.isArray(item.testTasks.TestTask) == false) {
       var resourceType = item.testTasks.TestTask.executableTestSuite.href;
       resourceType = resourceType.replace("//v2", "/v2");
       resourceType = resourceType.replace($scope.urlRealValidator + "ExecutableTestSuites/", "");
       resourceType = resourceType.replace(".json", "");
       resourceType = "EID" + resourceType;
       if (arrayTestSuiteId.includes(resourceType)) keyFoundResources = true;
    } else {
       var numTestSuites = item.testTasks.TestTask.length;
       for (var i = 0; i < numTestSuites; i++) {
           var resourceType = item.testTasks.TestTask[i].executableTestSuite.href;
           resourceType = resourceType.replace("//v2", "/v2");
           resourceType = resourceType.replace($scope.urlRealValidator + "ExecutableTestSuites/", "");
           resourceType = resourceType.replace(".json", "");
           resourceType = "EID" + resourceType;
           if (arrayTestSuiteId.includes(resourceType)) keyFoundResources = true;
        }
    }
 } else {
    keyFoundResources = true;
 }

As you can see, when the user select a specific Resource Type, the application generate an array of IDs. Then, for every item (test) received from the REST service, it goes to took the executabletestSuite.href field, it removes some elements (substrings) with the replace function in order to obtain only the simple ID code. However, executing a simple debug I saw that on production environment, all the executabletestSuite.href contain values similar to this:

https://yzyiqfakm4.execute-api.eu-west-1.amazonaws.com/validator/v2/ExecutableTestSuites/8f869e23-c9e9-4e86-8dca-be30ff421229.json

while the $scope.urlRealValidator is set to

https://inspire.ec.europa.eu/validator/v2/

So when it tries to remove the value contained in $scope.urlRealValidator, it will never be able to do it because the value is incorrect/different in this env.

So, to correct this issue you have 2 choices:

  1. substitute in the "config.js" the line

var serverRealURL = "https://inspire.ec.europa.eu/validator/v2/";

with the new line

var serverRealURL = "https://yzyiqfakm4.execute-api.eu-west-1.amazonaws.com/validator/v2/";

  1. instead of the "serverRealURL" variable, I will use the variable that contains the correct URL, i.e. the one that in the "config.js" file is marked by the "serverDirectURL" variable (which, moreover, in this "controller.js" module you do not import and never use it, while instead it would be useful to do).

@fabiovinci
Copy link
Member Author

The fix for this issue was included in the release v2023.0 - 25/01/2023.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants