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

feat: qbd direct servey and info box in dashboard #1175

Merged
merged 2 commits into from
Feb 5, 2025

Conversation

DhaaraniCIT
Copy link
Contributor

@DhaaraniCIT DhaaraniCIT commented Feb 5, 2025

Description

feat: qbd direct servey and info box in dashboard

Clickup

https://app.clickup.com

Summary by CodeRabbit

  • New Features
    • Added an automated prompt for users to provide feedback once export operations complete successfully.
    • Enhanced the export dashboard with a real-time instruction, guiding users to trigger an update for immediate expense synchronization.
    • Introduced a new environment variable for configuring the survey ID related to the QBD onboarding process.

Copy link
Contributor

coderabbitai bot commented Feb 5, 2025

Walkthrough

This pull request introduces enhancements that improve how a survey is triggered and how environment variables are configured. A new substitution for the placeholder {{REFINER_QBD_EXPORT_DONE_SURVEY_ID}} is added to the shell script, and an environment variable is exposed in the setup configuration. Additionally, a conditional survey trigger is incorporated into the export status polling logic of the QBD dashboard component, while the dashboard export section is updated with a new informational display and an exposed enum property.

Changes

File(s) Change Summary
run.sh, scripts/setup_env.js Added a new sed substitution for the {{REFINER_QBD_EXPORT_DONE_SURVEY_ID}} placeholder in run.sh and introduced export_done_survery_id in the refiner_survey.qbd object in scripts/setup_env.js sourced from an environment variable.
src/app/integrations/.../qbd-direct-dashboard.component.ts Introduced a conditional block in pollExportStatus to trigger a survey via refinerService when failedExpenseGroupCount is zero.
src/app/shared/components/dashboard/dashboard-export-section/(component.html & component.ts) Updated the export section: added a conditional UI message in the HTML to guide users during export and exposed the AppName enum through a new public property in the component’s TypeScript file.

Sequence Diagram(s)

sequenceDiagram
    participant Qbd as QbdDirectDashboardComponent
    participant RS as refinerService
    Qbd->>Qbd: Execute pollExportStatus
    alt Export complete with no errors (failedExpenseGroupCount == 0)
        Qbd->>RS: triggerSurvey(appName, surveyId, "export_done")
    else Export has errors
        Qbd->>Qbd: No survey triggered
    end
Loading

Possibly related PRs

Suggested labels

size/M

Suggested reviewers

  • ashwin1111

Poem

In the code-fields where logic hops free,
I nibble bugs with glee and harmony.
A survey triggered, a new variable in the mix,
My little paws dance with each clever fix.
With every gentle hop and wink so bright,
I cheer these changes day and night! 🐇

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e9f0a16 and 9963a2b.

📒 Files selected for processing (1)
  • src/app/shared/components/dashboard/dashboard-export-section/dashboard-export-section.component.html (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/app/shared/components/dashboard/dashboard-export-section/dashboard-export-section.component.html
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: unit-test

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@github-actions github-actions bot added the size/XS Extra Small PR label Feb 5, 2025
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: 0

🧹 Nitpick comments (2)
src/app/integrations/qbd-direct/qbd-direct-main/qbd-direct-dashboard/qbd-direct-dashboard.component.ts (1)

103-142: Consider handling component destruction during polling.

The polling subscription should be cleaned up when the component is destroyed to prevent memory leaks and potential errors.

Consider storing the subscription and cleaning it up in ngOnDestroy:

+private pollingSub: Subscription;

 private pollExportStatus(exportableAccountingExportIds: number[] = []): void {
-  interval(3000).pipe(
+  this.pollingSub = interval(3000).pipe(
   switchMap(() => from(this.dashboardService.getAllTasks([], exportableAccountingExportIds, [], AppName.QBD_DIRECT))),
   takeWhile((response: QbdDirectTaskResponse) =>
     response.results.filter(task =>
       (this.exportLogProcessingStates.includes(task.status))
     ).length > 0, true
   )
 ).subscribe((res: QbdDirectTaskResponse) => {
   // ... existing code ...
 });
}

+ngOnDestroy(): void {
+  if (this.pollingSub) {
+    this.pollingSub.unsubscribe();
+  }
+}
run.sh (1)

41-41: Fix potential issues with special characters in the environment variable.

The current implementation might not handle special characters in REFINER_QBD_EXPORT_DONE_SURVEY_ID correctly.

Consider using printf for safer variable substitution:

-    sed -i $SED_EXTRA_ARGS "s?{{REFINER_QBD_EXPORT_DONE_SURVEY_ID}}?${REFINER_QBD_EXPORT_DONE_SURVEY_ID}?g" $f;
+    printf -v safe_survey_id "%q" "${REFINER_QBD_EXPORT_DONE_SURVEY_ID}"
+    sed -i $SED_EXTRA_ARGS "s?{{REFINER_QBD_EXPORT_DONE_SURVEY_ID}}?${safe_survey_id}?g" $f;
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 41-41: Quotes/backslashes in this variable will not be respected.

(SC2090)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7688c10 and e9f0a16.

📒 Files selected for processing (5)
  • run.sh (1 hunks)
  • scripts/setup_env.js (1 hunks)
  • src/app/integrations/qbd-direct/qbd-direct-main/qbd-direct-dashboard/qbd-direct-dashboard.component.ts (1 hunks)
  • src/app/shared/components/dashboard/dashboard-export-section/dashboard-export-section.component.html (1 hunks)
  • src/app/shared/components/dashboard/dashboard-export-section/dashboard-export-section.component.ts (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
run.sh

[warning] 41-41: Quotes/backslashes in this variable will not be respected.

(SC2090)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: unit-test
🔇 Additional comments (5)
src/app/shared/components/dashboard/dashboard-export-section/dashboard-export-section.component.ts (1)

47-47: LGTM!

The addition of the AppName property follows Angular best practices by exposing the enum to the template.

scripts/setup_env.js (1)

44-44: LGTM!

The addition of export_done_survery_id follows the established pattern for environment variables and maintains consistency with other refiner survey configurations.

src/app/integrations/qbd-direct/qbd-direct-main/qbd-direct-dashboard/qbd-direct-dashboard.component.ts (1)

134-138: LGTM!

The survey trigger is well-implemented, with appropriate conditions to ensure it only fires after a successful export.

run.sh (1)

41-41: LGTM!

The addition of the QBD export done survey ID substitution follows the established pattern.

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 41-41: Quotes/backslashes in this variable will not be respected.

(SC2090)

src/app/shared/components/dashboard/dashboard-export-section/dashboard-export-section.component.html (1)

51-55: Conditional Rendering and Info Label Text Formatting

The new block conditionally renders an info label when appName equals AppName.QBD_DIRECT and isExportInProgress is true. Please ensure that both appName and AppName are properly defined and imported in the corresponding component's TypeScript file to avoid runtime issues. Additionally, the infoText attribute contains escaped smart quotes (\‘Update Selected\’), which may not render as intended in all browsers. Consider using standard single quotes or proper HTML entities for consistency.

Suggested diff for clarity in the text formatting:

- [infoText]="'Click \‘Update Selected\’ in QuickBooks Web Connector after exporting to sync your expenses immediately'">
+ [infoText]="'Click \'Update Selected\' in QuickBooks Web Connector after exporting to sync your expenses immediately'">

This adjustment improves clarity and avoids potential issues with escape characters in Angular templates.

✅ Verification successful

Error: No shell scripts or web queries found


I'll start by gathering information with a shell script that checks the TypeScript file for the definitions of appName, isExportInProgress, and AppName, and also examines the HTML file for any occurrences of the escaped smart quotes (\‘). This will help us confirm both that the component is set up correctly and that the text formatting issue is present.

Please see the script below:

Once this script runs and returns its output, we can verify:

  • That appName and AppName (as well as isExportInProgress) are correctly defined/imported in the corresponding TypeScript file.
  • That the HTML file contains the escaped smart quotes as mentioned, confirming the need to change them to standard ones as suggested.

Based on the results, we can then decide whether any adjustments are required beyond the recommended diff.


🏁 Script executed:

#!/bin/bash
# Check if the TypeScript file exists and search for key identifiers
FILE="src/app/shared/components/dashboard/dashboard-export-section/dashboard-export-section.component.ts"
echo "=== Checking $FILE for required definitions ==="
if [ -f "$FILE" ]; then
  echo "File found: $FILE"
  echo "----- Occurrences of 'appName' -----"
  grep -H "appName" "$FILE"
  echo "----- Occurrences of 'isExportInProgress' -----"
  grep -H "isExportInProgress" "$FILE"
  echo "----- Occurrences of 'AppName' -----"
  grep -H "AppName" "$FILE"
else
  echo "File not found: $FILE"
fi

# Check the HTML file for escaped smart quotes
HTML_FILE="src/app/shared/components/dashboard/dashboard-export-section/dashboard-export-section.component.html"
echo "=== Checking $HTML_FILE for escaped smart quotes -----"
if [ -f "$HTML_FILE" ]; then
  grep -H "\\" "$HTML_FILE" || echo "No occurrences of escaped smart quotes found."
else
  echo "File not found: $HTML_FILE"
fi

Length of output: 4428


Conditional Rendering & Smart Quote Correction

Both the appName and isExportInProgress inputs, along with the AppName enum, are correctly defined and imported in the component’s TypeScript file. However, the HTML file still contains escaped smart quotes in the infoText attribute, which may lead to inconsistent rendering. Please update the escaped smart quotes according to the suggested diff:

- [infoText]="'Click \‘Update Selected\’ in QuickBooks Web Connector after exporting to sync your expenses immediately'">
+ [infoText]="'Click \'Update Selected\' in QuickBooks Web Connector after exporting to sync your expenses immediately'">

@DhaaraniCIT DhaaraniCIT added the deploy Triggers deployment of active branch to Staging label Feb 5, 2025
@DhaaraniCIT
Copy link
Contributor Author

Screenshot 2025-02-05 at 2 52 53 PM

Copy link

github-actions bot commented Feb 5, 2025

Unit Test Coverage % values
Statements 33.01% ( 4132 / 12515 )
Branches 26.36% ( 1173 / 4449 )
Functions 25.59% ( 893 / 3489 )
Lines 33.2% ( 4066 / 12246 )

@DhaaraniCIT DhaaraniCIT merged commit 8d5a7f2 into master Feb 5, 2025
5 checks passed
DhaaraniCIT added a commit that referenced this pull request Feb 5, 2025
* qbd direct servey and info box in dashboard

* adding padding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy Triggers deployment of active branch to Staging size/XS Extra Small PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants