12345678910111213141516171819202122232425262728 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- )
- type ResearchReportViewPUV struct {
- ResearchReportId int
- Pv int
- Uv int
- }
- // GetPUVByResearchReportIds 通过报告IDs获取老报告PV、UV
- func GetPUVByResearchReportIds(reportIds string) (list []*ResearchReportViewPUV, err error) {
- o := orm.NewOrmUsingDB("weekly")
- sql := `SELECT
- research_report_id,
- COUNT(1) AS pv,
- COUNT(DISTINCT user_id) AS uv
- FROM
- user_view_history
- WHERE
- research_report_id IN (` + reportIds + `)
- GROUP BY
- research_report_id`
- _, err = o.Raw(sql).QueryRows(&list)
- return
- }
|