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

[O2B-1194] Refactor export functionality #1462

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

xsalonx
Copy link
Collaborator

@xsalonx xsalonx commented Mar 14, 2024

I have a JIRA ticket

  • branch and/or PR name(s) include(s) JIRA ID
  • issue has "Fix version" assigned
  • issue "Status" is set to "In review"
  • PR labels are selected

Notable changes for users:

  • Changed export functionality:
    • Allow to input file name
    • Use spinner to show data are being loaded

Notable changes for developers:

  • Extracted export-related methods to OverviewPageModel
  • Generalised exportTriggerAndModal to work with another overview views

Changes made to the database:

  • NA

@xsalonx xsalonx self-assigned this Mar 14, 2024
@xsalonx xsalonx marked this pull request as ready for review March 14, 2024 09:49
Copy link

codecov bot commented Mar 14, 2024

Codecov Report

Attention: Patch coverage is 0% with 86 lines in your changes are missing coverage. Please review.

Project coverage is 45.20%. Comparing base (24ddf8b) to head (3536cf7).
Report is 358 commits behind head on main.

Files Patch % Lines
lib/public/models/OverviewModel.js 0.00% 53 Missing ⚠️
...ublic/views/Runs/Overview/exportTriggerAndModal.js 0.00% 32 Missing ⚠️
...ib/public/views/Runs/Overview/RunsOverviewModel.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1462      +/-   ##
==========================================
- Coverage   48.78%   45.20%   -3.58%     
==========================================
  Files         528      768     +240     
  Lines        7968    12452    +4484     
  Branches     1477     2220     +743     
==========================================
+ Hits         3887     5629    +1742     
- Misses       4081     6823    +2742     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@martinboulais martinboulais left a comment

Choose a reason for hiding this comment

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

I would suggest a bit of rework on top of my comments:

  • I propose to extract something like ExportConfigurationModel to store the configuration of the export, like selected columns and export type
  • I would create two classes (and maybe a common interface, but not sure it makes sense without ts): something like CsvExportGenerator and JsonExportGenerator that both expose an export function that takes as parameter a list of items, a list of properties, a file name and generate the corresponding file.

@@ -51,6 +58,25 @@ export class OverviewPageModel extends Observable {

this._observableItems = ObservableData.builder().initialValue(RemoteData.loading()).build();
this._observableItems.bubbleTo(this);

this._exportDataSource = new PaginatedRemoteDataSource();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Exports are not paginated

}

/**
* Get the field values that will be exported
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this comment is misleading, because it seems like you return the value of the fields.
I would rather use Get the list of properties that will be exported for each items

}

/**
* Set the selected fields to be exported
Copy link
Collaborator

Choose a reason for hiding this comment

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

Set the list of properties that will be exported for each items

@@ -136,8 +251,30 @@ export class OverviewPageModel extends Observable {
}

/**
* Return the current items remote data
* States if the list of NOT paginated runs contains the full list of runs available under the given criteria
Copy link
Collaborator

Choose a reason for hiding this comment

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

runs?

*/
get areExportItemsTruncated() {
return this.exportItems.match({
Success: (payload) => this.items.match({
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do you need this second match?

@@ -0,0 +1,143 @@
/**
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would go further and move this away from Runs

@xsalonx xsalonx marked this pull request as draft May 30, 2024 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants