Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions backend/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
8 changes: 4 additions & 4 deletions backend/db/sql/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,14 +438,14 @@ export {
sqlExchangeRates,
sqlFutureOutagesPerArea,
sqlGeneration,
sqlGenerationAnyInterval,
sqlGroupBy,
sqlLatestGenerationInterval,
sqlLatestLoadInterval,
sqlLatestPricePerArea,
sqlLatestPricePerCountry,
sqlLatestLoadInterval,
sqlLatestGenerationInterval,
sqlLoad,
sqlLoadAnyInterval,
sqlLoadAndGeneration,
sqlLoadAnyInterval,
sqlRaw,
sqlGenerationAnyInterval,
};
2 changes: 0 additions & 2 deletions backend/scheduler/jobs/daily.currencyupdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 0 additions & 2 deletions backend/scheduler/jobs/daily.outageupdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 0 additions & 2 deletions backend/scheduler/jobs/daily.priceupdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
7 changes: 0 additions & 7 deletions backend/scheduler/jobs/hourly.consumptionupdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 0 additions & 4 deletions backend/scheduler/jobs/hourly.productionupdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions static/BingSiteAuth.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<users>
<user>061CFD64915789189179DA473A0B64D0</user>
</users>
<user>061CFD64915789189179DA473A0B64D0</user>
</users>
78 changes: 39 additions & 39 deletions static/css/custom.css
Original file line number Diff line number Diff line change
@@ -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;
}
max-height: 70px;
}
14 changes: 7 additions & 7 deletions static/offline.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<html>
<head>
<title>Spotweb</title>
</head>
<body>
<h1>Spotweb is not available offline, try refreshing you browser</h1>
</body>
</html>
<head>
<title>Spotweb</title>
</head>
<body>
<h1>Spotweb is not available offline, try refreshing you browser</h1>
</body>
</html>
29 changes: 18 additions & 11 deletions utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -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.
Expand Down
7 changes: 1 addition & 6 deletions utils/log.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
let level = "normal";
const decorate = false;

const setLevel = (requestedLevel: string) => {
level = requestedLevel;
Expand All @@ -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);
}
};

Expand Down
12 changes: 6 additions & 6 deletions utils/price.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down Expand Up @@ -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 };