Skip to content

feat: revenue graph#25

Merged
hmbanan666 merged 2 commits into
mainfrom
graph
Jul 29, 2025
Merged

feat: revenue graph#25
hmbanan666 merged 2 commits into
mainfrom
graph

Conversation

@hmbanan666
Copy link
Copy Markdown
Collaborator

@hmbanan666 hmbanan666 commented Jul 29, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a new interactive chart to visualize kitchen revenue over selectable periods (daily, weekly, monthly) and date ranges.
    • The chart displays total revenue, number of checks, and supports responsive design with localized Russian formatting.
  • Enhancements

    • Updated the kitchen finance page to show revenue data using the new chart component instead of plain data.
  • Other Changes

    • Added new period and date range selection types for improved data filtering.
    • Integrated visualization libraries to support advanced charting features.

@hmbanan666 hmbanan666 self-assigned this Jul 29, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jul 29, 2025

Walkthrough

A new kitchen revenue chart component was added to the web app, using the Unovis visualization library. The kitchen finance page was updated to use this chart, with new types for period and date range introduced. Dependencies for Unovis were added to the UI package and workspace configuration.

Changes

Cohort / File(s) Change Summary
Kitchen Revenue Chart Component
apps/web-app/app/components/chart/KitchenRevenue.client.vue
Introduced a Vue 3 component to display kitchen revenue as a chart, with Russian localization, responsive layout, and dynamic data normalization.
Kitchen Finance Page Integration
apps/web-app/app/pages/kitchen/[id]/finance.vue
Updated to use the new chart component, added reactive period and range state, and connected fetched data to the chart.
Shared Types
apps/web-app/shared/types/index.ts
Added Period union type and Range interface for date intervals.
UI Package Dependencies
packages/ui/package.json
Added @unovis/ts and @unovis/vue as dependencies.
Workspace Dependencies
pnpm-workspace.yaml
Registered @unovis/ts and @unovis/vue in the workspace catalog.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant KitchenFinancePage
    participant ChartKitchenRevenue
    participant DataSource

    User->>KitchenFinancePage: Visits kitchen finance page
    KitchenFinancePage->>DataSource: Fetch revenue data
    DataSource-->>KitchenFinancePage: Return revenue data
    KitchenFinancePage->>ChartKitchenRevenue: Pass period, range, values props
    ChartKitchenRevenue->>ChartKitchenRevenue: Normalize and compute chart data
    ChartKitchenRevenue-->>User: Render chart with revenue and checks
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Poem

In the kitchen’s digital den,
A chart now shines for every yen.
With lines and areas, numbers bloom,
Russian dates and checks resume.
New types and tools join the stew—
A tasty upgrade, fresh and new!
🥕📊


📜 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 db52d5c and dd05c8a.

📒 Files selected for processing (1)
  • apps/web-app/app/components/chart/KitchenRevenue.client.vue (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web-app/app/components/chart/KitchenRevenue.client.vue
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch graph

🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this 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.

@socket-security
Copy link
Copy Markdown

socket-security Bot commented Jul 29, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​unovis/​vue@​1.5.2981009095100
Added@​unovis/​ts@​1.5.2981009597100

View full report

Copy link
Copy Markdown

@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)
apps/web-app/app/components/chart/KitchenRevenue.client.vue (2)

72-88: Consider optimizing the date comparison logic.

The current date comparison logic compares year, month, and date separately, which could have timezone issues and is inefficient for large datasets.

Consider this optimization using date string comparison:

-const value = values.find((d) => new Date(d.date).getFullYear() === date.getFullYear() && new Date(d.date).getMonth() === date.getMonth() && new Date(d.date).getDate() === date.getDate())
+const dateStr = format(date, 'yyyy-MM-dd')
+const value = values.find((d) => d.date.startsWith(dateStr))

Alternatively, create a Map for O(1) lookups:

+const valuesByDate = new Map(values.map(v => [v.date.split('T')[0], v]))
+
 data.value = dates.map((date) => {
-  const value = values.find((d) => new Date(d.date).getFullYear() === date.getFullYear() && new Date(d.date).getMonth() === date.getMonth() && new Date(d.date).getDate() === date.getDate())
+  const dateStr = format(date, 'yyyy-MM-dd')
+  const value = valuesByDate.get(dateStr)

84-85: Simplify the conditional assignment.

The conditional checks can be simplified using nullish coalescing.

-total: value?.total ? value.total : 0,
-checks: value?.checks ? value.checks : 0,
+total: value?.total ?? 0,
+checks: value?.checks ?? 0,
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2378644 and db52d5c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • apps/web-app/app/components/chart/KitchenRevenue.client.vue (1 hunks)
  • apps/web-app/app/pages/kitchen/[id]/finance.vue (1 hunks)
  • apps/web-app/shared/types/index.ts (1 hunks)
  • packages/ui/package.json (1 hunks)
  • pnpm-workspace.yaml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (12)
pnpm-workspace.yaml (1)

29-30: LGTM! Clean dependency additions for visualization library.

The Unovis visualization library dependencies are properly added to the catalog with appropriate version constraints.

packages/ui/package.json (1)

14-15: LGTM! Proper dependency management using workspace catalog.

The Unovis dependencies are correctly added to the runtime dependencies section with proper catalog references.

apps/web-app/shared/types/index.ts (1)

48-53: LGTM! Well-defined types for date range functionality.

The Period union type and Range interface provide clear type safety for date-based chart filtering and display operations.

apps/web-app/app/pages/kitchen/[id]/finance.vue (3)

3-7: LGTM! Clean integration of the chart component.

The template correctly passes the required props to the chart component with proper fallback for the values prop.


12-13: LGTM! Proper imports and dependencies.

The type imports and date-fns import are correctly structured for the component's needs.


19-23: LGTM! Sensible default values for date range and period.

The 14-day default range and 'daily' period provide a good starting point for users. Using shallowRef for the range object is appropriate.

apps/web-app/app/components/chart/KitchenRevenue.client.vue (6)

1-12: LGTM! Clean card layout with proper header information.

The header effectively displays the total revenue and period description with proper localization and formatting.


14-45: LGTM! Comprehensive chart setup with good visual elements.

The chart configuration includes all necessary components (line, area, axis, crosshair, tooltip) with proper theming using CSS variables.


48-64: LGTM! Well-structured component props and imports.

The props are properly typed using the shared types, and all necessary Unovis and date-fns imports are included.


90-113: LGTM! Well-implemented chart accessors and formatting functions.

The x/y accessors, total calculation, number formatting, and date formatting functions are all properly implemented with good localization support.


116-129: LGTM! Comprehensive CSS variable theming.

The scoped styles properly integrate with the UI theme system using CSS variables for consistent visual appearance.


113-113: KitchenRevenue.client.vue tooltip interpolation is safe

The template function only formats and concatenates a date (d.date), numeric totals (d.total), and a count (d.checks) via formatDate, formatNumber, and pluralizationRu. None of these functions render HTML or inject untrusted markup—they return plain text for chart tooltips. Since the fields are strictly Date/number types and not user-entered HTML, there’s no XSS vector here. You can safely ignore the sanitization recommendation for this component.

Likely an incorrect or invalid review comment.

@sonarqubecloud
Copy link
Copy Markdown

@hmbanan666 hmbanan666 merged commit cd17718 into main Jul 29, 2025
7 of 8 checks passed
@hmbanan666 hmbanan666 deleted the graph branch July 29, 2025 10:33
@coderabbitai coderabbitai Bot mentioned this pull request Jul 30, 2025
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.

1 participant