Skip to content

chore: add params to filter call history by direction and/or state#37873

Merged
kodiakhq[bot] merged 2 commits intodevelopfrom
chore/call-history-filters
Dec 19, 2025
Merged

chore: add params to filter call history by direction and/or state#37873
kodiakhq[bot] merged 2 commits intodevelopfrom
chore/call-history-filters

Conversation

@pierre-lehnen-rc
Copy link
Contributor

@pierre-lehnen-rc pierre-lehnen-rc commented Dec 18, 2025

Proposed changes (including videos or screenshots)

Issue(s)

VGA-115

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • New Features

    • Call history list now supports filtering by call direction (inbound or outbound).
    • Call history list now supports filtering by call state.
  • Bug Fixes

    • Improved error response handling to properly distinguish between unauthorized (401) and forbidden (403) status codes.

✏️ Tip: You can customize this high-level summary in your review settings.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Dec 18, 2025

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Dec 18, 2025

⚠️ No Changeset found

Latest commit: 7989b03

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 18, 2025

Walkthrough

The pull request extends the call history API endpoint with filtering capabilities for direction (inbound/outbound) and state, updates test data to support multiple call history scenarios with varying states and directions, and adds comprehensive end-to-end tests to validate the new filtering functionality.

Changes

Cohort / File(s) Summary
API Endpoint Schema & Logic
apps/meteor/app/api/server/v1/call-history.ts
Added direction and state filter parameters to CallHistoryList schema; implemented query parameter extraction and normalization using ensureArray for state filtering; updated error response mapping to use 401 for unauthorized and 403 for forbidden; modified call-history.list and call-history.info endpoint handlers to apply filters via MongoDB $in operator.
Test Data Setup
apps/meteor/server/startup/callHistoryTestData.ts
Renamed and reorganized test call history document IDs to distinguish internal/external and outbound/inbound variants; updated inserted documents with new direction field, state transitions (e.g., ended → not-answered, ended → failed), and external flag markers; aligned MediaCalls test data with new call ID mappings.
End-to-End Tests
apps/meteor/tests/end-to-end/api/call-history.ts
Updated test assertions to reference reorganized history IDs; adjusted expected item states to match new test data; added new test suites for direction-based filtering, state-based filtering, and combined filter scenarios; verified correct item counts and presence of filtered results.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • API logic changes: Direction and state extraction/normalization with MongoDB filtering—verify correct filter application and schema compliance
  • Test data reorganization: Systematic ID and field updates across multiple records—confirm consistency between old and new mappings
  • Comprehensive filtering test coverage: Multiple new test cases with varied filter combinations—validate assertions and expected behavior align with API logic

Possibly related PRs

Suggested labels

stat: ready to merge, stat: QA assured

Suggested reviewers

  • KevLehman
  • tassoevan
  • ricardogarim

Poem

🐰 Hop, hop! The filters now align,
Directions split—outbound, inbound fine,
States refined with ended, failed, and more,
Call history organized to the core!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding filter parameters (direction and/or state) to the call history endpoint.
Linked Issues check ✅ Passed The PR implements filter parameters for direction and state in call history, which aligns with VGA-115's objective to add filters to the History List endpoint.
Out of Scope Changes check ✅ Passed All changes are scoped to implementing direction and state filtering for call history; no unrelated modifications detected.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/call-history-filters

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a909ab6 and 6f5fdf9.

📒 Files selected for processing (3)
  • apps/meteor/app/api/server/v1/call-history.ts (5 hunks)
  • apps/meteor/server/startup/callHistoryTestData.ts (4 hunks)
  • apps/meteor/tests/end-to-end/api/call-history.ts (7 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/tests/end-to-end/api/call-history.ts
  • apps/meteor/app/api/server/v1/call-history.ts
  • apps/meteor/server/startup/callHistoryTestData.ts
🧠 Learnings (5)
📚 Learning: 2025-12-18T15:18:23.819Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37773
File: apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx:24-34
Timestamp: 2025-12-18T15:18:23.819Z
Learning: In apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx, for internal call history items, the item.contactId is guaranteed to always match either the caller.id or callee.id in the call data, so the contact resolution in getContact will never result in undefined.

Applied to files:

  • apps/meteor/tests/end-to-end/api/call-history.ts
  • apps/meteor/app/api/server/v1/call-history.ts
  • apps/meteor/server/startup/callHistoryTestData.ts
📚 Learning: 2025-11-19T18:20:37.116Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37419
File: apps/meteor/server/services/media-call/service.ts:141-141
Timestamp: 2025-11-19T18:20:37.116Z
Learning: In apps/meteor/server/services/media-call/service.ts, the sendHistoryMessage method should use call.caller.id or call.createdBy?.id as the message author, not call.transferredBy?.id. Even for transferred calls, the message should appear in the DM between the two users who are calling each other, not sent by the person who transferred the call.

Applied to files:

  • apps/meteor/tests/end-to-end/api/call-history.ts
  • apps/meteor/app/api/server/v1/call-history.ts
  • apps/meteor/server/startup/callHistoryTestData.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Ensure tests run reliably in parallel without shared state conflicts

Applied to files:

  • apps/meteor/tests/end-to-end/api/call-history.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Ensure clean state for each test execution in Playwright tests

Applied to files:

  • apps/meteor/tests/end-to-end/api/call-history.ts
📚 Learning: 2025-11-19T18:20:07.720Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37419
File: packages/i18n/src/locales/en.i18n.json:918-921
Timestamp: 2025-11-19T18:20:07.720Z
Learning: Repo: RocketChat/Rocket.Chat — i18n/formatting
Learning: This repository uses a custom message formatting parser in UI blocks/messages; do not assume standard Markdown rules. For keys like Call_ended_bold, Call_not_answered_bold, Call_failed_bold, and Call_transferred_bold in packages/i18n/src/locales/en.i18n.json, retain the existing single-asterisk emphasis unless maintainers request otherwise.

Applied to files:

  • apps/meteor/server/startup/callHistoryTestData.ts
🧬 Code graph analysis (2)
apps/meteor/tests/end-to-end/api/call-history.ts (1)
apps/meteor/tests/data/api-data.ts (2)
  • request (10-10)
  • credentials (39-42)
apps/meteor/server/startup/callHistoryTestData.ts (1)
packages/models/src/index.ts (2)
  • CallHistory (152-152)
  • MediaCalls (189-189)
⏰ 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). (15)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 5.0 (1/5)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 8.2 [legacy watchers] coverage (2/5)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 8.2 [legacy watchers] coverage (1/5)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 8.2 [legacy watchers] coverage (5/5)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 8.2 [legacy watchers] coverage (3/5)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 5.0 (4/5)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 8.2 (1/4)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 5.0 (2/5)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 8.2 [legacy watchers] coverage (4/5)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 5.0 (5/5)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 8.2 (2/4)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 5.0 (3/5)
  • GitHub Check: 🔨 Test API (EE) / MongoDB 5.0 (1/1)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 8.2 (4/4)
  • GitHub Check: 🔨 Test API (EE) / MongoDB 8.2 coverage (1/1)
🔇 Additional comments (7)
apps/meteor/tests/end-to-end/api/call-history.ts (2)

25-80: LGTM! Test assertions correctly updated to match new test data structure.

The updated history IDs and property assertions align with the new test data seeding in callHistoryTestData.ts. The test properly validates all four history entries with their respective states (ended, not-answered, failed) and directions (inbound, outbound).


99-190: Comprehensive filter test coverage.

The new filter tests properly exercise:

  • Single state filtering (lines 99-120)
  • Multiple states filtering (lines 122-144)
  • Direction filtering (lines 146-167)
  • Combined state + direction filtering (lines 169-190)

Assertions correctly match the expected results based on the test data.

apps/meteor/app/api/server/v1/call-history.ts (3)

34-53: Well-documented schema handling for array serialization.

The inline comment explains the client serialization behavior clearly. The oneOf approach correctly handles both single values and arrays for the state parameter.


99-100: Verify the distinction between 401 and 403 responses.

The error response mapping now uses 401 for unauthorized and 403 for forbidden. Ensure this aligns with the API's authentication/authorization flow - typically 401 is for missing/invalid credentials and 403 is for insufficient permissions.

Also applies to: 197-198


109-119: Correct filter implementation with proper null/empty handling.

The implementation correctly:

  • Normalizes state to an array using ensureArray, but only when state is truthy (via the state && guard)
  • Only applies the $in filter when stateFilter has elements (checked via stateFilter?.length)
  • Conditionally spreads direction only when provided

Edge cases (undefined, null, empty string) are safely handled by the && guard before ensureArray is invoked, preventing falsy values from reaching the utility function. The ensureArray implementation using [].concat(param) correctly normalizes single values to arrays and creates new array instances.

apps/meteor/server/startup/callHistoryTestData.ts (2)

12-65: Test data provides comprehensive coverage for filter scenarios.

The four history entries cover all combinations needed for testing:

  • ended state: outbound internal + inbound external
  • not-answered state: inbound internal
  • failed state: outbound external

This enables thorough validation of single-state, multi-state, direction, and combined filters.


67-196: MediaCalls records correctly model caller/callee relationships.

The test data properly establishes:

  • callId1/callId2: Internal user-to-user calls with appropriate caller/callee
  • callId3/callId4: External SIP calls with correct direction modeling (user→SIP for outbound, SIP→user for inbound)

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.

@pierre-lehnen-rc pierre-lehnen-rc added this to the 7.14.0 milestone Dec 18, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 18, 2025

📦 Docker Image Size Report

📈 Changes

Service Current Baseline Change Percent
sum of all images 1.2GiB 1.2GiB +12MiB
rocketchat 358MiB 347MiB +12MiB
omnichannel-transcript-service 132MiB 132MiB +53B
queue-worker-service 132MiB 132MiB +184B
ddp-streamer-service 126MiB 126MiB +4.2KiB
account-service 113MiB 113MiB -649B
authorization-service 111MiB 111MiB -398B
stream-hub-service 110MiB 110MiB -557B
presence-service 110MiB 110MiB -173B

📊 Historical Trend

---
config:
  theme: "dark"
  xyChart:
    width: 900
    height: 400
---
xychart
  title "Image Size Evolution by Service (Last 30 Days + This PR)"
  x-axis ["11/15 22:28", "11/16 01:28", "11/17 23:50", "11/18 22:53", "11/19 23:02", "11/21 16:49", "11/24 17:34", "11/27 22:32", "11/28 19:05", "12/01 23:01", "12/02 21:57", "12/03 21:00", "12/04 18:17", "12/05 21:56", "12/08 20:15", "12/09 22:17", "12/10 23:26", "12/11 21:56", "12/12 22:45", "12/13 01:34", "12/15 22:31", "12/16 22:18", "12/17 21:04", "12/18 23:12", "12/19 00:33 (PR)"]
  y-axis "Size (GB)" 0 --> 0.5
  line "account-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "authorization-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "ddp-streamer-service" [0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12]
  line "omnichannel-transcript-service" [0.14, 0.14, 0.14, 0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13]
  line "presence-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "queue-worker-service" [0.14, 0.14, 0.14, 0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13]
  line "rocketchat" [0.36, 0.36, 0.35, 0.35, 0.35, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.35]
  line "stream-hub-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
Loading

Statistics (last 24 days):

  • 📊 Average: 1.5GiB
  • ⬇️ Minimum: 1.2GiB
  • ⬆️ Maximum: 1.6GiB
  • 🎯 Current PR: 1.2GiB
ℹ️ About this report

This report compares Docker image sizes from this build against the develop baseline.

  • Tag: pr-37873
  • Baseline: develop
  • Timestamp: 2025-12-19 00:33:35 UTC
  • Historical data points: 24

Updated: Fri, 19 Dec 2025 00:33:36 GMT

@pierre-lehnen-rc pierre-lehnen-rc marked this pull request as ready for review December 18, 2025 22:45
@pierre-lehnen-rc pierre-lehnen-rc requested a review from a team as a code owner December 18, 2025 22:45
@pierre-lehnen-rc pierre-lehnen-rc added the stat: QA assured Means it has been tested and approved by a company insider label Dec 18, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Dec 18, 2025
@codecov
Copy link

codecov bot commented Dec 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.69%. Comparing base (a909ab6) to head (7989b03).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop   #37873   +/-   ##
========================================
  Coverage    67.69%   67.69%           
========================================
  Files         3469     3469           
  Lines       113796   113796           
  Branches     20926    20950   +24     
========================================
+ Hits         77029    77030    +1     
- Misses       34591    34592    +1     
+ Partials      2176     2174    -2     
Flag Coverage Δ
e2e 57.13% <ø> (ø)
e2e-api 44.03% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kodiakhq kodiakhq bot merged commit d821cd3 into develop Dec 19, 2025
47 of 48 checks passed
@kodiakhq kodiakhq bot deleted the chore/call-history-filters branch December 19, 2025 00:55
gaolin1 pushed a commit to gaolin1/medsense.webchat that referenced this pull request Jan 6, 2026
@dougfabris dougfabris modified the milestones: 7.14.0, 8.0.0 Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants