add: duplicate tags
add: field sorted fix: head 100 sorted sql
This commit is contained in:
parent
e91995fc65
commit
524daccaf3
|
@ -91,14 +91,9 @@ func countTagInfo(cxt *gin.Context, ret func(cxt *gin.Context, cw *tagcounter))
|
||||||
})
|
})
|
||||||
|
|
||||||
var other = &taginfo{Name: "Other...", Value: 0}
|
var other = &taginfo{Name: "Other...", Value: 0}
|
||||||
var i = 0
|
|
||||||
for _, v := range cw.CountWord {
|
for _, v := range cw.CountWord {
|
||||||
if i <= 99 {
|
|
||||||
heap.Put(v)
|
heap.Put(v)
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
i++
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if heap.Size() == 0 {
|
if heap.Size() == 0 {
|
||||||
|
@ -106,15 +101,18 @@ func countTagInfo(cxt *gin.Context, ret func(cxt *gin.Context, cw *tagcounter))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// heap.Put(other)
|
for i := 0; i <= 100; i++ {
|
||||||
cw.PQueue = heap.Values()
|
if v, ok := heap.Pop(); ok {
|
||||||
|
cw.PQueue = append(cw.PQueue, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
other.Value = cw.PQueue[len(cw.PQueue)-1].(*taginfo).Value - 1
|
other.Value = cw.PQueue[len(cw.PQueue)-1].(*taginfo).Value - 1
|
||||||
if other.Value == 0 {
|
if other.Value == 0 {
|
||||||
other.Value = 1
|
other.Value = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
cw.PQueue = append(cw.PQueue, other)
|
cw.PQueue = append(cw.PQueue, other)
|
||||||
// cxt.JSON(200, cw.PQueue)
|
|
||||||
ret(cxt, cw)
|
ret(cxt, cw)
|
||||||
cw.LastTime = time.Now()
|
cw.LastTime = time.Now()
|
||||||
tagCounter.Store(platform, cw)
|
tagCounter.Store(platform, cw)
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -93,20 +94,37 @@ func Query(cxt *gin.Context, platform string) {
|
||||||
cxt.Error(err)
|
cxt.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if psize > 100 {
|
if psize > 5000 {
|
||||||
cxt.Error(fmt.Errorf("page size <= 100"))
|
cxt.Error(fmt.Errorf("page size <= 5000"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// filter := cxt.Query("filter")
|
||||||
|
orderfield := cxt.Query("orderfield")
|
||||||
|
ordertype := cxt.Query("ordertype")
|
||||||
|
|
||||||
|
log.Println(orderfield, ordertype)
|
||||||
|
|
||||||
start := (page - 1) * psize
|
start := (page - 1) * psize
|
||||||
// end := start + 200
|
// 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)
|
rows, err := StoreStreamer.Query(ssql)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cxt.Error(err)
|
cxt.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var ots []*ObjectQuery
|
var ots []*ObjectQuery
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
ot := &ObjectQuery{}
|
ot := &ObjectQuery{}
|
||||||
|
|
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ FROM
|
||||||
WHERE
|
WHERE
|
||||||
platform = "%s"
|
platform = "%s"
|
||||||
AND operator = 0
|
AND operator = 0
|
||||||
AND latest_log_uid is not NULL limit %s,%s) ie
|
AND latest_log_uid is not NULL ) ie
|
||||||
JOIN intimate_extractor.collect_log cl
|
JOIN intimate_extractor.collect_log cl
|
||||||
WHERE
|
WHERE
|
||||||
ie.latest_log_uid = cl.log_uid; `
|
ie.latest_log_uid = cl.log_uid %s limit %s,%s;`
|
||||||
|
|
|
@ -29,7 +29,7 @@ function parseData(cw = {}) {
|
||||||
return b.value - a.value
|
return b.value - a.value
|
||||||
})
|
})
|
||||||
|
|
||||||
for (var i = 0; i < seriesData.length; i++) {
|
for (i = 0; i < seriesData.length; i++) {
|
||||||
var o = seriesData[i];
|
var o = seriesData[i];
|
||||||
legendData.push(o.name);
|
legendData.push(o.name);
|
||||||
selected[o.name] = i <= 20;
|
selected[o.name] = i <= 20;
|
||||||
|
|
255
src/Table.js
255
src/Table.js
|
@ -5,19 +5,147 @@ import apihost from './Var';
|
||||||
|
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
|
|
||||||
const columns = [
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class DataTable extends React.Component {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
state = {
|
||||||
|
data: [],
|
||||||
|
platform: "openrec",
|
||||||
|
pagination: {
|
||||||
|
current: 1,
|
||||||
|
pageSize: 20,
|
||||||
|
position: ["topLeft"],
|
||||||
|
},
|
||||||
|
loading: false,
|
||||||
|
filters: null,
|
||||||
|
sorter: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
expandedRow = (record) => {
|
||||||
|
|
||||||
|
const ecolumns = [
|
||||||
|
{
|
||||||
|
title: 'uid',
|
||||||
|
dataIndex: 'Uid',
|
||||||
|
key: 'Uid',
|
||||||
|
dataField:'uid',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '直播地址',
|
||||||
|
dataIndex: 'LiveUrl',
|
||||||
|
key: 'LiveUrl',
|
||||||
|
dataField: 'live_url'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '直播标题',
|
||||||
|
dataIndex: 'LiveTitle',
|
||||||
|
key: 'LiveTitle',
|
||||||
|
dataField:'live_title',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '近直播开始时间',
|
||||||
|
dataIndex: 'LiveStartTime',
|
||||||
|
key: 'LiveStartTime',
|
||||||
|
dataField:'live_start_time',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '近直播结束时间',
|
||||||
|
dataIndex: 'LiveEndTime',
|
||||||
|
key: 'LiveEndTime',
|
||||||
|
dataField:'live_end_time',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
var data = [record];
|
||||||
|
return <Table rowClassName="subtable" size="small" bordered={true} columns={ecolumns} dataSource={data} pagination={false} />;
|
||||||
|
};
|
||||||
|
|
||||||
|
updatePlatform(p) {
|
||||||
|
|
||||||
|
const { pagination, sorter, filters } = this.state;
|
||||||
|
console.log("filters", filters); // ${filters?`&filters=${filters}`:""}
|
||||||
|
console.log("sorter", sorter);
|
||||||
|
pagination.current = 1;
|
||||||
|
this.setState({ platform: p }, () => {
|
||||||
|
this.fetchapi({
|
||||||
|
pagination,
|
||||||
|
sorter,
|
||||||
|
filters
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
const { platform } = this.state;
|
||||||
|
this.updatePlatform(platform);
|
||||||
|
}
|
||||||
|
|
||||||
|
handleTableChange = (pagination, filters, sorter) => {
|
||||||
|
|
||||||
|
this.fetchapi({
|
||||||
|
pagination,
|
||||||
|
sorter,
|
||||||
|
filters,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
fetchapi = (params = {}) => {
|
||||||
|
|
||||||
|
const { pagination, sorter, filters } = params;
|
||||||
|
const { platform, } = this.state;
|
||||||
|
this.setState({ loading: true });
|
||||||
|
console.log("filters", filters); // ${filters?`&filters=${filters}`:""}
|
||||||
|
console.log("sorter", sorter);
|
||||||
|
fetch(`${apihost}/${platform}/query?page=${pagination.current}&psize=${pagination.pageSize}${sorter?`&orderfield=${sorter.column?sorter.column.dataField:""}&ordertype=${sorter.order}`:""}`, { mode: "cors" }).then((response) => {
|
||||||
|
// console.log(response);
|
||||||
|
response.json().then(
|
||||||
|
(data) => {
|
||||||
|
var result = JSON.parse(data)
|
||||||
|
this.setState({
|
||||||
|
loading: false,
|
||||||
|
data: result.Data ? result.Data : [],
|
||||||
|
pagination: {
|
||||||
|
...params.pagination,
|
||||||
|
total: 100000,
|
||||||
|
},
|
||||||
|
filters: filters,
|
||||||
|
sorter: sorter
|
||||||
|
});
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
|
||||||
|
let { data, pagination, loading, sorter, filters } = this.state;
|
||||||
|
sorter = sorter || {};
|
||||||
|
filters = filters || {};
|
||||||
|
|
||||||
|
const columns = [
|
||||||
{
|
{
|
||||||
title: '平台',
|
title: '平台',
|
||||||
dataIndex: 'Platform',
|
dataIndex: 'Platform',
|
||||||
editable: false,
|
editable: false,
|
||||||
key: 'Platform',
|
key: 'Platform',
|
||||||
// width: "8%",
|
// width: "8%",
|
||||||
|
dataField: 'platform',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'userid',
|
title: 'userid',
|
||||||
dataIndex: 'UserId',
|
dataIndex: 'UserId',
|
||||||
editable: false,
|
editable: false,
|
||||||
key: 'UserId',
|
key: 'UserId',
|
||||||
|
dataField: 'user_id',
|
||||||
// width: "7%",
|
// width: "7%",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -25,12 +153,14 @@ const columns = [
|
||||||
dataIndex: 'UserName',
|
dataIndex: 'UserName',
|
||||||
editable: false,
|
editable: false,
|
||||||
key: 'UserName',
|
key: 'UserName',
|
||||||
|
dataField: 'user_name',
|
||||||
// width: "7%",
|
// width: "7%",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '标签',
|
title: '标签',
|
||||||
dataIndex: 'Tags',
|
dataIndex: 'Tags',
|
||||||
editable: false,
|
editable: false,
|
||||||
|
dataField: 'tags',
|
||||||
render: tags => (
|
render: tags => (
|
||||||
<>
|
<>
|
||||||
{
|
{
|
||||||
|
@ -60,130 +190,35 @@ const columns = [
|
||||||
dataIndex: 'Followers',
|
dataIndex: 'Followers',
|
||||||
key: 'Followers',
|
key: 'Followers',
|
||||||
width: "8%",
|
width: "8%",
|
||||||
|
dataField: 'followers',
|
||||||
|
sorter: (a, b) => a.Followers - b.Followers,
|
||||||
|
// sortOrder: sorter.columnKey === 'Gratuity' && sorter.order,
|
||||||
|
sortDirections: ['descend', 'ascend'],
|
||||||
|
ellipsis: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '礼物数(币|钱)',
|
title: '礼物数(币|钱)',
|
||||||
dataIndex: 'Gratuity',
|
dataIndex: 'Gratuity',
|
||||||
key: 'Gratuity',
|
key: 'Gratuity',
|
||||||
width: "8%",
|
width: "8%",
|
||||||
|
dataField: 'gratuity',
|
||||||
|
// defaultSortOrder: 'ascend',
|
||||||
|
// filterMultiple: false,
|
||||||
|
// onFilter: (value, record)=>{ console.log(record, value) ;return record.Gratuity >= value;},
|
||||||
sorter: (a, b) => a.Gratuity - b.Gratuity,
|
sorter: (a, b) => a.Gratuity - b.Gratuity,
|
||||||
// sortOrder: sortedInfo.columnKey === 'Gratuity' && sortedInfo.order,
|
// sortOrder: sorter.columnKey === 'Gratuity' && sorter.order,
|
||||||
ellipsis: true,
|
sortDirections: ['descend', 'ascend'],
|
||||||
|
ellipsis: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '数据更新时间',
|
title: '数据更新时间',
|
||||||
dataIndex: 'UpdateTime',
|
dataIndex: 'UpdateTime',
|
||||||
key: 'UpdateTime',
|
key: 'UpdateTime',
|
||||||
|
dataField: 'update_time',
|
||||||
// width: "7%",
|
// width: "7%",
|
||||||
},
|
},
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DataTable extends React.Component {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
state = {
|
|
||||||
data: [],
|
|
||||||
platform: "openrec",
|
|
||||||
pagination: {
|
|
||||||
current: 1,
|
|
||||||
pageSize: 20,
|
|
||||||
position: ["topLeft"],
|
|
||||||
},
|
|
||||||
loading: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
expandedRow = (record) => {
|
|
||||||
|
|
||||||
const ecolumns = [
|
|
||||||
{
|
|
||||||
title: 'uid',
|
|
||||||
dataIndex: 'Uid',
|
|
||||||
key: 'Uid',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '直播地址',
|
|
||||||
dataIndex: 'LiveUrl',
|
|
||||||
key: 'LiveUrl',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '直播标题',
|
|
||||||
dataIndex: 'LiveTitle',
|
|
||||||
key: 'LiveTitle',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '近直播开始时间',
|
|
||||||
dataIndex: 'LiveStartTime',
|
|
||||||
key: 'LiveStartTime',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '近直播结束时间',
|
|
||||||
dataIndex: 'LiveEndTime',
|
|
||||||
key: 'LiveEndTime',
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
var data = [record];
|
|
||||||
return <Table rowClassName="subtable" size="small" bordered={true} columns={ecolumns} dataSource={data} pagination={false} />;
|
|
||||||
};
|
|
||||||
|
|
||||||
updatePlatform(p) {
|
|
||||||
|
|
||||||
const { pagination } = this.state;
|
|
||||||
pagination.current = 1;
|
|
||||||
this.setState({ platform: p }, () => {
|
|
||||||
this.fetchapi({
|
|
||||||
pagination
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
const { platform } = this.state;
|
|
||||||
this.updatePlatform(platform);
|
|
||||||
}
|
|
||||||
|
|
||||||
handleTableChange = (pagination, filters, sorter) => {
|
|
||||||
console.log(filters, sorter);
|
|
||||||
this.fetchapi({
|
|
||||||
sortField: sorter.field,
|
|
||||||
sortOrder: sorter.order,
|
|
||||||
pagination,
|
|
||||||
...filters,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
fetchapi = (params = {}) => {
|
|
||||||
this.setState({ loading: true });
|
|
||||||
const { platform, pagination } = this.state;
|
|
||||||
|
|
||||||
fetch(`${apihost}/${platform}/query?page=${pagination.current}&psize=${pagination.pageSize}`, { mode: "cors" }).then((response) => {
|
|
||||||
// console.log(response);
|
|
||||||
response.json().then(
|
|
||||||
(data) => {
|
|
||||||
var result = JSON.parse(data)
|
|
||||||
this.setState({
|
|
||||||
loading: false,
|
|
||||||
data: result.Data ? result.Data : [],
|
|
||||||
pagination: {
|
|
||||||
...params.pagination,
|
|
||||||
total: 100000,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
)
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
|
||||||
|
|
||||||
const { data, pagination, loading } = this.state;
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
|
@ -208,6 +243,8 @@ class DataTable extends React.Component {
|
||||||
</Col>
|
</Col>
|
||||||
</Row> */}
|
</Row> */}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<Table
|
<Table
|
||||||
bordered={true}
|
bordered={true}
|
||||||
size={"middle"}
|
size={"middle"}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
|
|
||||||
var apihost = "http://192.168.31.208:5500"
|
var apihost = "http://192.168.16.130:5500"
|
||||||
|
|
||||||
export default apihost;
|
export default apihost;
|
Loading…
Reference in New Issue
Block a user