diff --git a/goserver/count_tag.go b/goserver/count_tag.go
index a6e09c2..531da8f 100644
--- a/goserver/count_tag.go
+++ b/goserver/count_tag.go
@@ -91,14 +91,9 @@ func countTagInfo(cxt *gin.Context, ret func(cxt *gin.Context, cw *tagcounter))
})
var other = &taginfo{Name: "Other...", Value: 0}
- var i = 0
+
for _, v := range cw.CountWord {
- if i <= 99 {
- heap.Put(v)
- } else {
- break
- }
- i++
+ heap.Put(v)
}
if heap.Size() == 0 {
@@ -106,15 +101,18 @@ func countTagInfo(cxt *gin.Context, ret func(cxt *gin.Context, cw *tagcounter))
return
}
- // heap.Put(other)
- cw.PQueue = heap.Values()
+ for i := 0; i <= 100; i++ {
+ if v, ok := heap.Pop(); ok {
+ cw.PQueue = append(cw.PQueue, v)
+ }
+ }
+
other.Value = cw.PQueue[len(cw.PQueue)-1].(*taginfo).Value - 1
if other.Value == 0 {
other.Value = 1
}
cw.PQueue = append(cw.PQueue, other)
- // cxt.JSON(200, cw.PQueue)
ret(cxt, cw)
cw.LastTime = time.Now()
tagCounter.Store(platform, cw)
diff --git a/goserver/main.go b/goserver/main.go
index 4a1a71d..40dc0ab 100644
--- a/goserver/main.go
+++ b/goserver/main.go
@@ -4,6 +4,7 @@ import (
"database/sql"
"encoding/json"
"fmt"
+ "log"
"net/http"
"strconv"
"strings"
@@ -93,20 +94,37 @@ func Query(cxt *gin.Context, platform string) {
cxt.Error(err)
return
}
- if psize > 100 {
- cxt.Error(fmt.Errorf("page size <= 100"))
+ if psize > 5000 {
+ cxt.Error(fmt.Errorf("page size <= 5000"))
return
}
+ // filter := cxt.Query("filter")
+ orderfield := cxt.Query("orderfield")
+ ordertype := cxt.Query("ordertype")
+
+ log.Println(orderfield, ordertype)
+
start := (page - 1) * psize
// end := start + 200
- ssql := fmt.Sprintf(SqlQuery, platform, strconv.Itoa(start), strconv.Itoa(psize))
+ var orderstr string
+ switch ordertype {
+ case "ascend":
+ orderstr = fmt.Sprintf("ORDER BY %s ASC", orderfield)
+ case "descend":
+ orderstr = fmt.Sprintf("ORDER BY %s DESC", orderfield)
+ default:
+ orderstr = ""
+ }
+
+ ssql := fmt.Sprintf(SqlQuery, platform, orderstr, strconv.Itoa(start), strconv.Itoa(psize))
rows, err := StoreStreamer.Query(ssql)
if err != nil {
cxt.Error(err)
return
}
+
var ots []*ObjectQuery
for rows.Next() {
ot := &ObjectQuery{}
diff --git a/goserver/main_test.go b/goserver/main_test.go
index 08f1544..0389833 100644
--- a/goserver/main_test.go
+++ b/goserver/main_test.go
@@ -42,3 +42,39 @@ func estCountTag(t *testing.T) {
}
}
+
+func estDupTag(t *testing.T) {
+ querysql := "select uid, tags from streamer where tags is not null"
+ rows, err := StoreStreamer.Query(querysql)
+ if err != nil {
+ panic(err)
+ }
+ for rows.Next() {
+ var uid int64
+ var tagsbuf []byte
+ var tags []string
+ rows.Scan(&uid, &tagsbuf)
+ json.Unmarshal(tagsbuf, &tags)
+ if len(tags) > 0 {
+ var newtags []string
+ m := make(map[string]int)
+ for _, t := range tags {
+ if _, ok := m[t]; !ok {
+ newtags = append(newtags, t)
+ m[t] = 1
+ } else {
+ m[t]++
+ }
+ }
+ if len(newtags) != len(tags) {
+ t.Error(uid, tags)
+ newtagsbuf, err := json.Marshal(newtags)
+ if err == nil {
+ StoreStreamer.Exec("update streamer set tags = ? where uid = ?", newtagsbuf, uid)
+ } else {
+ panic(err)
+ }
+ }
+ }
+ }
+}
diff --git a/goserver/var_sql.go b/goserver/var_sql.go
index 64f5c23..37b97de 100644
--- a/goserver/var_sql.go
+++ b/goserver/var_sql.go
@@ -27,8 +27,8 @@ FROM
intimate_extractor.streamer
WHERE
platform = "%s"
- AND operator = 0
- AND latest_log_uid is not NULL limit %s,%s) ie
+ AND operator = 0
+ AND latest_log_uid is not NULL ) ie
JOIN intimate_extractor.collect_log cl
WHERE
-ie.latest_log_uid = cl.log_uid; `
+ie.latest_log_uid = cl.log_uid %s limit %s,%s;`
diff --git a/src/ChartsCount.js b/src/ChartsCount.js
index 5ce7597..d0968fe 100644
--- a/src/ChartsCount.js
+++ b/src/ChartsCount.js
@@ -29,7 +29,7 @@ function parseData(cw = {}) {
return b.value - a.value
})
- for (var i = 0; i < seriesData.length; i++) {
+ for (i = 0; i < seriesData.length; i++) {
var o = seriesData[i];
legendData.push(o.name);
selected[o.name] = i <= 20;
diff --git a/src/Table.js b/src/Table.js
index 85045b8..da3dd22 100644
--- a/src/Table.js
+++ b/src/Table.js
@@ -5,78 +5,7 @@ import apihost from './Var';
const { Option } = Select;
-const columns = [
- {
- title: '平台',
- dataIndex: 'Platform',
- editable: false,
- key: 'Platform',
- // width: "8%",
- },
- {
- title: 'userid',
- dataIndex: 'UserId',
- editable: false,
- key: 'UserId',
- // width: "7%",
- },
- {
- title: '名称',
- dataIndex: 'UserName',
- editable: false,
- key: 'UserName',
- // width: "7%",
- },
- {
- title: '标签',
- dataIndex: 'Tags',
- editable: false,
- render: tags => (
- <>
- {
- tags != null ?
- tags.map(tag => {
- let color = "purple";
- if (tag.length < 3) {
- color = 'green';
- } else if (tag.length < 6) {
- color = 'geekblue';
- } else if (tag.length < 9) {
- color = 'volcano';
- }
- return (
-