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 filters arrays multi values in the CA Query #30191

Open
freddyDOTCMS opened this issue Sep 30, 2024 · 2 comments · Fixed by #30210
Open

Support filters arrays multi values in the CA Query #30191

freddyDOTCMS opened this issue Sep 30, 2024 · 2 comments · Fixed by #30210

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 FILE and PAGE request:

CubeJS Query:


{
  "measures": [
    "request.count"
  ],
  "filters": [
    {
      "member": "request.whatAmI",
      "operator": "equals",
      "values": [
        "PAGE",
        "FILE"
      ]
    }
  ],
  "dimensions": [
    "request.url"
  ],
  "order": {
    "request.count": "desc"
  }
}

Our less verbose Syntax:


{
  "measures": [
    "request.count"
  ],
  "filters": "request.whatAmI = ['PAGE', 'FILE']",
  "dimensions": [
    "request.url"
  ],
  "order": {
    "request.count": "desc"
  }
}

This is not working because it ignore the FILE value

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', 'FILE']"
                })

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

Accessed Pages

#foreach($item in $collection)
   -> Page Title: $item.get("request.pageTitle").get()
   -> Page URL: $item.get("request.url").get()
   -> Page ID: $item.get("request.pageId").get()
   -> Page Count: $item.get("request.count").get()
   
#end

Acceptance Criteria

Make multi values works in filters

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

@freddyDOTCMS freddyDOTCMS added the dotCMS : Analytics Data and Analytics Umbrella label Oct 1, 2024
@jcastro-dotcms jcastro-dotcms self-assigned this Oct 1, 2024
jcastro-dotcms added a commit that referenced this issue Oct 2, 2024
…e `filters` attribute in our Content Analytics Query
github-merge-queue bot pushed a commit that referenced this issue Oct 2, 2024
…e `filters` attribute in our Content Analytics Query (#30210)

### Proposed Changes
* Supporting the comparison of an array of values for the `filters`
attribute in our Content Analytics Query. This way, our custom filter
parameter can work just like it does in a CubeJS Query.
@jcastro-dotcms jcastro-dotcms reopened this Oct 2, 2024
@dsilvam dsilvam assigned dsilvam and unassigned jcastro-dotcms Oct 3, 2024
@dsilvam
Copy link
Contributor

dsilvam commented Oct 3, 2024

Passed Internal QA:

Tested with this query in the velocity query tool:

#set ($queryMap = {"measures" : ["request.count"], 
                "orders": "request.count desc",
                "dimensions": [
                    "request.url",
                    "request.pageTitle", 
                    "request.fileTitle",
                    "request.whatAmI", 
                    "request.pageId"
                  ],
                "filters":"request.whatAmI = ['PAGE', 'FILE']"
                })

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

Accessed Pages

#foreach($item in $collection)
   -> What I am: $item.get("request.whatAmI").get()
   #if($item.get("request.whatAmI").get()=="FILE")
   -> File Title: $item.get("request.fileTitle").get()
   #else
    -> Page Title: $item.get("request.pageTitle").get()
   #end    
   -> Page URL: $item.get("request.url").get()
   
   -> Page Count: $item.get("request.count").get()
   
#end

Response as expected https://gist.github.com/dsilvam/96062619fe6baad731d9d91173d284e5

@josemejias11
Copy link
Contributor

Approved: Tested on trunk_a12617a, Docker, macOS 14.5, FF v126.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment