Skip to content

feat(api-service): enhance platform notification usage with clickhouse support#9849

Merged
djabarovgeorge merged 6 commits intonextfrom
refactor-platform-usage-request
Jan 19, 2026
Merged

feat(api-service): enhance platform notification usage with clickhouse support#9849
djabarovgeorge merged 6 commits intonextfrom
refactor-platform-usage-request

Conversation

@djabarovgeorge
Copy link
Contributor

What changed? Why was the change needed?

EE-PR

Screenshots

Expand for optional sections

Related enterprise PR

Special notes for your reviewer

@netlify
Copy link

netlify bot commented Jan 18, 2026

Deploy Preview for dashboard-v2-novu-staging canceled.

Name Link
🔨 Latest commit fc3ece3
🔍 Latest deploy log https://app.netlify.com/projects/dashboard-v2-novu-staging/deploys/696e0be8701e8f000869a3f1

@github-actions
Copy link
Contributor

github-actions bot commented Jan 18, 2026

Hey there and thank you for opening this pull request! 👋

We require pull request titles to follow specific formatting rules and it looks like your proposed title needs to be adjusted.

Your PR title is: feat(api-service): enhance platform notification usage with clickhouse support

Requirements:

  1. Follow the Conventional Commits specification
  2. As a team member, include Linear ticket ID at the end: fixes TICKET-ID or include it in your branch name

Expected format: feat(scope): Add fancy new feature fixes NOV-123

Details:

PR title must end with 'fixes TICKET-ID' (e.g., 'fixes NOV-123') or include ticket ID in branch name

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 18, 2026

Walkthrough

Subproject commit reference updated from e38b53ee33bda663c1948ad3a8271c1f91c140b6 to 0f71416217e50b7a0343b980e458a96df149b93b. Added WorkflowRunRepository method getPlatformUsageByDateRange(startDate, endDate, organizationId?) that queries ClickHouse for counts per organization in a date range. Added feature-flag enum members IS_BILLING_USAGE_CLICKHOUSE_ENABLED and IS_BILLING_USAGE_CLICKHOUSE_SHADOW_ENABLED. Updated an E2E test to inject mocks for the new repository method and feature-flag service, adjusting the GetPlatformNotificationUsage constructor signature.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(api-service): enhance platform notification usage with clickhouse support' directly and clearly describes the main change: adding ClickHouse support to platform notification usage.
Description check ✅ Passed The description references a related enterprise PR and provides context for the change, though minimal details are given. It is related to the changeset as it discusses enhancements to platform notification usage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 19, 2026

Open in StackBlitz

npm i https://pkg.pr.new/novuhq/novu@9849
npm i https://pkg.pr.new/novuhq/novu/@novu/providers@9849
npm i https://pkg.pr.new/novuhq/novu/@novu/shared@9849

commit: fc3ece3

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/api/src/app/billing/e2e/get-platform-notification-usage.e2e-ee.ts (1)

49-149: Add test case for ClickHouse path when feature flag is enabled.

The feature flag mock is hardcoded to false (lines 25, 46), meaning workflowRunRepository.getPlatformUsageByDateRange is never invoked. Add at least one test that sets getFlag to true to verify the ClickHouse-based behavior is exercised:

it('should use ClickHouse when feature flag is enabled', async () => {
  mockFeatureFlagsService.getFlag.resolves(true);
  mockWorkflowRunRepository.getPlatformUsageByDateRange.resolves([
    { _id: 'org-id', notificationsCount: 50 }
  ]);
  
  const useCase = createUseCase();
  const result = await useCase.execute(
    GetPlatformNotificationUsageCommand.create({
      startDate: new Date('2021-01-01'),
      endDate: new Date('2021-01-31'),
    })
  );
  
  expect(result).to.deep.equal([{ _id: 'org-id', notificationsCount: 50 }]);
  expect(mockWorkflowRunRepository.getPlatformUsageByDateRange.calledOnce).to.be.true;
});
🧹 Nitpick comments (1)
apps/api/src/app/billing/e2e/get-platform-notification-usage.e2e-ee.ts (1)

20-26: Consider adding interface types for mock objects.

The mock objects work correctly but lack TypeScript interfaces. Adding explicit types would help catch any drift between the mock and actual implementation, especially as WorkflowRunRepository and FeatureFlagsService evolve.

🔧 Suggested improvement
+  interface MockWorkflowRunRepository {
+    getPlatformUsageByDateRange: sinon.SinonStub;
+  }
+
+  interface MockFeatureFlagsService {
+    getFlag: sinon.SinonStub;
+  }
+
-  const mockWorkflowRunRepository = {
+  const mockWorkflowRunRepository: MockWorkflowRunRepository = {
     getPlatformUsageByDateRange: sinon.stub().resolves([]),
   };

-  const mockFeatureFlagsService = {
+  const mockFeatureFlagsService: MockFeatureFlagsService = {
     getFlag: sinon.stub().resolves(false),
   };

As per coding guidelines, prefer interfaces over types in backend code.

@djabarovgeorge djabarovgeorge merged commit a2f3e69 into next Jan 19, 2026
48 of 49 checks passed
@djabarovgeorge djabarovgeorge deleted the refactor-platform-usage-request branch January 19, 2026 12:33
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.

2 participants