Skip to content

CDD-3342 - Dual category chart download api endpoint#3250

Open
tushortz wants to merge 4 commits into
feature/CDD-3295-dual-category-chart-interfacefrom
feature/CDD-3342-dual-category-chart-download-api-endpoint
Open

CDD-3342 - Dual category chart download api endpoint#3250
tushortz wants to merge 4 commits into
feature/CDD-3295-dual-category-chart-interfacefrom
feature/CDD-3342-dual-category-chart-download-api-endpoint

Conversation

@tushortz

Copy link
Copy Markdown
Contributor

Description

This PR includes the following:

  • dual category chart download interface/api
  • cms bug fix due to use of wrong second_category name

Fixes #CDD-3342


Type of change

Please select the options that are relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Tech debt item (this is focused solely on addressing any relevant technical debt)

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests at the right levels to prove my change is effective
  • I have added screenshots or screen grabs where appropriate
  • I have added docstrings in the correct style (google)

@tushortz tushortz requested a review from a team as a code owner June 11, 2026 12:33
@tushortz

Copy link
Copy Markdown
Contributor Author

Payload

{
  "file_format": "json",
  "x_axis": "age",
	"chart_type": "stacked_bar",
  "y_axis": "metric",
  "confidence_intervals": true,
  "primary_field_values": [
    "00-01",
    "01-04",
    "05-09",
    "05-11",
    "05-14",
    "10-14"
  ],
  "static_fields": {
    "topic": "Lead",
    "metric": "lead_headline_ratesByAgeSex",
    "geography": "England",
    "geography_type": "Nation",
    "sex": "all",
    "age": "all",
    "stratum": "default",
    "date_from": "2020-05-21",
    "date_to": "2026-05-21"
  },
  "secondary_category": "sex",
  "segments": [
		{
			"secondary_field_value": "f",
			"colour": "COLOUR_1_DARK_BLUE",
			"label": "Females"
		},
		{
			"secondary_field_value": "m",
			"colour": "COLOUR_1_DARK_BLUE",
			"label": "Males"
		}
  ]
}

@tushortz

Copy link
Copy Markdown
Contributor Author
image
[
	{
		"age": "00-01",
		"theme": "climate_and_environment",
		"sub_theme": "chemical_exposure",
		"topic": "Lead",
		"geography_type": "Nation",
		"geography": "England",
		"metric": "lead_headline_ratesByAgeSex",
		"stratum": "default",
		"period_start": "2023-01-01 00:00:00",
		"period_end": "2023-12-31 00:00:00",
		"m": "5.5000",
		"f": "6.0000"
	},
	{
		"age": "01-04",
		"theme": "climate_and_environment",
		"sub_theme": "chemical_exposure",
		"topic": "Lead",
		"geography_type": "Nation",
		"geography": "England",
		"metric": "lead_headline_ratesByAgeSex",
		"stratum": "default",
		"period_start": "2023-01-01 00:00:00",
		"period_end": "2023-12-31 00:00:00",
		"m": "22.3000",
		"f": "13.5000"
	},
        ...
]

@tushortz tushortz force-pushed the feature/CDD-3342-dual-category-chart-download-api-endpoint branch from ee1121e to 2ab07d6 Compare June 11, 2026 12:43
@aidan aidan force-pushed the feature/CDD-3295-dual-category-chart-interface branch from ce3ae71 to 3dca217 Compare June 11, 2026 12:57
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
3.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

**static_fields,
}
groups_plots.append(plot)
print(f"AIDAN: plots {groups_plots}")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove

)
@require_authorisation
def post(cls, request, *args, **kwargs):
"""This endpoint can be used to generate chart data in tabular format.

@tushortz tushortz Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the payload is different for dual categroy charts so the examples below in the docstring is not applicable here

```

"""
print(f"AIDAN: serialising {request.data}")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you remove the print above and below

@tushortz

Copy link
Copy Markdown
Contributor Author

@aidan these are my observations that needs fixing so far

  • Fix SonarQube warnings (Majority are because you have print statements you forgot to remove
  • Fix test coverage. Currently 99.97
  • Code error. (this is because DownloadsView is now renamed as SingleCategoryDownloadsView. so you can just remove it from the import in metrics/api/urls_construction.py
  • Timeseries serializer should not require primary_field_values. See DualCategoryChartSerializer.validate() for example
  • I receive response for other endpoints like downloads and charts but not for tables. Could you have a look please?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants