Procházet zdrojové kódy

web端直播数据调整

沈静伟 před 4 roky
rodič
revize
c22f7c014f

+ 2 - 7
src/dsb/com/cnd3b/restcontroller/customer/live/SQL/观看人数.sql

@@ -1,7 +1,2 @@
-SELECT SUM
-           (t1.num) as num
-FROM (
-         SELECT isnull(mobileuniqueviewer,0) + isnull(pcuniqueviewer,0) AS num
-         FROM tlive_data
-         WHERE channelid = $channelid$
-     ) AS t1
+--Ö±²¥¼ä¹Û¿´×ÜÈËÊý
+select count(distinct param1)as num from tlive_viewlog where channelid=$channelid$

+ 1 - 7
src/dsb/com/cnd3b/restcontroller/customer/live/SQL/观看时长.sql

@@ -1,7 +1 @@
-SELECT SUM
-           (t1.num) as num
-FROM (
-         SELECT isnull(PCPLAYDURATION,0) + isnull(MOBILEPLAYDURATION,0) AS num
-         FROM tlive_data
-         WHERE channelid = $channelid$
-     ) AS t1
+select CEILING(sum(playduration)/60) as num from tlive_viewlog where channelid = $channelid$

+ 1 - 7
src/dsb/com/cnd3b/restcontroller/customer/live/SQL/观看次数.sql

@@ -1,7 +1 @@
-SELECT SUM
-           (t1.num) as num
-FROM (
-         SELECT isnull(PCVIDEOVIEW,0) + isnull(MOBILEVIDEOVIEW,0) AS num
-         FROM tlive_data
-         WHERE channelid = $channelid$
-     ) AS t1
+select count(0)as num from tlive_viewlog where channelid=$channelid$

+ 20 - 20
src/dsb/com/cnd3b/restcontroller/customer/live/live.java

@@ -121,18 +121,18 @@ public class live extends Controller {
         String channelid = content.getString("channelid");
         JSONObject resultObject = new JSONObject();
         //观看次数(次)
-        double viewCounts = getCount("观看次数", "num", channelid);
-        resultObject.put("viewCounts", String.format("%.2f", viewCounts));
+        long viewCounts = getCount("观看次数", "num", channelid);
+        resultObject.put("viewCounts", viewCounts);
         //观看时长(分钟)
-        double viewDuration = getCount("观看时长", "num", channelid);
-        resultObject.put("viewDuration", String.format("%.2f", viewDuration));
+        long viewDuration = getCount("观看时长", "num", channelid);
+        resultObject.put("viewDuration", viewDuration);
         //观看人数(人)
-        double viewers = getCount("观看人数", "num", channelid);
-        resultObject.put("viewers", String.format("%.2f", viewers));
+        long viewers = getCount("观看人数", "num", channelid);
+        resultObject.put("viewers", viewers);
         //人均观看次数(次)
-        resultObject.put("viewCountsAvg", String.format("%.2f", viewers == 0.0 ? 0 : viewCounts / viewers));
+        resultObject.put("viewCountsAvg", viewers == 0 ? 0 : viewCounts / viewers);
         //人均观看时长(分钟)
-        resultObject.put("viewDurationAvg", String.format("%.2f", viewers == 0.0 ? 0 : viewDuration / viewers));
+        resultObject.put("viewDurationAvg", viewers == 0 ? 0 : viewDuration / viewers);
 
         return getSucReturnObject().setData(resultObject).toString();
     }
@@ -180,7 +180,7 @@ public class live extends Controller {
         String channelid = content.getString("channelid");
         String sessionid = content.getString("sessionid");
 
-        SQLFactory sqlFactory = new SQLFactory(this, "直播用户观看列表",pageSize,pageNumber,"t1.createdtime");
+        SQLFactory sqlFactory = new SQLFactory(this, "直播用户观看列表", pageSize, pageNumber, "t1.createdtime");
         sqlFactory.addParameter("channelid", channelid);
         sqlFactory.addParameter("sessionid", sessionid);
         Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
@@ -236,18 +236,18 @@ public class live extends Controller {
         String channelid = content.getString("channelid");
         JSONObject resultObject = new JSONObject();
         //观看次数(次)
-        double viewCounts = getCount("观看次数", "num", channelid);
-        resultObject.put("viewCounts", String.format("%.2f", viewCounts));
+        long viewCounts = getCount("观看次数", "num", channelid);
+        resultObject.put("viewCounts", viewCounts);
         //观看时长(分钟)
-        double viewDuration = getCount("观看时长", "num", channelid);
-        resultObject.put("viewDuration", String.format("%.2f", viewDuration));
+        long viewDuration = getCount("观看时长", "num", channelid);
+        resultObject.put("viewDuration", viewDuration);
         //观看人数(人)
-        double viewers = getCount("观看人数", "num", channelid);
-        resultObject.put("viewers", String.format("%.2f", viewers));
+        long viewers = getCount("观看人数", "num", channelid);
+        resultObject.put("viewers", viewers);
         //人均观看次数(次)
-        resultObject.put("viewCountsAvg", String.format("%.2f", viewers == 0.0 ? 0 : viewCounts / viewers));
+        resultObject.put("viewCountsAvg", viewers == 0 ? 0 : viewCounts / viewers);
         //人均观看时长(分钟)
-        resultObject.put("viewDurationAvg", String.format("%.2f", viewers == 0.0 ? 0 : viewDuration / viewers));
+        resultObject.put("viewDurationAvg", viewers == 0 ? 0 : viewDuration / viewers);
 
         return getSucReturnObject().setData(resultObject).toString();
     }
@@ -295,7 +295,7 @@ public class live extends Controller {
         String channelid = content.getString("channelid");
         String sessionid = content.getString("sessionid");
 
-        SQLFactory sqlFactory = new SQLFactory(this, "私域直播用户观看列表",pageSize,pageNumber,"t1.createdtime");
+        SQLFactory sqlFactory = new SQLFactory(this, "私域直播用户观看列表", pageSize, pageNumber, "t1.createdtime");
         sqlFactory.addParameter("channelid", channelid);
         sqlFactory.addParameter("sessionid", sessionid);
         Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
@@ -349,10 +349,10 @@ public class live extends Controller {
      * @param fieldname    取数据的字段名称
      * @return
      */
-    public double getCount(String SQLMODELNAME, String fieldname, String channelid) {
+    public long getCount(String SQLMODELNAME, String fieldname, String channelid) {
         SQLFactory sqlFactory = new SQLFactory(this, SQLMODELNAME);
         sqlFactory.addParameter("channelid", channelid);
         Rows rows = sqlFactory.runSqlQuery();
-        return rows.isEmpty() ? 0 : rows.get(0).getDouble(fieldname);
+        return rows.isEmpty() ? 0 : rows.get(0).getLong(fieldname);
     }
 }