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

Support Or logic operator in CA Query filters #30190

Open
freddyDOTCMS opened this issue Sep 30, 2024 · 2 comments
Open

Support Or logic operator in CA Query filters #30190

freddyDOTCMS opened this issue Sep 30, 2024 · 2 comments

Comments

@freddyDOTCMS
Copy link
Contributor

Parent Issue

#30141

Problem Statement

We create a new query sintax for the CA Endpoint and ViewTool, is not really the same CubeJs syntax, let see an example on the filter attribute:

Example to get all the request for any PAGE or for the URL equals to something like '/dA/716dcfa9-537d-419a-837f-73084a499cf3/fileAsset/1200w/50q/bg-footer.jpg', the CubeJS query look like:


{
  "measures": [
    "request.count"
  ],
  "filters": [
    {
       "or": [
            {
              "member": "request.whatAmI",
              "operator": "equals",
              "values": [
                "PAGE"
              ]
            },
            {
              "member": "request.url",
              "operator": "equals",
              "values": [
                "/dA/716dcfa9-537d-419a-837f-73084a499cf3/fileAsset/1200w/50q/bg-footer.jpg"
              ]
            }
        ]
     }
  ],
  "dimensions": [
    "request.url"
  ],
  "order": {
    "request.count": "desc"
  }
}

In our less verbose Syntax:


{
  "measures": [
    "request.count"
  ],
  "filters": "member": "request.whatAmI = ['PAGE'] OR request.url = ['/dA/716dcfa9-537d-419a-837f-73084a499cf3/fileAsset/1200w/50q/bg-footer.jpg"']",
  "dimensions": [
    "request.url"
  ],
  "order": {
    "request.count": "desc"
  }
}

It is failing because it translate it like to different filters in the filters attribute and it is a AND.

Steps to Reproduce

  • Start dotCMS with the full starter
  • Start Analytics to this just: Go to ""/core/docker/docker-compose-examples/analytics"" and run the command "docker-compose up", and wait a couple of minutes, Configure the Analitycs App in dotCMS with the follow parameters:
ClientIId: analytics-customer-customer1
Client Secret: testsecret
Analytics Config URL http://localhost:8088/c/customer1/cluster1/keys
Analytics Write URL http://localhost:8081/api/v1/event
Analytics Read URL http://localhost:4001/
  • Navigate in the dotCMS FE to the Home Page this is going to include request to '/dA/716dcfa9-537d-419a-837f-73084a499cf3/fileAsset/1200w/50q/bg-footer.jpg'.

  • GO to the Velocity playground and run this code

#set ($queryMap = {"measures" : ["request.count"],
"orders": "request.count desc",
"dimensions":["request.url"],
"filters":"request.whatAmI = ['PAGE'] OR request.url = ['/dA/716dcfa9-537d-419a-837f-73084a499cf3/fileAsset/1200w/50q/bg-footer.jpg']"
})

#set($collection = $analytics.runReportFromMap($queryMap).getResults())

Accessed Pages

#foreach($item in $collection)
-> URL: $item.get("request.url").get()
-> Count: $item.get("request.count").get()

#end

You must be request to both the FIle and the Home Page

Acceptance Criteria

Make the Or filter works when we retrieve CA data

dotCMS Version

latest

Proposed Objective

Core Features

Proposed Priority

Priority 2 - Important

External Links... Slack Conversations, Support Tickets, Figma Designs, etc.

No response

Assumptions & Initiation Needs

No response

Quality Assurance Notes & Workarounds

No response

Sub-Tasks & Estimates

No response

@jcastro-dotcms
Copy link
Contributor

This issue is NOT reproducible anymore. The OR logical operator is working as expected.

@jcastro-dotcms
Copy link
Contributor

NOTE TO QA:

In order to test this, click around the pages in the front-end. Then, you can create a test HTML Page and add a Code Snippet to it with the following code:

#set ($queryMap = {"measures" : ["request.count"],
"orders": "request.count desc",
"dimensions":["request.url"],
"filters":"request.whatAmI = ['PAGE'] or request.url = ['<GET-YOUR-OWN-FILE-ASSET-URL-FROM-CUBEJS>']"
})

#set($collection = $analytics.runReportFromMap($queryMap).getResults())

<h2>Accessed Pages</h2>

#foreach($item in $collection)
<ul>
	<li>URL: $item.get("request.url").get()</li>
	<li>Count: $item.get("request.count").get()</li>
</ul>
#end

Replace the <GET-YOUR-OWN-FILE-ASSET-URL-FROM-CUBEJS> with something similar to this: /dA/716dcfa9-537d-419a-837f-73084a499cf3/fileAsset/1200w/50q/bg-footer.jpg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: QA - In Progress
Development

No branches or pull requests

2 participants