Add currency statistics
This commit is contained in:
parent
368d05349a
commit
8dc24a7763
3 changed files with 60 additions and 8 deletions
|
@ -13,12 +13,21 @@ const currencyExchange = new Map([
|
|||
["AUD", 0.63],
|
||||
["BRL", 0.17],
|
||||
["CAD", 0.7],
|
||||
["CZK", 0.045],
|
||||
["CHF", 1.13],
|
||||
["DKK", 0.15],
|
||||
["EUR", 1.08],
|
||||
["GBP", 1.3],
|
||||
["HKD", 0.13],
|
||||
["HUF", 0.0028],
|
||||
["ILS", 0.27],
|
||||
["MXN", 0.05],
|
||||
["JPY", 0.0067],
|
||||
["NOK", 0.1],
|
||||
["NZD", 0.57],
|
||||
["PLN", 0.27],
|
||||
["SEK", 0.1],
|
||||
["SGD", 0.76],
|
||||
["USD", 1],
|
||||
])
|
||||
const currencies = [...currencyExchange.keys()]
|
||||
|
@ -32,7 +41,7 @@ pugSync.beforeInclude("includes/layout.pug", async (from, event, locals) => {
|
|||
pugSync.beforeInclude("includes/collection-stats.pug", async (from, event, {account, currency}) => {
|
||||
let displayCurrency = currency || getCookie(event, "bcex-currency") || ""
|
||||
if (!currencyExchange.has(displayCurrency)) displayCurrency = "NZD"
|
||||
const currencyRoundTo = displayCurrency === "JPY" ? 1000 : 10
|
||||
const currencyRoundTo = (currencyExchange.get(displayCurrency) || 1) < 0.01 ? 1000 : 10
|
||||
|
||||
return {
|
||||
count: {
|
||||
|
@ -51,7 +60,8 @@ pugSync.beforeInclude("includes/collection-stats.pug", async (from, event, {acco
|
|||
return (currencyExchange.get(c.currency) || 0.6) * c.price / (currencyExchange.get(displayCurrency) || 1) / currencyRoundTo
|
||||
}).reduce((a, c) => a + c, 0)) * currencyRoundTo,
|
||||
displayCurrency,
|
||||
taste: db.prepare("with popularity (a) as (select avg(also_collected_count) from item WHERE account = ? group by band_url) select sum(iif(a >= 0 and a < 20, 1, 0)) as cold, sum(iif(a >= 20 and a < 200, 1, 0)) as warm, sum(iif(a >= 200 and a < 2000, 1, 0)) as hot, sum(iif(a >= 2000, 1, 0)) as supernova from popularity").raw().get(account)
|
||||
taste: db.prepare("with popularity (a) as (select avg(also_collected_count) from item WHERE account = ? group by band_url) select sum(iif(a >= 0 and a < 20, 1, 0)) as cold, sum(iif(a >= 20 and a < 200, 1, 0)) as warm, sum(iif(a >= 200 and a < 2000, 1, 0)) as hot, sum(iif(a >= 2000, 1, 0)) as supernova from popularity").raw().get(account),
|
||||
currencies: db.prepare("select currency, count(*) as count from (select currency, band_url from item where account = ? group by band_url) group by currency order by count desc").raw().all(account)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue