Skip to content

Conversation

jordojordo
Copy link
Member

@jordojordo jordojordo commented Sep 5, 2025

Summary

Fix MA-4298

This PR will increase the maximum number of records returned by the CSV export functionality from 50 to 250 records.

Main changes:

  • Maximum records increased from 50 to 250
  • Users now see a loading skeleton while export data is being fetched
  • Clear indication of the 250 group limit within a tooltip
  • Export data is fetched independently from the chart data

Technical changes:

  • Created useAnalyticsRequestExport in analytics-utilities for shared export functionality
  • Added a CsvExportState type to handle loading, success, and error states
  • CsvExportModal now accepts exportState instead of direct chartData

@jordojordo jordojordo marked this pull request as ready for review September 8, 2025 16:30
@jordojordo jordojordo requested a review from a team as a code owner September 8, 2025 16:30
Copy link
Contributor

@adorack adorack left a comment

Choose a reason for hiding this comment

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

I'd like to review.

Copy link
Contributor

@adorack adorack left a comment

Choose a reason for hiding this comment

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

Still reviewing; thinking about whether DashboardTile is the right place to build the new query.

"exportAsCsv": "Export as CSV",
"exportTimeRange": "Time range",
"exportDescription": "Exports a CSV of the data represented in the chart.",
"maximumRecordAmount": "The amount of rows is limited to {value}",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"maximumRecordAmount": "The amount of rows is limited to {value}",
"maximumRecordAmount": "The number of groups is limited to {value}",

<CsvExportModal
v-if="exportModalVisible"
:chart-data="(chartData as ExploreResultV4)"
:chart-data="(exportExploreResult || (chartData as ExploreResultV4))"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the data model should be a bit more comprehensive:

  • I don't think we should fall back to chartData -- if the export request fails, the modal should reflect that. I think it's better to behave consistently rather than sometimes give different results if there's an error.
  • Since it's making a new request, the modal should have a way of displaying an error if there is one.

You might get along better with Typescript if you make a union type for loading | success | error and pass that as one property, rather than having separate loading / error /data props. Happy to discuss further.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's fair, I'll work on some changes to reflect this.

}
// Build a larger dataset for CSV export
const requestExport = async (limit: number = EXPORT_RECORD_LIMIT): Promise<ExploreResultV4 | undefined> => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is code that's very similar to what's needed in ui-apps, I think this should be refactored out to some common place -- maybe a composable in analytics-chart; this would allow it to call onUnmounted and to inject the query bridge.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the feedback, I've refactored the export functionality into a utility/composable within the analytics-chart package. I'll add info of the changes to the main PR description.

@jordojordo jordojordo force-pushed the feat/ma-4298 branch 2 times, most recently from c1b6189 to 55b43e7 Compare September 10, 2025 11:35
@jordojordo jordojordo requested a review from adorack September 10, 2025 13:00
@jordojordo jordojordo force-pushed the feat/ma-4298 branch 3 times, most recently from e587ed8 to ba75953 Compare September 10, 2025 14:06
</div>
</template>

<script setup lang="ts">
Copy link
Member Author

Choose a reason for hiding this comment

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

Cleaned up the imports in this file as they were all over the place.

jordojordo and others added 3 commits September 10, 2025 11:53
- Update CSV export modal so it just emits `closeModal` rather than `toggleModal` with a parameter that's always false.
- Remove requestExport composable because it's no longer code in common with ui-apps.
- Add new composable, just for use in the dashboard renderer, that knows how to merge context and issue a query.
- Allow DashboardTile to issue queries to export a CSV.
@jordojordo jordojordo merged commit 70b2825 into main Sep 15, 2025
13 checks passed
@jordojordo jordojordo deleted the feat/ma-4298 branch September 15, 2025 12:34
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