Skip to content

[WTEL-10706] Transferred call scoring with multiple agent scoring support - #581

Open
wahomeniuk wants to merge 2 commits into
mainfrom
feat/WTEL-10706/transferred-call-scoring
Open

wahomeniuk wants to merge 2 commits into
mainfrom
feat/WTEL-10706/transferred-call-scoring

Conversation

@wahomeniuk

Copy link
Copy Markdown
Contributor

No description provided.

@webitel-review

webitel-review Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Webitel Code Review

Цей комміт додає підтримку розширеного оцінювання дзвінків у платформі Webitel: у Protobuf-структуру HistoryCall додано нові поля rates та evaluation_agents разом з відповідними повідомленнями HistoryCallRate і HistoryCallEvaluationAgent. Також оновлено логіку валідації оцінки дзвінка у app/cc_audit_form.go — перейдено на новий метод ValidateCallRate хранилища AuditRateStore з врахуванням domainId.

📋 Walkthrough (2 файл(и/ів))
Файл Зміни
app/cc_audit_form.go Замінено виклики GetOwnerUserCall на ValidateCallRate з передачею domainId для перевірки оцінки дзвінка.
gen/engine/call.pb.go Оновлено згенерований gRPC/Protobuf код: додано структури HistoryCallRate, HistoryCallEvaluationAgent та нові поля rates і evaluation_agents до HistoryCall.

Суттєвих зауважень немає. 👍

🔗 Cross-repo callers змінених символів (37)
  • Descriptor → webitel.go/app/custom.go:74 у (*API).InitCustom (тип ресівера не доведено)
  • Descriptor → webitel.go/app/custom_dictionaries.go:264 у (CustomDictionariesAPI).CreateType (тип ресівера не доведено)
  • Descriptor → webitel.go/app/custom_dictionaries.go:312 у (CustomDictionariesAPI).CreateType (тип ресівера не доведено)
  • GetId → call_center/grpc_api/agent.go:46 у (*agent).Online (тип ресівера не доведено)
  • GetId → call_center/grpc_api/agent.go:113 у (*agent).AcceptTask (тип ресівера не доведено)
  • GetId → call_center/grpc_api/member.go:97 у (*member).AttemptResult (тип ресівера не доведено)
  • GetId → webitel.go/app/articles.go:589 у (*API).DeleteArticle
  • GetId → webitel.go/app/contacts.go:1536 у (*API).UpdateContact
  • GetId → webitel.go/app/model/contacts/etag.go:77 у (*Tid).GetId
  • GetId → webitel.go/postgres/catalog/contacts.go:378 у (*contactStore).Delete
  • GetId → webitel.go/postgres/catalog/spaces.go:220 у (*spaceStore).Delete
  • GetUser → chat_manager/bot/vk/bot.go:590 у (*VKBot).getChannel (тип ресівера не доведено)
  • GetUser → chat_manager/cmd/chat/service.go:523 у (*chatService).StartConversation (тип ресівера не доведено)
  • GetUser → chat_manager/cmd/chat/service.go:559 у (*chatService).StartConversation (тип ресівера не доведено)
  • GetUser → webitel.go/postgres/catalog/auth.go:140 у PasswordAuthorization
  • ProtoMessage → webitel.go/app/custom_extensions.go:336 у (CustomExtensionsAPI).CreateType (тип ресівера не доведено)
  • ProtoMessage → webitel.go/app/custom_extensions.go:487 у (CustomExtensionsAPI).UpdateType (тип ресівера не доведено)
  • ProtoReflect → im-account-service/internal/service/updates.go:107 у (*UpdatesManager).PublishUpdate (тип ресівера не доведено)
  • ProtoReflect → im-account-service/internal/service/updates/auth.v1.go:33 у (*UpdateDeviceRegister).ProtoReflect (тип ресівера не доведено)
  • ProtoReflect → im-account-service/internal/service/updates/auth.v1.go:60 у (*UpdateDeviceUnregister).ProtoReflect (тип ресівера не доведено)
  • Reset → chat_manager/bot/facebook/whatsapp.go:681 у (*Client).unsubscribeWhatsAppBusinessAccounts (тип ресівера не доведено)
  • Reset → chat_manager/bot/facebook/whatsapp.go:829 у (*Client).subscribeWhatsAppBusinessAccounts (тип ресівера не доведено)
  • Reset → chat_manager/bot/facebook/whatsapp.go:1990 у (*Client).whatsAppOnMessages (тип ресівера не доведено)
  • String → engine/app/chat.go:109 у (*App).SendFileMessage (тип ресівера не доведено)
  • String → engine/app/grpc_server.go:52 у (*GrpcServer).GetPublicInterface (тип ресівера не доведено)
  • String → engine/app/grpc_server.go:299 у (*App).StartGrpcServer (тип ресівера не доведено)
  • GetCallId → call_center/queue/queue_manager.go:621
  • GetCallId → engine/grpc_api/call.go:736
  • GetCallId → storage/grpc_api/file.go:840
  • GetCreatedAt → chat_manager/internal/repo/sqlx/bot.go:392
  • GetCreatedAt → webitel.go/app/model/contacts/output.go:149
  • GetCreatedAt → webitel.go/app/model/knowledgebase/output.go:132
  • GetCreatedAt → webitel.go/postgres/catalog/ldap_catalogs.go:735
  • GetRatedBy → engine/grpc_api/call.go:66
  • GetRatedUser → engine/grpc_api/call.go:66
  • GetScoreOptional → engine/grpc_api/call.go:66
  • GetScoreRequired → engine/grpc_api/call.go:66

Index-grounded review across the Webitel codebase. Знахідки можуть бути неточними — перевіряйте перед застосуванням.

@kirychukyurii kirychukyurii left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

крім того, чекаємо ще webitel/protos#508 і webitel/call_center#383

Comment thread store/sqlstore/call_store.go Outdated
Comment on lines +455 to +462
then t.id not in (
select x.root_id
from (select call_center.cc_call_root_id(ar.call_id::uuid) root_id
from call_center.cc_audit_rate ar
where ar.domain_id = :Domain::int8
and ar.call_id notnull
and (:From::timestamptz isnull or ar.call_created_at isnull or ar.call_created_at >= :From::timestamptz)) x
where x.root_id notnull)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут cc_call_root_id рахується для кожної оцінки домену з :From, і кожен виклик - це пошук по id в усіх місячних партиціях cc_calls_history, бо parent шукаємо без created_at

тож запит history з фільтром rated буде повільний на базі з великою к-тю оцінок
якщо в cc_audit_rate буде корінь дзвінка (коментар в webitel/call_center#383), тут вистачить exists по ньому
+ в гілці else нижче і в GetHistoryByGroups

Comment thread store/sqlstore/call_store.go Outdated
Comment on lines +463 to +466
else t.id::text not in (
select ar.call_id
from call_center.cc_audit_rate ar
where ar.domain_id = :Domain::int8 and ar.call_id notnull)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут раніше був not exists, який йде по cc_audit_rate_call_id_uindex, а not in тягне всі оцінки домену на кожен запит
+ те саме в GetHistoryByGroups

Suggested change
else t.id::text not in (
select ar.call_id
from call_center.cc_audit_rate ar
where ar.domain_id = :Domain::int8 and ar.call_id notnull)
else not exists(
select 1
from call_center.cc_audit_rate ar
where ar.call_id = t.id::text)

Comment thread store/sqlstore/cc_audit_rate.go Outdated
})

if err != nil {
if isDuplicationViolationErrorCode(err) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

пропоную перевіряти ще й Constraint == "cc_audit_rate_call_id_uindex", бо isDuplicationViolationErrorCode спрацює на будь-який unique, і ми віддами "already rated" там, де причина інша

Comment thread store/sqlstore/cc_audit_rate.go Outdated
Comment on lines +335 to +351
row := s.GetReplica().WithContext(ctx).QueryRow(`select a.user_id,
case when c.user_id notnull or q.type = 2 then c.created_at else p.created_at end as created_at,
a.call_id notnull as allowed,
exists (select 1
from call_center.cc_audit_rate ar
where ar.call_id = any (array(select f.id::text
from call_center.cc_call_family(call_center.cc_call_root_id(c.id)) f))
and (ar.call_id = c.id::text or ar.rated_user_id = a.user_id)) as rated
from call_center.cc_calls_history c
left join call_center.cc_queue q on q.id = c.queue_id
left join call_center.cc_calls_history p on p.id = c.bridged_id
left join lateral (select e.call_id, e.user_id
from call_center.cc_call_evaluation_agents(call_center.cc_call_root_id(c.id)) e
where e.call_id = c.id) a on true
where c.id = $1::uuid and c.domain_id = $2::int8`, callId, domainId)

err := row.Scan(&userId, &createdAt, &allowed, &rated)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в решті стору іменовані параметри через мапу і SelectOne в структуру
може зробити так само?

тоді і errors.Is(err, sql.ErrNoRows) не треба, бо extractCodeFromErr вже віддає 404 на sql.ErrNoRows, ValidateChatRate вище так само, але його можна окремо

@Kontentski

Copy link
Copy Markdown
Contributor

@kirychukyurii глянув ПРи. Погоджуюсь з коментарями. Ще чогось критичного не побачив.

PS. якщо не робити зміну зі збереженням id кореневого дзвінка в cc_audit_rate, то варто хоча б винести блок фільтра rated/score (40+ рядків, повторюється в GetHistory і GetHistoryByGroups) в спільну функцію, як hasFileFilterSQL("t") у цьому ж файлі, щоб не повторювати його.

@Kontentski Kontentski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

нема чого додати до коментарів вище

@kirychukyurii kirychukyurii left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

дякую) ще дрібна правка, після якої можна мерджить

from a
where not a.id = any(:DependencyIds::uuid[]))
))
and ( (:Rated::bool isnull and :RatedUserIds::int8[] isnull and :RatedByIds::int8[] isnull and :ScoreOptionalFrom::numeric isnull

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

пропоную все ж зробити по аналогії з hasFileFilterSQL, як тут
цей фільтр вцілому став складним і дуже легко в ньому помилитись і забути змінити у двох місцях
а так трохи спростимо

This branch has not been deployed

No deployments
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.

3 participants