Skill: Create Monitoring Report
When to Use
- Use this skill when implementing a new
monitoringreport type (new model/report generator + API registry entry). - Use it when
python manage.py generate_report <report_type>must support a new type. - Use it when
/v1/monitoring/report*must expose a newreport_type. - Do NOT use this skill for read-only consumption of existing reports.
- Do NOT use this skill for unrelated domains outside
breathecode.monitoring.
Workflow
- Define the report data model under
breathecode/monitoring/reports/<report_type>/models.py. - Implement a generator class in
breathecode/monitoring/reports/<report_type>/actions.pyextendingBaseReport. - Register command generation by adding the new class in
breathecode/monitoring/management/commands/generate_report.pyREPORT_REGISTRY. - Add list/detail serializers in
breathecode/monitoring/serializers.pyfor the new report model. - Register API metadata in
breathecode/monitoring/reports/api_registry.py:
slug,label,descriptionmodel,list_serializer,detail_serializerfilters,sort_fields,default_sortsupports_detail,supports_summary,summary_builder,date_field(as needed)
- Validate list/detail/summary behavior through existing generic monitoring report endpoints in
breathecode/monitoring/views.pyandbreathecode/monitoring/urls.py(no new endpoint path required). - Add tests for report generation command and report API behavior.
- Run focused tests for new report files plus current monitoring report URL tests.
Endpoints
- Method:
GET - Path:
/v1/monitoring/report - Purpose for this skill: Verify your new
report_typeappears in discovery metadata.
Response fields to verify
{
"slug": "new-report-slug",
"filters": ["academy", "date"],
"sort_fields": ["created_at", "-created_at"],
"supports_detail": true,
"supports_summary": true
}
- Method:
GET - Path:
/v1/monitoring/report/{report_type} - Purpose for this skill: Verify list serialization and filters for the new report.
- Method:
GET - Path:
/v1/monitoring/report/{report_type}/{report_id} - Purpose for this skill: Verify detail serializer output for one row.
- Method:
GET - Path:
/v1/monitoring/report/{report_type}/summary - Purpose for this skill: Verify summary builder output shape if summary is enabled.
Edge Cases
- New report missing in discovery: confirm
api_registry.pyhas an entry inREPORT_API_REGISTRY. - Command rejects report type: confirm
generate_report.pyREPORT_REGISTRYincludes it. - Unsupported filter/sort errors: ensure
filtersandsort_fieldsin registry match intended query behavior. - Empty default list response: if
date_fieldis configured, list defaults to latest date; verify test fixtures include report rows for at least one date. - Summary fails: set
supports_summary=Falsewhen nosummary_builderexists, or implement the builder.
Checklist
- [ ] Added report model + migrations under
monitoring/reports/<report_type>. - [ ] Implemented
BaseReportsubclass with fetch/process/save flow. - [ ] Registered report in
generate_report.pyREPORT_REGISTRY. - [ ] Added serializers and API registry config for the report type.
- [ ] Verified discovery/list/detail/summary endpoints with the new
report_type. - [ ] Added automated tests for command and API behavior.
- [ ] Ran focused tests successfully before finishing.