用户对报告的导出和查看行为分析
更新时间: 2024-12-19 16:23:35
阅读 293
用户对报告的导出&查看行为分析
背景:我需要统计哪些报告被用户导出了或者查看了,可以使用下面的SQL,在有数上连接业务库表做分析:
select
t1.id `报告ID`,
t1.name1 `项目名称`,
t1.title `报告名称`,
t1.name `模型名称`,
t1.statu `报告状态`,
t1.type `所属文件夹`,
t1.list1 `一级目录`,
t1.list2 `二级目录`,
t1.list3 `三级目录`,
t1.list4 `四级目录`,
t2.create_time `事件发生时间`,
t2.creator_id `操作人id`,
t3.nick `操作人`,
t2.type1 `操作行为`
from
(SELECT
c.id ,
d.name `name1`,
c.title ,
b.name ,
c.statu ,
c.type ,
case when e1.parent_id = 0 then e1.name
when e2.parent_id = 0 then e2.name
when e3.parent_id = 0 then e3.name
when e4.parent_id = 0 then e4.name
else "无" end list1,
case when e2.parent_id = 0 then e1.name
when e3.parent_id = 0 then e2.name
when e4.parent_id = 0 then e3.name
else "无" end list2,
case when e3.parent_id = 0 then e1.name
when e4.parent_id = 0 then e2.name
else "无" end list3,
case when e4.parent_id = 0 then e1.name
else "无" end list4
FROM
(SELECT data_connection_id,
pivot_schema ,
name,
project_id,
report_id
FROM youdata.new_report_data_model
) b
inner JOIN
(SELECT id,
title,
case when category=0 then "公共文件夹" when category=1 then "私人文件夹" end type,
case when status=0 then "回收站报告" when status=1 then "正常报告" when status="-1" then "幽灵报告" end statu,
folder_id
FROM youdata.new_report
where category = 0) c ON c.id = b.report_id
LEFT JOIN
(SELECT id,
name
FROM youdata.project)d ON d.id = b.project_id
left join
(select id,
parent_id,
name
from youdata.folder) e1 on e1.id=c.folder_id
left join
(select id,
parent_id,
name
from youdata.folder) e2 on e2.id=e1.parent_id
left join
(select id,
parent_id,
name
from youdata.folder) e3 on e3.id=e2.parent_id
left join
(select id,
parent_id,
name
from youdata.folder) e4 on e4.id=e3.parent_id)t1
right join
(select
report_id,
create_time,
creator_id,
"导出" as type1
from
youdata.export_excel_task
where
status = "success"
union all
select
resource_id,
create_time,
creator_id,
"查看" as type1
from
youdata.resource_operation_record
where
resource_type = "NEW_REPORT"
and action = "VIEW"
) t2 on t1.id =t2.report_id
left join
(select
*
from
youdata.bigviz_user
)t3 on t3.id = t2.creator_id
最终呈现的效果如下:
文档反馈
以上内容对您是否有帮助?