[IMP] website_livechat : show ratings per operators in channel stat webpage
This commit adds more precision about ratings per operators for a specific channel. Only the operators that have been rated on the last 100 feedbacks have their statistics displayed. The other operators that did not worked (or have not been rated) on the last 100 feedbacks are still displayed but are flaged as 'Not rated yet', so we still can see who is working on this channel. Task ID : 1895998 Closes PR #28283
This commit is contained in:
@@ -72,3 +72,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.o_livechat_no_rating {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
@@ -32,11 +32,26 @@ class WebsiteLivechat(http.Controller):
|
||||
for grade in repartition:
|
||||
percentage[grade] = round(repartition[grade] * 100.0 / sum(repartition.values()), 1) if sum(repartition.values()) else 0
|
||||
|
||||
# filter only on the team users that worked on the last 100 ratings and get their detailed stat
|
||||
ratings_per_partner = dict.fromkeys(ratings.mapped('rated_partner_id.id'), dict.fromkeys(['great', 'okay', 'bad'], 0))
|
||||
total_ratings_per_partner = dict.fromkeys(ratings.mapped('rated_partner_id.id'), 0)
|
||||
rating_texts = {10: 'great', 5: 'okay', 1: 'bad'}
|
||||
|
||||
for rating in ratings:
|
||||
partner_id = rating.rated_partner_id.id
|
||||
ratings_per_partner[partner_id][rating_texts[rating.rating]] += 1
|
||||
total_ratings_per_partner[partner_id] += 1
|
||||
|
||||
for partner_id, rating in ratings_per_partner.items():
|
||||
for k, v in ratings_per_partner[partner_id].items():
|
||||
ratings_per_partner[partner_id][k] = round(100 * v / total_ratings_per_partner[partner_id], 1)
|
||||
|
||||
# the value dict to render the template
|
||||
values = {
|
||||
'channel': channel,
|
||||
'ratings': ratings,
|
||||
'team': channel.sudo().user_ids,
|
||||
'percentage': percentage
|
||||
'percentage': percentage,
|
||||
'ratings_per_user': ratings_per_partner
|
||||
}
|
||||
return request.render("website_livechat.channel_page", values)
|
||||
|
||||
@@ -152,6 +152,25 @@
|
||||
</t>
|
||||
<div class="media-body">
|
||||
<h5><t t-esc="user.name"/></h5>
|
||||
<div class="col-lg-12">
|
||||
<div class="row">
|
||||
<div class="col-lg-4 pl-0 pr-0">
|
||||
<img t-attf-src='/rating/static/src/img/rating_10.png' alt="Great" width="16px" height="16px"/>
|
||||
<span class="align-middle"><t t-esc="ratings_per_user[user.partner_id.id]['great']"/>%</span>
|
||||
</div>
|
||||
<div class="col-lg-4 pl-0 pr-0">
|
||||
<img t-attf-src='/rating/static/src/img/rating_5.png' alt="Okay" width="16px" height="16px"/>
|
||||
<span class="align-middle"><t t-esc="ratings_per_user[user.partner_id.id]['okay']"/>%</span>
|
||||
</div>
|
||||
<div class="col-lg-4 pl-0 pr-0">
|
||||
<img t-attf-src='/rating/static/src/img/rating_1.png' alt="Bad" width="16px" height="16px"/>
|
||||
<span class="align-middle"><t t-esc="ratings_per_user[user.partner_id.id]['bad']"/>%</span>
|
||||
</div>
|
||||
<t t-if="user.partner_id.id not in ratings_per_user">
|
||||
<div class="col-lg-12 pl-0 pr-0 o_livechat_no_rating">Not rated yet</div>
|
||||
</t>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
Reference in New Issue
Block a user