Skip to content

Conversation

@omkarK06
Copy link
Contributor

@omkarK06 omkarK06 commented Sep 6, 2024

fix #4346

Summary by CodeRabbit

  • New Features

    • Introduced a toggle feature for managing cached reports in the report creation process.
    • Added a new component for displaying and managing scheduled dashboard reports.
    • Implemented a dropdown button for accessing scheduled reports in the dashboard view.
  • Bug Fixes

    • Minor formatting adjustments to improve code readability in various components.
  • Documentation

    • Enhanced localization support with new key-value pairs for report management terms.

@omkarK06 omkarK06 changed the title feat: Scheduled Reports UI feat: Scheduled Dashboards UI Sep 6, 2024
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 6, 2024

Walkthrough

The changes introduce a new feature for managing scheduled dashboard reports, enhancing user interaction with the dashboard. Key updates include a toggle for cached reports, a new component for displaying scheduled reports, and modifications to existing components to support this functionality. Additionally, localization updates and interface definitions have been added to support the new features.

Changes

Files Change Summary
web/src/components/reports/CreateReport.vue Added a toggle for cached reports, modified control flow to conditionally render elements based on the toggle state, and introduced a new function to initialize report data.
web/src/locales/languages/en.json Added new key-value pairs for localization related to reporting and scheduling functionalities.
web/src/services/reports.ts Expanded the list function to include new parameters for folder and dashboard filtering, enhancing API request specificity.
web/src/ts/interfaces/dashboard.ts Introduced a new interface for ScheduledDashboardReport defining its structure and properties.
web/src/views/Dashboards/ScheduledDashboards.vue Implemented a new component for managing scheduled reports with features for filtering and pagination.
web/src/views/Dashboards/ViewDashboard.vue Added a dropdown button for accessing scheduled reports, introduced a dialog for displaying reports, and implemented reactive state management for loading and displaying reports.

Assessment against linked issues

Objective Addressed Explanation
Provide a button in the dashboard to show scheduled reports (#[4346])
Open a side panel with all reports for that dashboard (#[4346])
List reports with cache destination only (#[4346])
Navigate to add report page with pre-filled options (#[4346]) The implementation does not include navigation to add report page.

Suggested labels

🧹 Updates

Tip

New features

Walkthrough comment now includes:

  • Possibly related PRs: A list of potentially related PRs to help you recall past context.
  • Suggested labels: CodeRabbit can now suggest labels by learning from your past PRs. You can also provide custom labeling instructions in the UI or configuration file.

Notes:

  • Please share any feedback in the discussion post on our Discord.
  • Possibly related PRs, automatic label suggestions based on past PRs, learnings, and possibly related issues require data opt-in (enabled by default).

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5630650 and 27b32db.

Files selected for processing (15)
  • web/src/components/alerts/AlertList.vue (1 hunks)
  • web/src/components/reports/CreateReport.vue (8 hunks)
  • web/src/components/reports/ReportList.vue (5 hunks)
  • web/src/locales/languages/en.json (2 hunks)
  • web/src/services/reports.ts (1 hunks)
  • web/src/ts/interfaces/alert.ts (1 hunks)
  • web/src/ts/interfaces/dashboard.ts (1 hunks)
  • web/src/ts/interfaces/global.ts (1 hunks)
  • web/src/ts/interfaces/iam.ts (1 hunks)
  • web/src/ts/interfaces/index.ts (1 hunks)
  • web/src/ts/interfaces/ingestion.ts (1 hunks)
  • web/src/ts/interfaces/query.ts (1 hunks)
  • web/src/utils/date.ts (2 hunks)
  • web/src/views/Dashboards/ScheduledDashboards.vue (1 hunks)
  • web/src/views/Dashboards/ViewDashboard.vue (17 hunks)
Files skipped from review due to trivial changes (8)
  • web/src/components/alerts/AlertList.vue
  • web/src/components/reports/ReportList.vue
  • web/src/ts/interfaces/alert.ts
  • web/src/ts/interfaces/global.ts
  • web/src/ts/interfaces/iam.ts
  • web/src/ts/interfaces/index.ts
  • web/src/ts/interfaces/ingestion.ts
  • web/src/ts/interfaces/query.ts
Additional comments not posted (17)
web/src/ts/interfaces/dashboard.ts (1)

16-26: Interface Definition for ScheduledDashboardReport

The interface ScheduledDashboardReport is well-defined and aligns with the PR objectives for managing scheduled reports. The properties cover essential aspects like scheduling frequency, last trigger time, and caching status.

Consider verifying the type consistency for orgId. It is defined as string | number, which might lead to inconsistencies depending on how organization identifiers are handled elsewhere in the application.

web/src/utils/date.ts (1)

243-249: New Function: convertUnixToQuasarFormat

The function convertUnixToQuasarFormat is a valuable addition for converting Unix timestamps (in microseconds) to a formatted date string. The implementation is clear, and it correctly handles the conversion process, enhancing the module's functionality for date formatting.

The function is well-implemented and aligns with the needs of the application for handling date and time conversions.

web/src/views/Dashboards/ScheduledDashboards.vue (2)

17-95: Review of Vue Template in ScheduledDashboards.vue

The template section is well-structured and makes good use of Quasar components for a consistent UI experience. Here are some observations and suggestions:

  1. Localization and Text Management: The use of the t method for text ensures that the component can support internationalization. This is a good practice and should be maintained.
  2. Data Binding: The :rows="scheduledReports" and :columns="columns" bindings in the q-table are correctly set up to display dynamic data.
  3. Event Handling: The @click="createNewReport" on the q-btn and @row-click="openReport" on the q-table are appropriate for user interactions. Ensure that these methods (createNewReport and openReport) handle errors gracefully and provide feedback to the user.
  4. Accessibility: Consider adding aria-labels to interactive elements for better accessibility.

Overall, the template follows good practices in Vue.js and Quasar framework usage.


282-307: Review of Style Section in ScheduledDashboards.vue

The SCSS styles are scoped to the component, which is good practice to avoid styling conflicts with other parts of the application. Here are some points to consider:

  1. Consistency: The styles use consistent naming conventions and SCSS features like variables and nesting. This makes the code easier to read and maintain.
  2. Responsiveness: Ensure that the styles handle different screen sizes and devices. If the application is meant to be responsive, consider using media queries or responsive units.
  3. Accessibility: Check if the color contrasts meet accessibility standards, especially for text and interactive elements.

Overall, the styling is well-implemented and follows good practices in modern CSS development.

web/src/components/reports/CreateReport.vue (7)

106-127: Add a toggle for cached reports with an informational tooltip.

The addition of a q-toggle component linked to the isCachedReport state variable allows users to enable or disable cached reports. This is a crucial feature for managing the caching behavior of reports. The accompanying tooltip provides necessary information about the implications of using cached reports, specifically that sharing is disabled for these reports. This is a good implementation as it enhances user understanding and control over report settings.


630-630: Conditional rendering based on cached report status.

The navigation button to continue to the next step is conditionally rendered based on the isCachedReport state. This ensures that users do not proceed with irrelevant options when cached reports are active. It's a good practice to conditionally render UI elements based on the state to prevent user errors and enhance the UI's responsiveness to user settings.


650-650: Conditional rendering of the share step.

The share step is also conditionally rendered based on the isCachedReport state. This is consistent with the toggle's functionality, ensuring that sharing options are only available when the report is not cached. This consistency in UI behavior is crucial for maintaining a predictable and user-friendly interface.


856-859: Initialization of reactive state variables for cached reports and tooltips.

The state variables isCachedReport and showInfoTooltip are initialized with ref(false), making them reactive. This is necessary for Vue 3 composition API to ensure that changes to these variables trigger UI updates. Proper use of reactive state management is key to building dynamic and responsive interfaces.


1005-1026: Function to set initial report data based on query parameters.

The setInitialReportData function is well-implemented to handle various query parameters that configure the report settings upon loading. This includes setting the report type as cached, selecting folders, dashboards, and tabs based on the provided IDs. This function is crucial for initializing the form with pre-filled values, reducing the effort required by the user to set up a report, and potentially reducing errors.


1296-1297: Handling of destinations based on cached report status.

When a report is marked as cached, the destinations array is cleared. This aligns with the functionality that disables sharing for cached reports. It's a good practice to enforce such business rules at the data model level to ensure consistency and prevent the application state from entering invalid configurations.


1493-1494: Adjust cached report status based on the presence of destinations.

This code segment adjusts the isCachedReport state based on whether there are any destinations set for the report. If there are no destinations, the report is considered cached. This is a sensible fallback mechanism to ensure the report's configuration is consistent with its intended use, especially in scenarios where the report might be edited and destinations are removed.

web/src/views/Dashboards/ViewDashboard.vue (4)

169-186: Addition of Dropdown Button for Scheduled Reports

The addition of a <q-btn-dropdown> for accessing scheduled reports is well-implemented. It enhances the dashboard's functionality by providing a user-friendly interface to manage scheduled reports. The openScheduledReports method is correctly bound to the click event, which should trigger the display of the scheduled reports dialog.


218-231: Scheduled Reports Dialog Implementation

The <q-dialog> component for displaying scheduled reports is correctly implemented. It uses the showScheduledReportsDialog reactive reference for visibility control, which is a standard practice in Vue.js. The passing of props such as reports, loading, folderId, dashboardId, and tabId to the ScheduledDashboards component is done correctly, ensuring that all necessary data is available for the component to function properly.


265-266: Import and Registration of ScheduledDashboards Component

The import and registration of the ScheduledDashboards component are correctly handled. This component is crucial for displaying the scheduled reports, and its registration in the components object of the Vue instance ensures it can be used in the template.

Also applies to: 283-283


Line range hint 294-312: Reactive References and Computed Properties for Dashboard Context

The setup of reactive references like showScheduledReportsDialog and computed properties for dashboardId, folderId, and tabId are appropriate. These are used to manage the state and context of the dashboard, which is essential for the functionality of scheduled reports.

web/src/locales/languages/en.json (2)

649-651: Addition of Localization Entries for Scheduled Reports

The new localization entries for "scheduledReports", "newReport", and "scheduledDashboards" are correctly added. These entries are essential for supporting multiple languages and enhancing the user interface's accessibility.


902-910: Localization Entries for Report Attributes

The addition of localization entries for various report attributes like "timeRange", "frequency", "lastTriggeredAt", "createdAt", "tab", "cached", "cachedReport", "destination", and "scheduled" is correctly implemented. These entries will help in displaying these attributes in the user interface, making it more user-friendly and accessible.

@omkarK06 omkarK06 force-pushed the feat/scheduled_dashboards branch 2 times, most recently from 074feb3 to 7b04a13 Compare September 9, 2024 04:48
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 27b32db and 7b04a13.

Files selected for processing (16)
  • web/src/components/alerts/AlertList.vue (1 hunks)
  • web/src/components/reports/CreateReport.vue (8 hunks)
  • web/src/components/reports/ReportList.vue (5 hunks)
  • web/src/locales/languages/en.json (2 hunks)
  • web/src/services/reports.ts (1 hunks)
  • web/src/ts/interfaces/alert.ts (1 hunks)
  • web/src/ts/interfaces/dashboard.ts (1 hunks)
  • web/src/ts/interfaces/global.ts (1 hunks)
  • web/src/ts/interfaces/iam.ts (1 hunks)
  • web/src/ts/interfaces/index.ts (1 hunks)
  • web/src/ts/interfaces/ingestion.ts (1 hunks)
  • web/src/ts/interfaces/query.ts (1 hunks)
  • web/src/utils/date.ts (2 hunks)
  • web/src/views/Dashboards/Dashboards.vue (14 hunks)
  • web/src/views/Dashboards/ScheduledDashboards.vue (1 hunks)
  • web/src/views/Dashboards/ViewDashboard.vue (10 hunks)
Files skipped from review due to trivial changes (9)
  • web/src/components/alerts/AlertList.vue
  • web/src/components/reports/ReportList.vue
  • web/src/locales/languages/en.json
  • web/src/ts/interfaces/alert.ts
  • web/src/ts/interfaces/global.ts
  • web/src/ts/interfaces/index.ts
  • web/src/ts/interfaces/ingestion.ts
  • web/src/ts/interfaces/query.ts
  • web/src/views/Dashboards/Dashboards.vue
Files skipped from review as they are similar to previous changes (6)
  • web/src/components/reports/CreateReport.vue
  • web/src/services/reports.ts
  • web/src/ts/interfaces/dashboard.ts
  • web/src/ts/interfaces/iam.ts
  • web/src/utils/date.ts
  • web/src/views/Dashboards/ScheduledDashboards.vue
Additional comments not posted (3)
web/src/views/Dashboards/ViewDashboard.vue (3)

214-227: Dialog Component for Displaying Scheduled Reports

The <q-dialog> component setup for displaying scheduled reports is correctly implemented. The use of reactive properties like showScheduledReportsDialog to control the visibility of the dialog is a standard Vue practice. Passing necessary props such as reports, loading, folderId, dashboardId, and tabId ensures that the ScheduledDashboards component has all the required data to function correctly.

This implementation aligns well with the PR's objectives to enhance dashboard interactivity and manage scheduled reports effectively.


751-782: Method to Open Scheduled Reports and Fetch Data

The openScheduledReports method is well-structured. It handles the opening of the dialog, resetting the scheduledReports array, and setting the loading state. The use of the reports service to fetch scheduled reports is appropriate. However, ensure that error handling is implemented to manage potential failures in the reports service call.

Consider adding error handling for the reports service call to improve robustness. For example:

reports
  .list(store.state.selectedOrganization.identifier, currentDashboardData.data?.folderId, currentDashboardData.data?.dashboardId)
  .then((response) => {
    response.data.forEach((report, index) => {
      scheduledReports.push({
        "#": index + 1,
        name: report.name,
        tab: report.dashboards?.[0]?.tabs?.[0],
        time_range: getTimeRangeValue(report.dashboards?.[0]?.timerange),
        frequency: getFrequencyValue(report.frequency),
        last_triggered_at: convertUnixToQuasarFormat(report.lastTriggeredAt),
        created_at: convertUnixToQuasarFormat(new Date(report.createdAt).getTime() * 1000),
        orgId: report.orgId,
        isCached: !report.destinations.length,
      });
    });
  })
  .catch((error) => {
    showErrorNotification(error.message || "Failed to fetch reports");
    isLoadingReports.value = false;
  })
  .finally(() => {
    isLoadingReports.value = false;
  });

169-180: Addition of Button for Scheduled Reports

The addition of a <q-btn> component to trigger the openScheduledReports method is well-implemented. The button is correctly configured with accessibility and test attributes (data-test). The tooltip is also a nice touch for enhancing user experience.

However, ensure that the icon used (outlinedDescription) is appropriately defined and accessible. It might be beneficial to verify that this icon is correctly rendered and accessible to all users.

Verification successful

Icon outlinedDescription is Defined and Accessible

The outlinedDescription icon is correctly imported from @quasar/extras/material-icons-outlined and used within the ViewDashboard.vue component. This confirms that the icon is defined and accessible, aligning with the Quasar framework's standard practices. No further action is required regarding the icon's definition or accessibility.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify that the icon `outlinedDescription` is defined and accessible
grep -r "outlinedDescription" ./web/src

Length of output: 445

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7b04a13 and ddf4d2d.

Files selected for processing (3)
  • web/src/services/reports.ts (1 hunks)
  • web/src/views/Dashboards/ScheduledDashboards.vue (1 hunks)
  • web/src/views/Dashboards/ViewDashboard.vue (9 hunks)
Files skipped from review as they are similar to previous changes (2)
  • web/src/services/reports.ts
  • web/src/views/Dashboards/ScheduledDashboards.vue
Additional comments not posted (5)
web/src/views/Dashboards/ViewDashboard.vue (5)

169-180: Addition of Button for Scheduled Reports

The addition of the <q-btn> component to trigger the openScheduledReports method is well-implemented. The button is correctly placed within the UI and uses the outlinedDescription for its icon, which should be verified to ensure it represents the functionality accurately. The tooltip provides additional context, which enhances user experience.


214-227: Dialog Component for Displaying Scheduled Reports

The <q-dialog> component setup for displaying scheduled reports is correctly implemented. It uses the showScheduledReportsDialog reactive reference for its visibility control, which is standard practice in Vue.js. The passing of necessary props such as reports, loading, folderId, dashboardId, and tabId to the ScheduledDashboards component is done properly, ensuring that all required data is available for the component to function correctly.


Line range hint 261-279: Import and Registration of ScheduledDashboards Component

The import and registration of the ScheduledDashboards component are correctly handled. This is crucial for the component's functionality within this file. The addition of this component enhances the modular architecture of the application by separating concerns and allowing for better maintainability.


Line range hint 290-308: Reactive References for Dialog and Scheduled Reports

The setup of reactive references such as showScheduledReportsDialog, scheduledReports, isLoadingReports, dashboardId, folderId, and tabId is appropriate. These references are essential for managing the state and interactions of the scheduled reports feature. It's important to ensure that these references are used consistently throughout the component to manage state effectively.


750-769: Method to Open Scheduled Reports and Fetch Data

The openScheduledReports method is well-structured. It handles the opening of the dialog, resetting the scheduledReports array, and setting the loading state. The use of the reports service to fetch scheduled reports is appropriate. However, ensure that error handling is implemented to manage potential failures in the reports service call.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ddf4d2d and cca4ccb.

Files selected for processing (1)
  • web/src/views/Dashboards/ScheduledDashboards.vue (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • web/src/views/Dashboards/ScheduledDashboards.vue

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between cca4ccb and 746ad2b.

Files selected for processing (3)
  • web/src/views/Dashboards/Dashboards.vue (14 hunks)
  • web/src/views/Dashboards/ScheduledDashboards.vue (1 hunks)
  • web/src/views/Dashboards/ViewDashboard.vue (8 hunks)
Files skipped from review due to trivial changes (2)
  • web/src/views/Dashboards/Dashboards.vue
  • web/src/views/Dashboards/ScheduledDashboards.vue
Additional comments not posted (5)
web/src/views/Dashboards/ViewDashboard.vue (5)

169-180: Addition of Button for Scheduled Reports

The addition of the <q-btn> component to trigger the openScheduledReports method is aligned with the PR objectives to enhance dashboard functionality by allowing users to manage scheduled reports. The use of Quasar components for UI consistency is noted, and the tooltip provides a good user experience by explaining the button's purpose.


214-227: Introduction of Dialog for Scheduled Reports

The new <q-dialog> component for displaying scheduled reports is a crucial part of the feature, allowing users to interact with the reports linked to the dashboard. The binding to showScheduledReportsDialog ensures that the dialog's visibility is controlled programmatically. Passing necessary props such as reports, loading, folderId, dashboardId, and tabId to the ScheduledDashboards component is well-handled, ensuring that all relevant data is available for display and interaction within the component.


Line range hint 261-279: Component and Service Imports

The import of ScheduledDashboards and reports services is necessary for the functionality of displaying and fetching scheduled reports. The organization of imports and the addition of the ScheduledDashboards component to the local components registry are correctly implemented. This setup facilitates the use of the ScheduledDashboards component within this file, supporting the new feature's requirements.


Line range hint 290-308: Reactive References and Computed Properties for Scheduled Reports

The setup of reactive references like showScheduledReportsDialog, scheduledReports, and isLoadingReports, along with computed properties for dashboardId, folderId, and tabId, is well done. These reactive states and computed properties are essential for managing the UI state and data flow concerning the scheduled reports feature. It ensures that the component reacts appropriately to changes and provides a dynamic user experience.


750-769: Method to Open Scheduled Reports and Fetch Data

The openScheduledReports method is well-structured. It handles the opening of the dialog, resetting the scheduledReports array, and setting the loading state. The use of the reports service to fetch scheduled reports is appropriate. However, ensure that error handling is implemented to manage potential failures in the reports service call.

Consider adding error handling for the reports service call to improve robustness. For example:

reports
  .list(store.state.selectedOrganization.identifier, currentDashboardData.data?.folderId, currentDashboardData.data?.dashboardId)
  .then((response) => {
    response.data.forEach((report, index) => {
      scheduledReports.push({
        "#": index + 1,
        name: report.name,
        tab: report.dashboards?.[0]?.tabs?.[0],
        time_range: getTimeRangeValue(report.dashboards?.[0]?.timerange),
        frequency: getFrequencyValue(report.frequency),
        last_triggered_at: convertUnixToQuasarFormat(report.lastTriggeredAt),
        created_at: convertUnixToQuasarFormat(new Date(report.createdAt).getTime() * 1000),
        orgId: report.orgId,
        isCached: !report.destinations.length,
      });
    });
  })
  .catch((error) => {
    showErrorNotification(error.message || "Failed to fetch reports");
    isLoadingReports.value = false;
  })
  .finally(() => {
    isLoadingReports.value = false;
  });

@omkarK06 omkarK06 force-pushed the feat/scheduled_dashboards branch from 746ad2b to 6daac01 Compare September 9, 2024 10:01
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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 746ad2b and 6daac01.

Files selected for processing (16)
  • web/src/components/alerts/AlertList.vue (1 hunks)
  • web/src/components/reports/CreateReport.vue (8 hunks)
  • web/src/components/reports/ReportList.vue (5 hunks)
  • web/src/locales/languages/en.json (2 hunks)
  • web/src/services/reports.ts (1 hunks)
  • web/src/ts/interfaces/alert.ts (1 hunks)
  • web/src/ts/interfaces/dashboard.ts (1 hunks)
  • web/src/ts/interfaces/global.ts (1 hunks)
  • web/src/ts/interfaces/iam.ts (1 hunks)
  • web/src/ts/interfaces/index.ts (1 hunks)
  • web/src/ts/interfaces/ingestion.ts (1 hunks)
  • web/src/ts/interfaces/query.ts (1 hunks)
  • web/src/utils/date.ts (2 hunks)
  • web/src/views/Dashboards/Dashboards.vue (14 hunks)
  • web/src/views/Dashboards/ScheduledDashboards.vue (1 hunks)
  • web/src/views/Dashboards/ViewDashboard.vue (8 hunks)
Files skipped from review due to trivial changes (8)
  • web/src/components/alerts/AlertList.vue
  • web/src/components/reports/ReportList.vue
  • web/src/ts/interfaces/global.ts
  • web/src/ts/interfaces/iam.ts
  • web/src/ts/interfaces/index.ts
  • web/src/ts/interfaces/ingestion.ts
  • web/src/ts/interfaces/query.ts
  • web/src/views/Dashboards/Dashboards.vue
Files skipped from review as they are similar to previous changes (7)
  • web/src/components/reports/CreateReport.vue
  • web/src/locales/languages/en.json
  • web/src/services/reports.ts
  • web/src/ts/interfaces/alert.ts
  • web/src/ts/interfaces/dashboard.ts
  • web/src/views/Dashboards/ScheduledDashboards.vue
  • web/src/views/Dashboards/ViewDashboard.vue
Additional comments not posted (1)
web/src/utils/date.ts (1)

218-218: Approved minor style improvement.

The addition of the trailing comma in getConsumableRelativeTime aligns with modern JavaScript practices and improves code consistency.

Comment on lines +243 to +249
export const convertUnixToQuasarFormat = (unixMicroseconds: any) => {
if (!unixMicroseconds) return "";
const unixSeconds = unixMicroseconds / 1e6;
const dateToFormat = new Date(unixSeconds * 1000);
const formattedDate = dateToFormat.toISOString();
return date.formatDate(formattedDate, "YYYY-MM-DDTHH:mm:ssZ");
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Enhance type safety and error handling in convertUnixToQuasarFormat.

The function convertUnixToQuasarFormat correctly converts Unix time in microseconds to a formatted date string. However, it lacks robust type checking and error handling for non-numeric inputs. Consider enhancing the function by explicitly checking the type of unixMicroseconds and handling potential errors during date conversion.

Here's a suggested improvement:

-export const convertUnixToQuasarFormat = (unixMicroseconds: any) => {
+export const convertUnixToQuasarFormat = (unixMicroseconds: number) => {
  if (typeof unixMicroseconds !== 'number' || !unixMicroseconds) return "";
  const unixSeconds = unixMicroseconds / 1e6;
  const dateToFormat = new Date(unixSeconds * 1000);
  if (isNaN(dateToFormat.getTime())) return "";
  const formattedDate = dateToFormat.toISOString();
  return date.formatDate(formattedDate, "YYYY-MM-DDTHH:mm:ssZ");
};
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const convertUnixToQuasarFormat = (unixMicroseconds: any) => {
if (!unixMicroseconds) return "";
const unixSeconds = unixMicroseconds / 1e6;
const dateToFormat = new Date(unixSeconds * 1000);
const formattedDate = dateToFormat.toISOString();
return date.formatDate(formattedDate, "YYYY-MM-DDTHH:mm:ssZ");
};
export const convertUnixToQuasarFormat = (unixMicroseconds: number) => {
if (typeof unixMicroseconds !== 'number' || !unixMicroseconds) return "";
const unixSeconds = unixMicroseconds / 1e6;
const dateToFormat = new Date(unixSeconds * 1000);
if (isNaN(dateToFormat.getTime())) return "";
const formattedDate = dateToFormat.toISOString();
return date.formatDate(formattedDate, "YYYY-MM-DDTHH:mm:ssZ");
};

@omkarK06 omkarK06 merged commit 1e7ba3e into main Sep 9, 2024
@omkarK06 omkarK06 deleted the feat/scheduled_dashboards branch September 9, 2024 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scheduled Dashboards for caching purpose

3 participants