Fix issue printing correct currency values in set and card
This commit is contained in:
parent
884fbdf96d
commit
b4f0067b4a
@ -80,7 +80,7 @@ func Cards(rarity, set, sortby, name, oracle, cardType string, reserved, foil bo
|
||||
var sortStage bson.D
|
||||
switch sortby {
|
||||
case "value":
|
||||
if getCurrency() == "EUR" {
|
||||
if getCurrency() == EUR {
|
||||
sortStage = bson.D{{"prices.eur", 1}}
|
||||
} else {
|
||||
sortStage = bson.D{{"prices.usd", 1}}
|
||||
|
||||
@ -5,6 +5,9 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
const EUR = "€"
|
||||
const USD = "$"
|
||||
|
||||
func getMongoDBURI() string {
|
||||
uri := os.Getenv("MONGODB_URI")
|
||||
if uri == "" {
|
||||
@ -19,13 +22,11 @@ func getMongoDBURI() string {
|
||||
func getCurrency() string {
|
||||
switch os.Getenv("SERRA_CURRENCY") {
|
||||
case "EUR":
|
||||
return "€"
|
||||
return EUR
|
||||
case "USD":
|
||||
return USD
|
||||
default:
|
||||
LogMessage("Warning: You did not configure SERRA_CURRENCY. Assuming \"USD\"", "yellow")
|
||||
return "$"
|
||||
}
|
||||
|
||||
// default
|
||||
LogMessage("Warning: You did not configure SERRA_CURRENCY. Assuming \"USD\"", "yellow")
|
||||
|
||||
return "USD"
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ func Gains(limit float64, sort int) error {
|
||||
}
|
||||
|
||||
currencyField := "$serra_prices.usd"
|
||||
if getCurrency() == "EUR" {
|
||||
if getCurrency() == EUR {
|
||||
currencyField = "$serra_prices.eur"
|
||||
}
|
||||
|
||||
|
||||
@ -167,14 +167,16 @@ func showPriceHistory(prices []PriceEntry, prefix string, total bool) {
|
||||
|
||||
var value float64
|
||||
if total {
|
||||
value = e.Usd + e.UsdFoil + e.UsdEtched
|
||||
if getCurrency() == "EUR" {
|
||||
if getCurrency() == EUR {
|
||||
value = e.Eur + e.EurFoil
|
||||
} else {
|
||||
value = e.Usd + e.UsdFoil
|
||||
}
|
||||
} else {
|
||||
value = e.Usd
|
||||
if getCurrency() == "EUR" {
|
||||
if getCurrency() == EUR {
|
||||
value = e.Eur
|
||||
} else {
|
||||
value = e.Usd
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -119,7 +119,7 @@ type Card struct {
|
||||
|
||||
// Getter for currency specific value
|
||||
func (c Card) getValue(foil bool) float64 {
|
||||
if getCurrency() == "EUR" {
|
||||
if getCurrency() == EUR {
|
||||
if foil {
|
||||
return c.Prices.EurFoil
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ func ShowSet(setname string) error {
|
||||
|
||||
// fetch all cards in set ordered by currently used currency
|
||||
cardSortCurrency := bson.D{{"prices.usd", -1}}
|
||||
if getCurrency() == "EUR" {
|
||||
if getCurrency() == EUR {
|
||||
cardSortCurrency = bson.D{{"prices.eur", -1}}
|
||||
}
|
||||
cards, err := coll.storageFind(bson.D{{"set", setname}}, cardSortCurrency, 0, 0)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user