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

Ab#85981 - In email preview, use same logic than in grid export to replace {{dataset}} and attach export files #984

Open
wants to merge 8 commits into
base: 2.x.x
Choose a base branch
from

Conversation

guisoares1
Copy link
Contributor

@guisoares1 guisoares1 commented Feb 16, 2024

Description

Previously, the extractGridData file had its own logic for fetching records. However, we noticed that the logic in src > utils > files > resourceExporter is quite similar, albeit with some differences due to its need to generate a file.

To avoid redundancy and improve maintainability, we have refactored the code to reuse the record fetching logic from resourceExporter in extractGridData.

Useful links

Type of change

Please delete options that are not relevant.

  • Improvement (refactor or addition to existing functionality)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.

  • I created a preview email with {{dataset}} configured and observed system behavior

Screenshots

2024-02-20.10-51-21.mp4

Checklist:

( * == Mandatory )

  • * I have set myself as assignee of the pull request
  • * My code follows the style guidelines of this project
  • * Linting does not generate new warnings
  • * I have performed a self-review of my own code
  • * I have put the ticket for review, adding the oort-backend team to the list of reviewers
  • * I have commented my code, particularly in hard-to-understand areas
  • * I have put JSDoc comment in all required places
  • * My changes generate no new warnings
  • * I have included screenshots describing my changes if relevant
  • * I have selected labels in the Pull Request, according to the changes with code brings
  • I have made corresponding changes to the documentation ( if required )
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

More explanation

https://www.loom.com/share/05a716d61b9744faaf51fb304c21d1e5?sid=f87cf896-582a-4f76-93ae-8ceed801b145

@guisoares1 guisoares1 self-assigned this Feb 16, 2024
@guisoares1 guisoares1 added the enhancement Existing feature label Feb 16, 2024
@NathanHGit
Copy link
Contributor

hi @AntoineRelief

Is this bullet point of the ticket

in addition, we can allow the email to attach the selected data of the grid. It still uses the old logic, not optimised, so it can be changed to use the resourceExporter code

referring to the following code by "old logic" ?

  // Attach excel
  if (getAttachments && args.attachment && rows.length > 0) {
    const today = new Date();
    const month = today.toLocaleString('en-us', { month: 'short' });
    const date = month + ' ' + today.getDate() + ' ' + today.getFullYear();
    const name = args.query.name.substring(3);
    fileName = name + ' ' + date;
    const file = await xlsBuilder(fileName, columns, rows);
    attachments.push({
      filename: `${fileName}.xlsx`,
      content: file,
    });
  }

in src\routes\email\index.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants