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

[Canned Reports] Create visualisation on question #835

Open
Tracked by #1688
mahalakshme opened this issue Dec 16, 2024 · 10 comments
Open
Tracked by #1688

[Canned Reports] Create visualisation on question #835

mahalakshme opened this issue Dec 16, 2024 · 10 comments
Assignees

Comments

@mahalakshme
Copy link
Contributor

mahalakshme commented Dec 16, 2024

AC:

  • Users should be able to see count of individuals registered for each subject type in the form of pie-chart Do not include the voided individuals and voided subject types.
  • Piechart colors should be of lighter shades mentioned here - lighter shades
  • Create via GUI options using API, so that we can make use of the drill-through functionality.
  • On drilling on the pie-chart, w.r to observation, concept names should be shown in separate columns, and values which are coded, should also have concept answer names. Instead of address id, each location type should show up in separate columns so that it can be filtered later.
  • If needed, apply the above question on a modal, to get the expected results

Technical suggestions:

Metabase api link

Approximate payload that might work - Not tested:

POST /api/card
Request Body Example:
json
Copy code
{
  "name": "Count by Category",
  "dataset_query": {
    "type": "query",
    "query": {
      "source-table": "your_table_id",
      "aggregation": [["count"]],
      "breakout": [["field-id", 123]]  // Replace 123 with the field ID of your category column
    }
  },
  "display": "table"  // Can be "bar", "pie", etc., depending on the visualization
}

Thoughts:

  • Just showing numbers like in Cini seems to be more work for user to be able to comprehend - piechart seems to be more compact.
  • Observations, with uuids replaced with their names , and uuids of concept answers replaced with their names - should be done as part of ETL itself or model can be created(seems to take more time), or exclude observations from union tables(because useful only in Data)
  • Are registrations across different subject types even comparables?
  • user trigger?
  • refresh - new metadata - recreation
  • within Avni -
  • drill-down -> model without observations
  • complexity

Old: Ignore


POST /api/card
Authorization: Bearer <your_api_token>

{
  "name": "Sales Data with Date Filters",
  "dataset_query": {
    "type": "native",
    "native": {
      "query": "SELECT date, SUM(sales) AS total_sales FROM sales_table WHERE date BETWEEN {{start_date}} AND {{end_date}} GROUP BY date ORDER BY date",
      "template-tags": {
        "start_date": {
          "id": "c53df913",
          "name": "start_date",
          "display_name": "Start Date",
          "type": "date",
          "default": "2023-01-01"  // Optional default value
        },
        "end_date": {
          "id": "c82df913",
          "name": "end_date",
          "display_name": "End Date",
          "type": "date",
          "default": "2023-12-31"  // Optional default value
        }
      }
    },
    "database": 1  // Replace with your database ID
  },
  "display": "bar",  // Visualization type
  "visualization_settings": {
    "x_axis.title": "Date",
    "y_axis.title": "Total Sales",
    "graph.line_style": "solid"
  },
  "collection_id": null  // Add to a collection if needed
}

Inputs-Ignore-for analysis purpose and later reference:

  • paste the chart here
  • line chart over bar chart - intelligently - every line will be subject type
  • metabase, dataogram - ODK and metabase -> absolute, and then trend, display data below that
@mahalakshme mahalakshme converted this from a draft issue Dec 16, 2024
@mahalakshme mahalakshme moved this from In Analysis to In Analysis Review in Avni Product Dec 16, 2024
@mahalakshme mahalakshme changed the title Create visualisation on question with filters [Canned Reports] Create visualisation on question with filters Dec 16, 2024
@ombhardwajj
Copy link
Contributor

Please assign it to me @mahalakshme !

@mahalakshme mahalakshme moved this from In Analysis Review to Ready in Avni Product Dec 18, 2024
@petmongrels petmongrels moved this from Ready to In Progress in Avni Product Dec 20, 2024
@petmongrels petmongrels moved this from In Progress to Ready in Avni Product Dec 20, 2024
@mahalakshme mahalakshme moved this from Ready to In Analysis in Avni Product Dec 26, 2024
@mahalakshme mahalakshme changed the title [Canned Reports] Create visualisation on question with filters [Canned Reports] Create visualisation on question Dec 26, 2024
@mahalakshme mahalakshme moved this from In Analysis to In Analysis Review in Avni Product Dec 27, 2024
@ombhardwajj
Copy link
Contributor

ombhardwajj commented Jan 6, 2025

Hey @mahalakshme

  1. Since we would need to specify color for each subject type individually
    (see the expected payload here https://gist.github.com/ombhardwajj/bec45e2fb53be8910847455b62356bc9) I don’t think it would be a good idea to make those of lighter colors to match our color scheme unless metabase colors look too bad which isn’t the case. Anyways lmk if we need to proceed with this

  2. Couldn't find anything related to GUI options. I’ve used the APIs and we can still use the drill through functionality.

  3. I don’t think we can get concept names with drill through . It only shows the option to see those individuals
    (see screenshot).

Screenshot 2025-01-06 at 5 32 17 PM

p.s. code is almost ready for this!

@mahalakshme mahalakshme moved this from In Analysis Review to In Progress in Avni Product Jan 9, 2025
@mahalakshme
Copy link
Contributor Author

@ombhardwajj the above is fine, just hide the observations column, I think when compared to creating model in metabase, you can just create a view in the server codebase to use for this if needed.

cc: @petmongrels based on yesterdays' discussion thought we can start back the work.

@ombhardwajj
Copy link
Contributor

Commit added @mahalakshme !

@mahalakshme
Copy link
Contributor Author

Yayy!!

@ombhardwajj ombhardwajj moved this from In Progress to Code Review Ready in Avni Product Jan 9, 2025
@petmongrels petmongrels moved this from Code Review Ready to In Code Review in Avni Product Jan 15, 2025
@petmongrels
Copy link
Contributor

  1. org.avni.server.dao.metabase.DatabaseRepository#getExistingCollectionItems, org.avni.server.dao.metabase.DatabaseRepository#getCollectionByName, should be in Collection Repository
  2. We need a separate question repository. org.avni.server.dao.metabase.DatabaseRepository#createQuestionForASingleTable, org.avni.server.dao.metabase.DatabaseRepository#createAdvancedQuestion, org.avni.server.dao.metabase.DatabaseRepository#postQuestion
  3. lets make the method that are access only from within the class private
  4. why createAdvancedQuestion2 and createAdvancedQuestion two methods
  5. I am not sure whether all of this was added in the same story but we should fix all this.
  6. Since we are not creating dashboard right now, lets remove the calls for them. We can get back to it in an appropriate story down the line. Right now it would create confusion.

@petmongrels petmongrels moved this from In Code Review to Code Review with Comments in Avni Product Jan 15, 2025
@mahalakshme
Copy link
Contributor Author

@petmongrels thought if creating dashboard and filters for it are not too complex, we can do them - to assess that - added creating one dashboard and filter to this card: #837 not the current(#835) card.

My intention was to try to get things work end-end instead of going deep on one thing. Let me know if you think otherwise.

@petmongrels
Copy link
Contributor

ok. will review the code when done

@ombhardwajj
Copy link
Contributor

Code refactoring done , please review @petmongrels !

@petmongrels petmongrels moved this from Code Review with Comments to QA Ready in Avni Product Jan 16, 2025
@petmongrels
Copy link
Contributor

Testing related

  • Enabling canned report for an existing organisation which has ETL enabled. This is more important as for new organisation there may not be any data to test. Better to be done with any org which is well configured and has some data.
  • Lets add this to our regression suite, to be applicable from release 12

petmongrels added a commit that referenced this issue Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: QA Ready
Development

No branches or pull requests

3 participants