From ce20c29f820ee748afa40375d4dc350e119c710a Mon Sep 17 00:00:00 2001 From: David Beguin Date: Tue, 6 Nov 2018 10:32:27 +0000 Subject: [PATCH] [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 --- .../static/src/scss/im_livechat.scss | 4 ++++ addons/website_livechat/controllers/main.py | 17 ++++++++++++++++- .../views/website_livechat.xml | 19 +++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/addons/im_livechat/static/src/scss/im_livechat.scss b/addons/im_livechat/static/src/scss/im_livechat.scss index 1c154c27049..af21085a2c1 100644 --- a/addons/im_livechat/static/src/scss/im_livechat.scss +++ b/addons/im_livechat/static/src/scss/im_livechat.scss @@ -72,3 +72,7 @@ } } } + +.o_livechat_no_rating { + opacity: 0.5; +} diff --git a/addons/website_livechat/controllers/main.py b/addons/website_livechat/controllers/main.py index 31af89c2e63..8b5a6fba317 100644 --- a/addons/website_livechat/controllers/main.py +++ b/addons/website_livechat/controllers/main.py @@ -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) diff --git a/addons/website_livechat/views/website_livechat.xml b/addons/website_livechat/views/website_livechat.xml index 6afcda0cd0e..22770a3d7b4 100644 --- a/addons/website_livechat/views/website_livechat.xml +++ b/addons/website_livechat/views/website_livechat.xml @@ -152,6 +152,25 @@
+
+
+
+ Great + % +
+
+ Okay + % +
+
+ Bad + % +
+ +
Not rated yet
+
+
+