user_view_history.go 631 B

12345678910111213141516171819202122232425262728
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. )
  5. type ResearchReportViewPUV struct {
  6. ResearchReportId int
  7. Pv int
  8. Uv int
  9. }
  10. // GetPUVByResearchReportIds 通过报告IDs获取老报告PV、UV
  11. func GetPUVByResearchReportIds(reportIds string) (list []*ResearchReportViewPUV, err error) {
  12. o := orm.NewOrmUsingDB("weekly")
  13. sql := `SELECT
  14. research_report_id,
  15. COUNT(1) AS pv,
  16. COUNT(DISTINCT user_id) AS uv
  17. FROM
  18. user_view_history
  19. WHERE
  20. research_report_id IN (` + reportIds + `)
  21. GROUP BY
  22. research_report_id`
  23. _, err = o.Raw(sql).QueryRows(&list)
  24. return
  25. }