-
Notifications
You must be signed in to change notification settings - Fork 7
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
RN-484: Add ability for defining 'custom reports' in the report-server #4090
Conversation
- This meets a long time need of a way for viz builders to create ad hoc js functions that pull whatever data they need - We want these to be uncommonly used, and we should endeavour to consolidate common needs into clean ways of doing things via the viz-builder
- Added test to check we can extract a customReport
@@ -24,20 +18,22 @@ const getPresentation = (dashboardItem: DashboardItem, report: Report | LegacyRe | |||
const { type, name, ...config } = dashboardItemConfig; | |||
|
|||
const presentation: Record<string, unknown> = { type, ...config }; | |||
if (!dashboardItem.legacy) { | |||
if (!dashboardItem.legacy && 'output' in reportConfig) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having typescript in this package was an absolute godsend! It would have been sooo bug prone to try and make such a change without type safety 😄
const { fetch, transform } = config; | ||
const { aggregations, ...restOfFetch } = fetch; | ||
return { fetch: restOfFetch, aggregate: aggregations, transform }; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored this out as it was common between mapOverlay and dashboardItem logic
width: 100%; | ||
height: 100%; | ||
} | ||
`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am no css craftsperson 😢 You can see the ticket for an example. But given this should be for internal use only I don't mind it if it looks a bit bad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace CustomReportName
to div will do the work, don't need to attach any css.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah thanks @billli0 !
{ filter: { type: 'facility' } }, | ||
); | ||
return [{ value: facilities.length }]; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this testCustomReport
as an example for future use and a bit of a proof of concept. @chris-bes feel free to remove this once you add your actual implementation 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rohan-bes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rohan-bes for adding this custom report function. Looks great!
Issue RN-484:
There often come times where we need to rush out a viz, and the demands to get it to work are too tricky for the viz builder at the moment.
The 'Custom Report' is an option to just handcraft a single JS function that pulls and transforms all the data we need. I prefer this option over using the legacy databuilders for a few reason:
@tupaia/api-client
But happy to hear push back from the reviewer if they feel this really muddies the report-server code?
Thoughts on the name 'Custom Reports' btw? It feel a bit weak and non-descriptive to me... HardCodedReport? idk...