|
@@ -2,4 +2,36 @@
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="org.jeecg.modules.adweb.dmp.mapper.GA">
|
|
|
|
|
|
+ <select id="getPeriodicStats" resultType="org.jeecg.modules.adweb.dmp.vo.report.PeriodicStatsVO">
|
|
|
+ SELECT
|
|
|
+ tp.time_period,
|
|
|
+ COALESCE(SUM(d.total_users), 0) AS total_users,
|
|
|
+ COALESCE(SUM(d.page_views), 0) AS page_views
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT 'today' AS time_period
|
|
|
+ UNION ALL SELECT 'yesterday'
|
|
|
+ UNION ALL SELECT 'thisWeek'
|
|
|
+ UNION ALL SELECT 'lastWeek'
|
|
|
+ UNION ALL SELECT 'thisMonth'
|
|
|
+ UNION ALL SELECT 'lastMonth'
|
|
|
+ UNION ALL SELECT 'allTime'
|
|
|
+ ) tp
|
|
|
+ LEFT JOIN
|
|
|
+ dmp_ga_daily_report d
|
|
|
+ ON
|
|
|
+ d.site_code = #{siteCode}
|
|
|
+ AND (
|
|
|
+ (tp.time_period = 'today' AND DATE(d.date) = CURDATE()) OR
|
|
|
+ (tp.time_period = 'yesterday' AND DATE(d.date) = CURDATE() - INTERVAL 1 DAY) OR
|
|
|
+ (tp.time_period = 'thisWeek' AND YEARWEEK(d.date, 1) = YEARWEEK(CURDATE(), 1)) OR
|
|
|
+ (tp.time_period = 'lastWeek' AND YEARWEEK(d.date, 1) = YEARWEEK(CURDATE() - INTERVAL 1 WEEK, 1)) OR
|
|
|
+ (tp.time_period = 'thisMonth' AND YEAR(d.date) = YEAR(CURDATE()) AND MONTH(d.date) = MONTH(CURDATE())) OR
|
|
|
+ (tp.time_period = 'lastMonth' AND YEAR(d.date) = YEAR(CURDATE() - INTERVAL 1 MONTH) AND MONTH(d.date) =
|
|
|
+ MONTH(CURDATE() - INTERVAL 1 MONTH)) OR
|
|
|
+ (tp.time_period = 'allTime')
|
|
|
+ )
|
|
|
+ GROUP BY
|
|
|
+ tp.time_period;
|
|
|
+ </select>
|
|
|
</mapper>
|