mlomb / chat-analytics

Generate interactive, beautiful and insightful chat analysis reports
https://chatanalytics.app
GNU Affero General Public License v3.0
689 stars 51 forks source link

Allow multiple calls at the same time #94

Closed hopperelec closed 11 months ago

hopperelec commented 1 year ago

It's usually safe to assume that a call cannot be started when the last one hasn't ended yet, but this doesn't work if importing multiple chats. I could be in a call with someone but receive a call from someone else, or I could be in two group chats which happened to have an active call at the same time.

github-actions[bot] commented 1 year ago

⚡ Preview for this PR: https://pr-94.chat-analytics.pages.dev 📊 Demo

codecov[bot] commented 1 year ago

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (33696f2) 71.96% compared to head (3d7a8af) 71.90%.

Files Patch % Lines
pipeline/aggregate/blocks/calls/CallsStats.ts 0.00% 3 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #94 +/- ## ========================================== - Coverage 71.96% 71.90% -0.06% ========================================== Files 60 60 Lines 2440 2442 +2 Branches 513 513 ========================================== Hits 1756 1756 - Misses 624 626 +2 Partials 60 60 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

mlomb commented 11 months ago

You are right, but I think the sign is flipped. We want to ignore the overlap time, so we have to subtract the difference (since this line secondsInCall += call.duration will count the overlap twice)

hopperelec commented 11 months ago

Yes, you want to take off the absolute difference if the difference is negative, but since the difference is negative (hence the if (diff < 0) {) this actually means adding it.

For example, if the second call is 10 seconds before the first one, then diff could be -10 and we want to take off the 10 seconds in between. If we do secondsInCall -= -10, we actually add 10

mlomb commented 11 months ago

You are right, my bad. Fixed in https://github.com/mlomb/chat-analytics/commit/6b1be2b6e1cd93242f5568d859bdd4f6ef575d82