Rename Stocks to Markets
Also fix bug that would remove markets if a network request failed and not show them again until Glance was restarted
This commit is contained in:
parent
d2f5dbbc26
commit
1bebb88d0e
9 changed files with 74 additions and 68 deletions
|
|
@ -85,20 +85,24 @@ var currencyToSymbol = map[string]string{
|
|||
"PHP": "₱",
|
||||
}
|
||||
|
||||
type Stock struct {
|
||||
Name string `yaml:"name"`
|
||||
Symbol string `yaml:"symbol"`
|
||||
ChartLink string `yaml:"chart-link"`
|
||||
SymbolLink string `yaml:"symbol-link"`
|
||||
type MarketRequest struct {
|
||||
Name string `yaml:"name"`
|
||||
Symbol string `yaml:"symbol"`
|
||||
ChartLink string `yaml:"chart-link"`
|
||||
SymbolLink string `yaml:"symbol-link"`
|
||||
}
|
||||
|
||||
type Market struct {
|
||||
MarketRequest
|
||||
Currency string `yaml:"-"`
|
||||
Price float64 `yaml:"-"`
|
||||
PercentChange float64 `yaml:"-"`
|
||||
SvgChartPoints string `yaml:"-"`
|
||||
}
|
||||
|
||||
type Stocks []Stock
|
||||
type Markets []Market
|
||||
|
||||
func (t Stocks) SortByAbsChange() {
|
||||
func (t Markets) SortByAbsChange() {
|
||||
sort.Slice(t, func(i, j int) bool {
|
||||
return math.Abs(t[i].PercentChange) > math.Abs(t[j].PercentChange)
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue