Skip to content

Ai assessment#92

Merged
Shubham4026 merged 7 commits into
mainfrom
AI-assessment
Sep 11, 2025
Merged

Ai assessment#92
Shubham4026 merged 7 commits into
mainfrom
AI-assessment

Conversation

@Shubham4026
Copy link
Copy Markdown
Collaborator

No description provided.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Sep 11, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Content tracking events are now published on create and delete, enabling downstream integrations; safely no-ops when messaging is disabled.
    • Tenant-aware tracking: tenantId can be provided on creation and is included in emitted events; tenant context is also captured on deletions.
    • Event payloads include relevant details and timestamps for more accurate activity reporting.

Walkthrough

Adds Kafka-based publishing for content-tracking events in TrackingContentService and KafkaService. Makes tenantId optional in the create DTO. Wires KafkaModule into TrackingContentModule. Updates service logic to include tenant context, recent-detail fetching, and event emission on create/delete.

Changes

Cohort / File(s) Summary of changes
Kafka event publishing API
src/kafka/kafka.service.ts
Added publishContentTrackingEvent(eventType, trackingData, contentTrackingId). Determines topic from config, maps eventType to fullEventType, builds payload, and publishes via publishMessage when Kafka is enabled.
DTO: tenantId optional
src/modules/tracking_content/dto/tracking-content-create-dto.ts
tenantId made optional: added IsOptional, removed IsNotEmpty, retained IsString; property signature updated to tenantId?.
Module wiring for Kafka
src/modules/tracking_content/tracking_content.module.ts
Imported KafkaModule and added it to module imports alongside TypeOrmModule.forFeature.
Service: event emission and tenant context
src/modules/tracking_content/tracking_content.service.ts
Injected KafkaService. On create: saves details, includes tenantId, publishes 'created'. On delete: extracts tenantId from headers, publishes 'deleted'. Added helper publishContentTrackingEvent. Added MoreThan-based query to fetch recent details for non-delete events.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant S as TrackingContentService
  participant R as Repository
  participant K as KafkaService

  rect rgb(245,248,255)
    note over Client,S: Create content tracking
    Client->>S: createContentTracking(dto, req)
    S->>R: save(details with optional tenantId)
    R-->>S: savedDetails
    S->>K: publishContentTrackingEvent('created', savedDetails, contentTrackingId)
    K-->>S: ack/complete
    S-->>Client: created result
  end
Loading
sequenceDiagram
  autonumber
  actor Client
  participant S as TrackingContentService
  participant R as Repository
  participant K as KafkaService

  rect rgb(255,248,245)
    note over Client,S: Delete content tracking
    Client->>S: deleteContentTracking(id, req)
    S->>R: delete(id)
    R-->>S: delete result
    S->>K: publishContentTrackingEvent('deleted', {timestamp, tenantId}, id)
    K-->>S: ack/complete
    S-->>Client: delete confirmation
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between df45842 and bf9cc32.

📒 Files selected for processing (4)
  • src/kafka/kafka.service.ts (1 hunks)
  • src/modules/tracking_content/dto/tracking-content-create-dto.ts (2 hunks)
  • src/modules/tracking_content/tracking_content.module.ts (1 hunks)
  • src/modules/tracking_content/tracking_content.service.ts (9 hunks)
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch AI-assessment

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.

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
23.6% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@Shubham4026 Shubham4026 merged commit 5a62b84 into main Sep 11, 2025
1 of 3 checks passed
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