[IMP] im_livechat: improve livechat statistics

task-3471332

closes odoo/odoo#137548

Signed-off-by: Didier Debondt (did) <did@odoo.com>
This commit is contained in:
tsm-odoo
2023-10-05 10:21:56 +00:00
parent ef424a9dc2
commit ae6f6e3e5b
3 changed files with 14 additions and 5 deletions
@@ -8,8 +8,9 @@
<field name="arch" type="xml">
<pivot string="Livechat Support Statistics" disable_linking="1" sample="1">
<field name="technical_name" type="row"/>
<field name="duration" type="measure"/>
<field name="nbr_message" type="measure"/>
<field name="duration" type="measure" string="Duration of Session (min)"/>
<field name="nbr_message" type="measure" string="Messages per session"/>
<field name="is_without_answer" invisible="True"/>
</pivot>
</field>
</record>
@@ -20,7 +21,9 @@
<field name="arch" type="xml">
<graph string="Livechat Support Statistics" sample="1" disable_linking="1">
<field name="technical_name"/>
<field name="nbr_message" type="measure"/>
<field name="nbr_message" type="measure" string="Messages per session"/>
<field name="duration" string="Duration of Session (min)"/>
<field name="is_without_answer" invisible="True"/>
</graph>
</field>
</record>
@@ -55,7 +58,7 @@
<field name="name">Session Statistics</field>
<field name="res_model">im_livechat.report.channel</field>
<field name="view_mode">graph,pivot</field>
<field name="context">{"search_default_last_week":1}</field>
<field name="context">{"search_default_last_week":1, "group_by": "start_date:day"}</field>
<field name="help">Livechat Support Channel Statistics allows you to easily check and analyse your company livechat session performance. Extract information about the missed sessions, the audience, the duration of a session, etc.</field>
</record>
@@ -19,6 +19,7 @@ class ImLivechatReportOperator(models.Model):
start_date = fields.Datetime('Start Date of session', readonly=True)
time_to_answer = fields.Float('Time to answer', digits=(16, 2), readonly=True, group_operator="avg", help="Average time to give the first answer to the visitor")
duration = fields.Float('Average duration', digits=(16, 2), readonly=True, group_operator="avg", help="Duration of the conversation (in seconds)")
rating = fields.Float('Average rating', readonly=True, group_operator="avg", help="Average rating given by the visitor")
def init(self):
# Note : start_date_hour must be remove when the read_group will allow grouping on the hour of a datetime. Don't forget to change the view !
@@ -32,6 +33,7 @@ class ImLivechatReportOperator(models.Model):
COUNT(DISTINCT C.id) AS nbr_channel,
C.id AS channel_id,
C.create_date AS start_date,
C.rating_last_value as rating,
EXTRACT('epoch' FROM MAX(M.create_date) - MIN(M.create_date)) AS duration,
EXTRACT('epoch' FROM MIN(MO.create_date) - MIN(M.create_date)) AS time_to_answer
FROM discuss_channel C
@@ -35,6 +35,10 @@
<filter name="start_date_filter" string="This Week" domain="[
('start_date', '>=', (datetime.datetime.combine(context_today() + relativedelta(weeks=-1,days=1,weekday=0), datetime.time(0,0,0)).to_utc()).strftime('%Y-%m-%d %H:%M:%S')),
('start_date', '&lt;', (datetime.datetime.combine(context_today() + relativedelta(days=1,weekday=0), datetime.time(0,0,0)).to_utc()).strftime('%Y-%m-%d %H:%M:%S'))]"/>
<filter name="last_month" string="This Month" invisible="True" domain="[
('start_date', '>=', (datetime.datetime.combine(context_today() + relativedelta(months=-1,days=1,weekday=0), datetime.time(0,0,0)).to_utc()).strftime('%Y-%m-%d %H:%M:%S')),
('start_date', '&lt;', (datetime.datetime.combine(context_today() + relativedelta(days=1,weekday=0), datetime.time(0,0,0)).to_utc()).strftime('%Y-%m-%d %H:%M:%S'))]"/>
<separator/>
<separator/>
<filter name="filter_start_date" date="start_date"/>
<group expand="0" string="Group By...">
@@ -51,7 +55,7 @@
<field name="name">Operator Analysis</field>
<field name="res_model">im_livechat.report.operator</field>
<field name="view_mode">graph,pivot</field>
<field name="context">{"search_default_last_week":1}</field>
<field name="context">{"search_default_last_month":1}</field>
<field name="help">Livechat Support Channel Statistics allows you to easily check and analyse your company livechat session performance. Extract information about the missed sessions, the audience, the duration of a session, etc.</field>
</record>