|
|
@@ -56,6 +56,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
SELECT A.page_views AS pageViews,A.unique_visitors AS uniqueVisitors, B.live_id AS liveId,B.live_name AS liveName,B.`status` AS status,B.live_img_url AS liveImgUrl,B.start_time AS startTime
|
|
|
FROM live_data A LEFT JOIN live B ON A.live_id = B.live_id ORDER BY B.start_time LIMIT 4
|
|
|
</select>
|
|
|
+ <select id="getCompanyRecentLive" resultType="com.fs.live.vo.RecentLiveDataVo">
|
|
|
+ SELECT A.page_views AS pageViews,A.unique_visitors AS uniqueVisitors, B.live_id AS liveId,B.live_name AS liveName,B.`status` AS status,B.live_img_url AS liveImgUrl,B.start_time AS startTime
|
|
|
+ FROM live_data A LEFT JOIN live B ON A.live_id = B.live_id
|
|
|
+ <if test="companyId != null">
|
|
|
+ where b.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ ORDER BY B.start_time LIMIT 4
|
|
|
+ </select>
|
|
|
<select id="getLiveTop" resultType="com.fs.live.vo.RecentLiveDataVo">
|
|
|
SELECT A.page_views AS pageViews,A.unique_visitors AS uniqueVisitors,A.total_views AS totalViews,A.unique_viewers AS uniqueViewers,A.peak_concurrent_viewers AS peakConcurrentViewers,
|
|
|
B.live_name AS liveName,B.live_img_url AS liveImgUrl
|
|
|
@@ -79,6 +87,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</choose>
|
|
|
LIMIT 10
|
|
|
</select>
|
|
|
+ <select id="getCompanyLiveTop" resultType="com.fs.live.vo.RecentLiveDataVo">
|
|
|
+ SELECT A.page_views AS pageViews,A.unique_visitors AS uniqueVisitors,A.total_views AS totalViews,A.unique_viewers AS uniqueViewers,A.peak_concurrent_viewers AS peakConcurrentViewers,
|
|
|
+ B.live_name AS liveName,B.live_img_url AS liveImgUrl
|
|
|
+ FROM live_data A LEFT JOIN live B ON A.live_id = B.live_id
|
|
|
+ <if test="companyId != null">
|
|
|
+ where b.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ <choose>
|
|
|
+ <when test="rankType == 'highFlow'">
|
|
|
+ ORDER BY A.page_views DESC
|
|
|
+ </when>
|
|
|
+ <when test="rankType == 'highView'">
|
|
|
+ ORDER BY A.total_views DESC
|
|
|
+ </when>
|
|
|
+ <when test="rankType == 'lowFlow'">
|
|
|
+ ORDER BY A.page_views ASC
|
|
|
+ </when>
|
|
|
+ <when test="rankType == 'lowView'">
|
|
|
+ ORDER BY A.total_views ASC
|
|
|
+ </when>
|
|
|
+ <otherwise>
|
|
|
+ ORDER BY A.page_views DESC
|
|
|
+ </otherwise>
|
|
|
+ </choose>
|
|
|
+ LIMIT 10
|
|
|
+ </select>
|
|
|
<select id="getCurrentData" resultType="com.fs.live.vo.TrendDataVO">
|
|
|
SELECT
|
|
|
SUM(ld.page_views) AS views,
|
|
|
@@ -125,6 +159,63 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
LEFT JOIN live l ON ld.live_id = l.live_id
|
|
|
WHERE DATE(l.start_time) BETWEEN #{prevStartDate} AND #{prevStartDate};
|
|
|
</select>
|
|
|
+ <select id="getCompanyCurrentData" resultType="com.fs.live.vo.TrendDataVO">
|
|
|
+ SELECT
|
|
|
+ SUM(ld.page_views) AS views,
|
|
|
+ SUM(ld.unique_visitors) AS visitors,
|
|
|
+ COUNT(l.live_id) AS streams,
|
|
|
+ SUM(ld.total_views) AS pv,
|
|
|
+ SUM(ld.unique_viewers) AS uv
|
|
|
+ FROM live_data ld
|
|
|
+ JOIN live l ON ld.live_id = l.live_id
|
|
|
+ WHERE DATE(l.start_time) BETWEEN #{startDate} AND #{endDate}
|
|
|
+ <if test="companyId != null">
|
|
|
+ and l.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ ;
|
|
|
+
|
|
|
+ </select>
|
|
|
+ <select id="getCompanyChartData" resultType="java.util.Map">
|
|
|
+ SELECT
|
|
|
+ CASE
|
|
|
+ WHEN #{format} = 'day' THEN DATE(l.start_time)
|
|
|
+ WHEN #{format} = 'week' THEN
|
|
|
+ CONCAT(
|
|
|
+ DATE_FORMAT(DATE_SUB(l.start_time, INTERVAL WEEKDAY(l.start_time) DAY), '%m/%d'),
|
|
|
+ '-',
|
|
|
+ DATE_FORMAT(DATE_ADD(l.start_time, INTERVAL (6 - WEEKDAY(l.start_time)) DAY), '%m/%d')
|
|
|
+ )
|
|
|
+ WHEN #{format} = 'month' THEN DATE_FORMAT(l.start_time, '%Y-%m')
|
|
|
+ END AS date_range,
|
|
|
+ <choose>
|
|
|
+ <when test="category == 'streams'"> COUNT(l.live_id) </when>
|
|
|
+ <otherwise> SUM(ld.${category}) </otherwise>
|
|
|
+ </choose>
|
|
|
+ AS views
|
|
|
+ FROM live_data ld
|
|
|
+ LEFT JOIN live l ON ld.live_id = l.live_id
|
|
|
+ WHERE DATE(l.start_time) BETWEEN #{chartStartDate} AND #{chartEndDate}
|
|
|
+ <if test="companyId != null">
|
|
|
+ and l.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ GROUP BY date_range
|
|
|
+ ORDER BY date_range;
|
|
|
+ </select>
|
|
|
+ <select id="getCompanyPreviousData" resultType="com.fs.live.vo.TrendDataVO">
|
|
|
+ SELECT
|
|
|
+ SUM(ld.page_views) AS prevViews,
|
|
|
+ SUM(ld.unique_visitors) AS prevVisitors,
|
|
|
+ COUNT(l.live_id) AS prevStreams,
|
|
|
+ SUM(ld.total_views) AS prevPv,
|
|
|
+ SUM(ld.unique_viewers) AS prevUv
|
|
|
+ FROM live_data ld
|
|
|
+ LEFT JOIN live l ON ld.live_id = l.live_id
|
|
|
+ WHERE DATE(l.start_time) BETWEEN #{prevStartDate} AND #{prevStartDate}
|
|
|
+ <if test="companyId != null">
|
|
|
+ and l.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ ;
|
|
|
+ </select>
|
|
|
|
|
|
<insert id="insertLiveData" parameterType="LiveData">
|
|
|
insert into live_data
|