mirror of
https://github.com/miguelmota/cointop
synced 2024-11-10 13:10:26 +00:00
Merge branch 'bugfix/range-update-corrupt-cache' of https://github.com/simon-anz/cointop into simon-anz-bugfix/range-update-corrupt-cache
This commit is contained in:
commit
2c7f7039fd
@ -189,8 +189,10 @@ func (ct *Cointop) PortfolioChart() error {
|
|||||||
chart := chartplot.NewChartPlot()
|
chart := chartplot.NewChartPlot()
|
||||||
chart.SetHeight(ct.State.chartHeight)
|
chart.SetHeight(ct.State.chartHeight)
|
||||||
|
|
||||||
rangeseconds := ct.chartRangesMap[ct.State.selectedChartRange]
|
convert := ct.State.currencyConversion // cache here
|
||||||
if ct.State.selectedChartRange == "YTD" {
|
selectedChartRange := ct.State.selectedChartRange // cache here
|
||||||
|
rangeseconds := ct.chartRangesMap[selectedChartRange]
|
||||||
|
if selectedChartRange == "YTD" {
|
||||||
ytd := time.Now().Unix() - int64(timeutil.BeginningOfYear().Unix())
|
ytd := time.Now().Unix() - int64(timeutil.BeginningOfYear().Unix())
|
||||||
rangeseconds = time.Duration(ytd) * time.Second
|
rangeseconds = time.Duration(ytd) * time.Second
|
||||||
}
|
}
|
||||||
@ -216,7 +218,7 @@ func (ct *Cointop) PortfolioChart() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var graphData []float64
|
var graphData []float64
|
||||||
cachekey := strings.ToLower(fmt.Sprintf("%s_%s", p.Symbol, strings.Replace(ct.State.selectedChartRange, " ", "", -1)))
|
cachekey := strings.ToLower(fmt.Sprintf("%s_%s_%s", p.Symbol, convert, strings.Replace(selectedChartRange, " ", "", -1)))
|
||||||
cached, found := ct.cache.Get(cachekey)
|
cached, found := ct.cache.Get(cachekey)
|
||||||
if found {
|
if found {
|
||||||
// cache hit
|
// cache hit
|
||||||
@ -230,7 +232,6 @@ func (ct *Cointop) PortfolioChart() error {
|
|||||||
if len(graphData) == 0 {
|
if len(graphData) == 0 {
|
||||||
time.Sleep(2 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
|
|
||||||
convert := ct.State.currencyConversion
|
|
||||||
apiGraphData, err := ct.api.GetCoinGraphData(convert, p.Symbol, p.Name, start, end)
|
apiGraphData, err := ct.api.GetCoinGraphData(convert, p.Symbol, p.Name, start, end)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user