You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
794 B
32 lines
794 B
package models |
|
|
|
import ( |
|
"server/common" |
|
"server/db" |
|
"server/util" |
|
|
|
"github.com/olivere/elastic/v7" |
|
) |
|
|
|
func GetOutputData(su, eu int64, cid, uid int) map[string]string { |
|
ret := map[string]string{} |
|
q := elastic.NewBoolQuery() |
|
if su > 0 { |
|
q.Filter(elastic.NewRangeQuery("time").Gte(su)) |
|
} |
|
if eu > 0 { |
|
q.Filter(elastic.NewRangeQuery("time").Lt(eu)) |
|
} |
|
if cid > 0 { |
|
q.Filter(elastic.NewTermsQuery("channel_id", cid)) |
|
} |
|
if uid > 0 { |
|
q.Filter(elastic.NewTermQuery("uid", uid)) |
|
} |
|
buk := &common.GroupSumBuckets{} |
|
db.ES().GroupSumBy(common.ESIndexBalance, "event", q, buk, "", false, 0, "value") |
|
for _, v := range buk.Buckets { |
|
ret[common.GetCurrencyTypeName(common.CurrencyEvent(util.GetInt(v.Key)))] = util.RoundFloat(v.Value.Value/common.DecimalDigits, 2) |
|
} |
|
return ret |
|
}
|
|
|