cortezaproject / corteza

Low-code platform
https://cortezaproject.org
Apache License 2.0
1.65k stars 379 forks source link

How do I power metrics for single module #1904

Open amanr11314 opened 2 months ago

amanr11314 commented 2 months ago

Is there an existing issue for this?

Version of Corteza

2023.9

Current Behavior

I have a module Lead I have following field in this module:

name source (specific option fields from select type field) channel (specific option fields from select type field) phone_number amount call_status (option of answered, missed if channel=‘Call’) lead_time appointment_status (unscheduled, scheduled, completed) location I have to power a dashboard with filter option of multi select location, date range (lead_time)

for selected filter I have to provide with the following chart metrics:

Lead count per source, per channel

Sum of Lead amount per source

Lead Conversion Count (appointment_status non empty) per source, per channel

Tracked Leads Count (Leads with phone_number non empty)

Call Status count per source where channel=‘Call’ i.e Answered count, Missed count

Also I have to group by bucket size from user input option of (week, month, day, year) for by grouping bucket on column lead_time : I. Total Lead Count per bucket II. Tracked Lead Count per bucket (Leads with phone_number non empty) III. Total Lead Conversion count per bucket (appointment_status non empty) IV. Total Lead production per bucket sum(amount) per bucket

  1. Currently I am only to call separate rest API for each metrics but not minimized: In this case I have to call report metrics API for module: However, this requires multiple API calls which is not feasible for frontend.

curl --location 'https://corteza-staging.remedoapp.com/api/compose/namespace/405510032080240642/module/406086487709319170/record/report?dimensions=CONCAT(source%2C%20%27-%27%2C%20medium%2C%20%27-%27%2C%20callStatus)&filter=medium%3D%27Call%27' \ --header 'accept: application/json, text/plain, */*' \ --header 'authorization: Bearer <token>'

  1. Created Reports Page using datasources but: I. I have to apply separate filter on loaded datasources dynamically for each metrics but I am unable to do so in API call. II. I have to create aggregate datasource for each section from original module datasource due to which I have no control over filters from api.

I am using this curl to fetch each element in report but unable to apply filter: curl --location 'https://corteza-staging.remedoapp.com/api/system/reports/406772798300618754/run' \ --header 'accept: application/json, text/plain, */*' \ --header 'authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "frames": [ { "name": "407139715293184002", "source": "GROUP BY SOURCE-AMOUNT", "ref": "GROUP BY SOURCE-AMOUNT", "filter": {}, "sort": "" } ] }'

Expected Behavior

How can I power these metrics in single API call if not possible how to minimize the API calls for these metrics independent of each Section

Steps To Reproduce

No response

Environment and versions

No response

Anything else?

No response

github-actions[bot] commented 3 weeks ago

Stale issue message