binancePrices
continuous-integration/drone/push Build is passing Details

master
dustoair 3 years ago
parent eb7553d5e0
commit 8025700010

@ -3,6 +3,7 @@ package api
import ( import (
"WechatGateWay/global" "WechatGateWay/global"
"github.com/jinzhu/gorm" "github.com/jinzhu/gorm"
"log"
) )
/* /*
@ -26,12 +27,14 @@ func GetBinanceLatestPrice(symbol string) float64 {
func GetBinanceLatestPrices(symbol string) []BinancePrice { func GetBinanceLatestPrices(symbol string) []BinancePrice {
var binancePrices []BinancePrice var binancePrices []BinancePrice
global.DB.Where("symbol = ? order by id desc", symbol).Limit(30).Find(&binancePrices) global.DB.Where("symbol = ? order by id desc", symbol).Find(&binancePrices)
//global.DB.Where("symbol = ? order by id desc", symbol).Limit(30).Find(&binancePrices)
return binancePrices return binancePrices
} }
func GetSerivers(symbol string) (timeUpdate []string, symbolPrice []float64) { func GetSerivers(symbol string) (timeUpdate []string, symbolPrice []float64) {
binancePrices := GetBinanceLatestPrices(symbol) binancePrices := GetBinanceLatestPrices(symbol)
log.Println("binancePrices: ", len(binancePrices))
for _, binancePrice := range binancePrices { for _, binancePrice := range binancePrices {
timeUpdate = append(timeUpdate, binancePrice.UpdatedAt.Format("2006-01-02 15:04:05")) timeUpdate = append(timeUpdate, binancePrice.UpdatedAt.Format("2006-01-02 15:04:05"))
symbolPrice = append(symbolPrice, binancePrice.Price) symbolPrice = append(symbolPrice, binancePrice.Price)

Loading…
Cancel
Save