diff --git a/backend/db/index.ts b/backend/db/index.ts index 1f69bfd..458b13a 100644 --- a/backend/db/index.ts +++ b/backend/db/index.ts @@ -14,16 +14,16 @@ import { sqlExchangeRates, sqlFutureOutagesPerArea, sqlGeneration, + sqlGenerationAnyInterval, sqlGroupBy, + sqlLatestGenerationInterval, + sqlLatestLoadInterval, sqlLatestPricePerArea, sqlLatestPricePerCountry, - sqlLatestLoadInterval, - sqlLatestGenerationInterval, sqlLoad, - sqlLoadAnyInterval, sqlLoadAndGeneration, + sqlLoadAnyInterval, sqlRaw, - sqlGenerationAnyInterval, } from "backend/db/sql/index.ts"; import { DataCache } from "utils/datacache.ts"; import { log } from "utils/log.ts"; diff --git a/backend/db/sql/index.ts b/backend/db/sql/index.ts index e9fae21..660d59d 100644 --- a/backend/db/sql/index.ts +++ b/backend/db/sql/index.ts @@ -438,14 +438,14 @@ export { sqlExchangeRates, sqlFutureOutagesPerArea, sqlGeneration, + sqlGenerationAnyInterval, sqlGroupBy, + sqlLatestGenerationInterval, + sqlLatestLoadInterval, sqlLatestPricePerArea, sqlLatestPricePerCountry, - sqlLatestLoadInterval, - sqlLatestGenerationInterval, sqlLoad, - sqlLoadAnyInterval, sqlLoadAndGeneration, + sqlLoadAnyInterval, sqlRaw, - sqlGenerationAnyInterval, }; diff --git a/backend/scheduler/jobs/daily.currencyupdate.ts b/backend/scheduler/jobs/daily.currencyupdate.ts index 9a3b0fd..db47c3b 100644 --- a/backend/scheduler/jobs/daily.currencyupdate.ts +++ b/backend/scheduler/jobs/daily.currencyupdate.ts @@ -40,8 +40,6 @@ const DailyCurrencyUpdate = async () => { log("info", `Scheduled data update done`); tm.emit("spotweb-main", "clear_cache", { cache: "exrate" }); - //tm.emit("spotweb-main-2", "clear_cache", { cache: "exrate" }); - //tm.emit("spotweb-main-3", "clear_cache", { cache: "exrate" }); database.close(); diff --git a/backend/scheduler/jobs/daily.outageupdate.ts b/backend/scheduler/jobs/daily.outageupdate.ts index 8328f1b..6d99bc5 100644 --- a/backend/scheduler/jobs/daily.outageupdate.ts +++ b/backend/scheduler/jobs/daily.outageupdate.ts @@ -98,8 +98,6 @@ const DailyOutageUpdate = async () => { log("info", `Scheduled data update done`); tm.emit("spotweb-main", "clear_cache", { cache: "outage" }); - //tm.emit("spotweb-main-2", "clear_cache", { cache: "outage" }); - //tm.emit("spotweb-main-3", "clear_cache", { cache: "outage" }); database.close(); diff --git a/backend/scheduler/jobs/daily.priceupdate.ts b/backend/scheduler/jobs/daily.priceupdate.ts index 4eccd5b..47f9e85 100644 --- a/backend/scheduler/jobs/daily.priceupdate.ts +++ b/backend/scheduler/jobs/daily.priceupdate.ts @@ -119,8 +119,6 @@ const DailyPriceUpdate = async () => { log("info", `Scheduled data update done`); tm.emit("spotweb-main", "clear_cache", { cache: "spotprices" }); - //tm.emit("spotweb-main-2", "clear_cache", { cache: "spotprices" }); - //tm.emit("spotweb-main-3", "clear_cache", { cache: "spotprices" }); database.close(); diff --git a/backend/scheduler/jobs/hourly.consumptionupdate.ts b/backend/scheduler/jobs/hourly.consumptionupdate.ts index 9335960..ff84646 100644 --- a/backend/scheduler/jobs/hourly.consumptionupdate.ts +++ b/backend/scheduler/jobs/hourly.consumptionupdate.ts @@ -75,17 +75,10 @@ const HourlyConsumptionUpdate = async () => { log("error", `Error occured while updating data, skipping. Error: ${e}`); } - // Clear memory cache - log("info", `Database changed, clearing cache, realm load.`); - log("info", `Scheduled data update done`); tm.emit("spotweb-main", "clear_cache", { cache: "load" }); tm.emit("spotweb-main", "clear_cache", { cache: "generation" }); - //tm.emit("spotweb-main-2", "clear_cache", { cache: "load" }); - //tm.emit("spotweb-main-2", "clear_cache", { cache: "generation" }); - //tm.emit("spotweb-main-3", "clear_cache", { cache: "load" }); - //tm.emit("spotweb-main-3", "clear_cache", { cache: "generation" }); database.close(); diff --git a/backend/scheduler/jobs/hourly.productionupdate.ts b/backend/scheduler/jobs/hourly.productionupdate.ts index e3d6116..741d3f5 100644 --- a/backend/scheduler/jobs/hourly.productionupdate.ts +++ b/backend/scheduler/jobs/hourly.productionupdate.ts @@ -120,10 +120,6 @@ const HourlyProductionUpdate = async () => { tm.emit("spotweb-main", "clear_cache", { cache: "load" }); tm.emit("spotweb-main", "clear_cache", { cache: "generation" }); - //tm.emit("spotweb-main-2", "clear_cache", { cache: "load" }); - //tm.emit("spotweb-main-2", "clear_cache", { cache: "generation" }); - //tm.emit("spotweb-main-3", "clear_cache", { cache: "load" }); - //tm.emit("spotweb-main-3", "clear_cache", { cache: "generation" }); database.close(); diff --git a/deno.json b/deno.json index c255564..a339230 100644 --- a/deno.json +++ b/deno.json @@ -26,7 +26,7 @@ "croner": "jsr:@hexagon/croner@^9.1.0", "entsoe_api_client": "https://deno.land/x/entsoe_api_client@1.0.3/mod.ts", "fresh_seo": "https://deno.land/x/fresh_seo@1.0.1/mod.ts", - "https://deno.land/x/glob_filter@1.0.0/mod.ts": "https://deno.land/x/glob_filter@1.0.1/mod.ts", + "https://deno.land/x/glob_filter@1.0.0/mod.ts": "https://deno.land/x/glob_filter@1.0.1/mod.ts", "islands/": "./islands/", "localekit_fresh": "https://deno.land/x/localekit_fresh@0.5.2/mod.ts", "preact": "https://esm.sh/preact@10.19.6", diff --git a/static/BingSiteAuth.xml b/static/BingSiteAuth.xml index e095dd9..0d6d158 100644 --- a/static/BingSiteAuth.xml +++ b/static/BingSiteAuth.xml @@ -1,4 +1,4 @@ - 061CFD64915789189179DA473A0B64D0 - \ No newline at end of file + 061CFD64915789189179DA473A0B64D0 + diff --git a/static/css/custom.css b/static/css/custom.css index b585017..4347974 100644 --- a/static/css/custom.css +++ b/static/css/custom.css @@ -1,86 +1,86 @@ .bg-color-1 { - background-color: rgba(224, 255, 24, 0.3) !important; + background-color: rgba(224, 255, 24, 0.3) !important; } .bg-color-2 { - background-color: rgba(24, 255, 124, 0.3) !important; + background-color: rgba(24, 255, 124, 0.3) !important; } .bg-color-3 { - background-color: rgb(24 144 255 / 30%) !important; + background-color: rgb(24 144 255 / 30%) !important; } .bg-color-4 { - background-color: rgba(232, 24, 255, 0.3) !important; + background-color: rgba(232, 24, 255, 0.3) !important; } .bg-color-5 { - background-color: rgba(224, 24, 71, 0.3) !important; + background-color: rgba(224, 24, 71, 0.3) !important; } .link-color-1 { - color: rgba(224, 255, 24, 1) !important; + color: rgba(224, 255, 24, 1) !important; } .link-color-2 { - color: rgba(24, 255, 124, 1) !important; + color: rgba(24, 255, 124, 1) !important; } .link-color-3 { - color: rgb(24, 144, 255, 1) !important; + color: rgb(24, 144, 255, 1) !important; } .link-color-4 { - color: rgba(232, 24, 255, 1) !important; + color: rgba(232, 24, 255, 1) !important; } .link-color-5 { - color: rgba(224, 24, 71, 1) !important; + color: rgba(224, 24, 71, 1) !important; } .extra-pad { - padding: 5px !important; + padding: 5px !important; } .hidden { - display: none !important; + display: none !important; } .price-display { - font-size: 6.4rem !important; - color:antiquewhite; - line-height: 6.4rem; - font-family: 'Seven Segment', sans-serif; + font-size: 6.4rem !important; + color: antiquewhite; + line-height: 6.4rem; + font-family: "Seven Segment", sans-serif; } .price-display-48 { - font-size: 4.8rem !important; - color:antiquewhite; - line-height: 4.8rem; - font-family: 'Seven Segment', sans-serif; + font-size: 4.8rem !important; + color: antiquewhite; + line-height: 4.8rem; + font-family: "Seven Segment", sans-serif; } .price-display-24 { - font-size: 2.4rem !important; - color:antiquewhite; - line-height: 2.4rem; + font-size: 2.4rem !important; + color: antiquewhite; + line-height: 2.4rem; } /* Halfmoon customizations */ .on-this-page-nav { - position: fixed; - margin-right: 2rem; - z-index: 20; - background-color: #ffffff; - padding: 0.5rem; - border-radius: 0.4rem; + position: fixed; + margin-right: 2rem; + z-index: 20; + background-color: #ffffff; + padding: 0.5rem; + border-radius: 0.4rem; } /* highlight.js customization */ .hljs { - background-color: #111213 !important; - font-size: 1.1rem; + background-color: #111213 !important; + font-size: 1.1rem; } .hljs::-webkit-scrollbar { - width: 14px; + width: 14px; } .hljs::-webkit-scrollbar-track { - box-shadow: inset 0 0 5px #212223; - border-radius: 2px; + box-shadow: inset 0 0 5px #212223; + border-radius: 2px; } .hljs::-webkit-scrollbar-thumb { - background: #333435; - border-radius: 4px; - padding:3px; + background: #333435; + border-radius: 4px; + padding: 3px; } /* Ads */ .display-height { - max-height: 70px; -} \ No newline at end of file + max-height: 70px; +} diff --git a/static/offline.html b/static/offline.html index 3465756..c566ece 100644 --- a/static/offline.html +++ b/static/offline.html @@ -1,8 +1,8 @@ - - Spotweb - - -

Spotweb is not available offline, try refreshing you browser

- - \ No newline at end of file + + Spotweb + + +

Spotweb is not available offline, try refreshing you browser

+ + diff --git a/utils/common.ts b/utils/common.ts index 370c981..855b188 100644 --- a/utils/common.ts +++ b/utils/common.ts @@ -89,16 +89,23 @@ const formatNumber = ( const decimals = options?.decimals ?? 0; // Map our internal language to a locale tag; fallback to en-US const lang = options?.lang ?? "en"; - const locale = - lang === "sv" ? "sv-SE" : - lang === "nl" ? "nl-NL" : - lang === "no" ? "nb-NO" : - lang === "fi" ? "fi-FI" : - lang === "dk" ? "da-DK" : - lang === "es" ? "es-ES" : - lang === "fr" ? "fr-FR" : - lang === "de" ? "de-DE" : - "en-US"; + const locale = lang === "sv" + ? "sv-SE" + : lang === "nl" + ? "nl-NL" + : lang === "no" + ? "nb-NO" + : lang === "fi" + ? "fi-FI" + : lang === "dk" + ? "da-DK" + : lang === "es" + ? "es-ES" + : lang === "fr" + ? "fr-FR" + : lang === "de" + ? "de-DE" + : "en-US"; try { return new Intl.NumberFormat(locale, { @@ -120,7 +127,7 @@ const formatMW = ( decimals: number = 0, ): string => formatNumber(value, { decimals, lang }); -export { formatHhMm, generateUrl, langFromUrl, sleep, formatNumber, formatMW }; +export { formatHhMm, formatMW, formatNumber, generateUrl, langFromUrl, sleep }; /** * Guess interval by area/country identifier using config/countries mapping. diff --git a/utils/log.ts b/utils/log.ts index c0e3eea..c512b99 100644 --- a/utils/log.ts +++ b/utils/log.ts @@ -1,5 +1,4 @@ let level = "normal"; -const decorate = false; const setLevel = (requestedLevel: string) => { level = requestedLevel; @@ -14,11 +13,7 @@ const log = (type: string, t: string) => { else if (type === "debug") fn = console.debug; else throw new Error("Invalid log type, cannot log: " + t); if (fn) { - if (decorate) { - fn(new Date().toLocaleString("sv-SE"), "Backend:", t); - } else { - fn(t); - } + fn(t); } }; diff --git a/utils/price.ts b/utils/price.ts index a87b87a..07172fe 100644 --- a/utils/price.ts +++ b/utils/price.ts @@ -78,16 +78,16 @@ const parseInterval = (interval: string): number => { // Default to 1 hour if parsing fails return 3600 * 1000; } - + const value = parseInt(match[1]); const unit = match[2]; - - if (unit === 'M') { + + if (unit === "M") { return value * 60 * 1000; // minutes to milliseconds - } else if (unit === 'H') { + } else if (unit === "H") { return value * 3600 * 1000; // hours to milliseconds } - + // Default to 1 hour if unit is unknown return 3600 * 1000; }; @@ -150,4 +150,4 @@ const applyExchangeRateSingle = (rs: number, ex: ExchangeRateResult, currency: s return converted; }; -export { applyExchangeRate, applyExchangeRateSingle, avgPrice, maxPrice, minPrice, nowPrice, processPrice, parseInterval }; +export { applyExchangeRate, applyExchangeRateSingle, avgPrice, maxPrice, minPrice, nowPrice, parseInterval, processPrice };