Repository navigation
[WTEL-10706] Transferred call scoring with multiple agent scoring support - #581
wahomeniuk wants to merge 2 commits into
Conversation
🤖 Webitel Code ReviewЦей комміт додає підтримку розширеного оцінювання дзвінків у платформі Webitel: у Protobuf-структуру 📋 Walkthrough (2 файл(и/ів))
Суттєвих зауважень немає. 👍 🔗 Cross-repo callers змінених символів (37)
Index-grounded review across the Webitel codebase. Знахідки можуть бути неточними — перевіряйте перед застосуванням. |
kirychukyurii
left a comment
There was a problem hiding this comment.
крім того, чекаємо ще webitel/protos#508 і webitel/call_center#383
| 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) |
There was a problem hiding this comment.
тут cc_call_root_id рахується для кожної оцінки домену з :From, і кожен виклик - це пошук по id в усіх місячних партиціях cc_calls_history, бо parent шукаємо без created_at
тож запит history з фільтром rated буде повільний на базі з великою к-тю оцінок
якщо в cc_audit_rate буде корінь дзвінка (коментар в webitel/call_center#383), тут вистачить exists по ньому
+ в гілці else нижче і в GetHistoryByGroups
| 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) |
There was a problem hiding this comment.
тут раніше був not exists, який йде по cc_audit_rate_call_id_uindex, а not in тягне всі оцінки домену на кожен запит
+ те саме в GetHistoryByGroups
| 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) |
| }) | ||
|
|
||
| if err != nil { | ||
| if isDuplicationViolationErrorCode(err) { |
There was a problem hiding this comment.
пропоную перевіряти ще й Constraint == "cc_audit_rate_call_id_uindex", бо isDuplicationViolationErrorCode спрацює на будь-який unique, і ми віддами "already rated" там, де причина інша
| 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) |
There was a problem hiding this comment.
в решті стору іменовані параметри через мапу і SelectOne в структуру
може зробити так само?
тоді і errors.Is(err, sql.ErrNoRows) не треба, бо extractCodeFromErr вже віддає 404 на sql.ErrNoRows, ValidateChatRate вище так само, але його можна окремо
|
@kirychukyurii глянув ПРи. Погоджуюсь з коментарями. Ще чогось критичного не побачив. PS. якщо не робити зміну зі збереженням id кореневого дзвінка в cc_audit_rate, то варто хоча б винести блок фільтра rated/score (40+ рядків, повторюється в GetHistory і GetHistoryByGroups) в спільну функцію, як hasFileFilterSQL("t") у цьому ж файлі, щоб не повторювати його. |
Kontentski
left a comment
There was a problem hiding this comment.
нема чого додати до коментарів вище
kirychukyurii
left a comment
There was a problem hiding this comment.
дякую) ще дрібна правка, після якої можна мерджить
| 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 |
There was a problem hiding this comment.
пропоную все ж зробити по аналогії з hasFileFilterSQL, як тут
цей фільтр вцілому став складним і дуже легко в ньому помилитись і забути змінити у двох місцях
а так трохи спростимо
No description provided.