More hourse
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
Jan Zípek 2024-06-04 08:22:44 +02:00
parent a7b1e659e8
commit f50abec60f
Signed by: kamen
GPG Key ID: A17882625B33AC31
1 changed files with 31 additions and 23 deletions

View File

@ -202,7 +202,7 @@ export const dowRoutes = router((router, ctx) => {
//#endregion CALENDAR
const next12Hours = Object.entries(weather.hours).slice(1, 13)
const next12Hours = Object.entries(weather.hours).slice(1, 22)
const minTemp =
Math.min(...next12Hours.map(([, h]) => h.temperature as number)) - 5
@ -247,17 +247,19 @@ export const dowRoutes = router((router, ctx) => {
})
for (const [offset, hour] of next12Hours) {
const offsetInt = +offset
const x = Math.floor(
tempX +
tempGraphP +
(+offset - 1) * (tempGraphW / next12Hours.length),
(offsetInt - 1) * (tempGraphW / next12Hours.length),
)
const y = tempY
const temperature = hour.temperature as number
const ratio = (temperature - minTemp) / tempRange
const height = Math.floor(50 * ratio)
const t = now.plus({ hours: +offset }).hour
const t = now.plus({ hours: offsetInt }).hour
widgets.push({
x: x + 7,
@ -279,6 +281,7 @@ export const dowRoutes = router((router, ctx) => {
})
}
if ((offsetInt - 1) % 2 === 0) {
widgets.push({
x: x + 10,
y: y + 60,
@ -289,6 +292,7 @@ export const dowRoutes = router((router, ctx) => {
f: 3,
})
}
}
const minPre = Math.min(
...next12Hours.map(([, h]) => h.precipitationAmount as number),
@ -335,15 +339,17 @@ export const dowRoutes = router((router, ctx) => {
})
for (const [offset, hour] of next12Hours) {
const offsetInt = +offset
const x = Math.floor(
preX + preGraphP + (+offset - 1) * (preGraphW / next12Hours.length),
preX + preGraphP + (offsetInt - 1) * (preGraphW / next12Hours.length),
)
const y = preY
const pre = hour.precipitationAmount as number
const ratio = (pre - minPre) / preRange
const height = Math.floor(50 * ratio)
const t = now.plus({ hours: +offset }).hour
const t = now.plus({ hours: offsetInt }).hour
widgets.push({
x: x + 7,
@ -365,6 +371,7 @@ export const dowRoutes = router((router, ctx) => {
})
}
if ((offsetInt - 1) % 2 === 0) {
widgets.push({
x: x + 10,
y: y + 60,
@ -375,6 +382,7 @@ export const dowRoutes = router((router, ctx) => {
f: 3,
})
}
}
res.json(widgets)
}),