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

exporter: pivot table report generator #642

Merged
merged 6 commits into from
Oct 16, 2024

Conversation

bangarang
Copy link
Collaborator

@bangarang bangarang commented Sep 25, 2024

announcement

@bangarang bangarang changed the title feat/PivotTableReportGenerator exporter: pivot table report generator Sep 25, 2024
@carlbrugger carlbrugger force-pushed the feat/PivotTableReportGenerator branch from 6c72d78 to 958f2aa Compare October 1, 2024 22:58
@carlbrugger carlbrugger force-pushed the feat/PivotTableReportGenerator branch from 7bfd66e to 9acfdd7 Compare October 15, 2024 18:47
@carlbrugger carlbrugger marked this pull request as ready for review October 15, 2024 19:00
Copy link
Contributor

coderabbitai bot commented Oct 15, 2024

Walkthrough

The changes introduce the @flatfile/plugin-export-pivot-table, a new plugin for generating pivot tables from sheet data and saving them as Markdown documents. It listens for the job:ready event linked to the workbook:generatePivotTable job type, retrieves relevant data, and constructs a pivot table based on user-defined parameters. Additionally, several utility functions and configuration files are created to support the functionality, including a Rollup configuration for bundling the plugin.

Changes

File Path Change Summary
export/pivot-table/README.MD Introduced documentation for the @flatfile/plugin-export-pivot-table, detailing its functionality and usage.
export/pivot-table/rollup.config.mjs Added Rollup configuration file for the plugin, exporting a default config object.
export/pivot-table/src/index.ts Added export for pivotTablePlugin, modified existing plugin configurations in the Flatfile listener.
export/pivot-table/src/pivot.table.plugin.ts Introduced PivotTableConfig interface and pivotTablePlugin function for setting up the listener and generating pivot tables.
export/pivot-table/src/pivot.table.utils.ts Added utility functions generatePivotTable and convertPivotTableToMarkdown for pivot table creation and formatting.
flatfilers/sandbox/src/index.ts Replaced existing plugins with pivotTablePlugin, renamed and modified the structure of sheets and fields.

Possibly related PRs

Suggested reviewers

  • carlbrugger

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5d68ff0 and 075269e.

⛔ Files ignored due to path filters (1)
  • export/pivot-table/announcement.svg is excluded by !**/*.svg, !**/*.svg
📒 Files selected for processing (1)
  • .changeset/dirty-eels-breathe.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/dirty-eels-breathe.md

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 11

🧹 Outside diff range and nitpick comments (4)
export/pivot-table/src/index.ts (1)

1-1: LGTM! Consider file naming convention and adding a brief comment.

The export statement looks good and aligns with the PR objective of adding a new pivot table report generator. However, I have a couple of suggestions:

  1. The naming convention of the imported file ('pivot.table.plugin') is unusual. Consider renaming it to follow a more standard convention, such as 'pivot-table.plugin.ts' or 'pivotTablePlugin.ts'.

  2. It would be helpful to add a brief comment explaining the purpose of this export and what pivotTablePlugin does. This can improve code readability and maintainability.

Here's a suggested modification:

// Export the pivot table plugin for generating reports from sheet data
export { pivotTablePlugin } from './pivot-table.plugin';
export/pivot-table/README.MD (2)

15-27: Adjust heading levels for consistency.

The parameter descriptions are clear and informative. However, for better document structure and consistency, consider changing the heading levels for parameter names from h4 (####) to h3 (###).

Apply this change to all parameter headings:

-#### `pivotColumn` - `string` 
+### `pivotColumn` - `string` 
🧰 Tools
🪛 Markdownlint

17-17: Expected: h3; Actual: h4
Heading levels should only increment by one level at a time

(MD001, heading-increment)


42-82: LGTM: Usage section is comprehensive and well-structured.

The usage section provides clear instructions for installation, import, and implementation of the plugin. The examples are helpful and easy to follow.

For consistency with the rest of the document, consider using h3 (###) headings for "Install", "Import", and "listener.js" instead of bold text. However, this is a minor stylistic choice and the current format is also acceptable.

Optional change for consistency:

-**install**
+### Install

-**import**
+### Import

-**listener.js**
+### listener.js
🧰 Tools
🪛 Markdownlint

44-44: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


49-49: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


54-54: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


67-67: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

export/pivot-table/src/pivot.table.utils.ts (1)

85-132: Make numeric formatting configurable in Markdown output

The toFixed(2) method formats numbers to two decimal places. Consider making the number of decimal places configurable or adaptable based on the data to improve readability.

For example, you could add a parameter for decimal places:

-export function convertPivotTableToMarkdown(pivotTable: any): string {
+export function convertPivotTableToMarkdown(pivotTable: any, decimalPlaces: number = 2): string {

  // ...

- row.push(typeof value === 'number' ? value.toFixed(2) : value || '-')
+ row.push(typeof value === 'number' ? value.toFixed(decimalPlaces) : value || '-')
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ad3d45f and 5d68ff0.

⛔ Files ignored due to path filters (4)
  • export/pivot-table/package.json is excluded by !**/*.json
  • export/pivot-table/samples/sample_sales_data.csv is excluded by !**/*.csv, !**/*.csv
  • package-lock.json is excluded by !**/package-lock.json, !**/*.json
  • package.json is excluded by !**/*.json
📒 Files selected for processing (6)
  • export/pivot-table/README.MD (1 hunks)
  • export/pivot-table/rollup.config.mjs (1 hunks)
  • export/pivot-table/src/index.ts (1 hunks)
  • export/pivot-table/src/pivot.table.plugin.ts (1 hunks)
  • export/pivot-table/src/pivot.table.utils.ts (1 hunks)
  • flatfilers/sandbox/src/index.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • export/pivot-table/rollup.config.mjs
🧰 Additional context used
🪛 Markdownlint
export/pivot-table/README.MD

17-17: Expected: h3; Actual: h4
Heading levels should only increment by one level at a time

(MD001, heading-increment)


44-44: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


49-49: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


54-54: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


67-67: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

🔇 Additional comments (8)
export/pivot-table/README.MD (3)

1-8: LGTM: Infocard section is informative and well-structured.

The infocard section provides a clear and concise description of the plugin's purpose and the event type it responds to. This information is crucial for users to understand the plugin's functionality at a glance.


31-38: LGTM: API Calls section is clear and informative.

The list of API calls used by the plugin is well-presented and provides valuable information for developers who might need to understand the plugin's interactions with the Flatfile API.


84-122: LGTM: Functionality and Output Format sections are well-detailed and helpful.

The Functionality section provides a clear, step-by-step explanation of how the plugin works, which is very useful for users and developers. The Output Format section, complete with an example, gives users a concrete understanding of what to expect from the plugin.

These sections greatly enhance the README's value by providing in-depth information about the plugin's operation and results.

flatfilers/sandbox/src/index.ts (4)

2-2: Import statement is correctly added

The pivotTablePlugin is properly imported from '@flatfile/plugin-export-pivot-table'.


7-11: Verify plugin configuration parameters

The parameters for pivotTablePlugin seem appropriate. Ensure that:

  • The aggregationMethod 'sum' is supported by the plugin.
  • The fields 'product', 'salesAmount', and 'region' exist and are correctly defined in your sheet.

21-22: Sheet name and slug updated appropriately

The sheet is renamed to 'Sales' with the slug 'sales', aligning with the sales data focus.


52-62: Review the 'type' property in the action configuration

The property type: 'string' in the action configuration may not be necessary or might be incorrect. Verify if this property is required, and if so, ensure it has the correct value for an action.

export/pivot-table/src/pivot.table.plugin.ts (1)

41-42: Ensure all records are retrieved when fetching data

The api.records.get(sheetId) method may paginate records if there are a large number. This could result in incomplete data being used to generate the pivot table.

Verify whether pagination is necessary and adjust the code to retrieve all records:

@bangarang bangarang enabled auto-merge (squash) October 16, 2024 03:57
@bangarang bangarang merged commit 08afb84 into main Oct 16, 2024
35 of 36 checks passed
@bangarang bangarang deleted the feat/PivotTableReportGenerator branch October 16, 2024 04:13
This was referenced Oct 28, 2024
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