Skip to content

Commit

Permalink
Added template in install.py. Updated snapshots.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daveiano committed Oct 28, 2023
1 parent 1453a87 commit c7f3537
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 11 deletions.
1 change: 1 addition & 0 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def __init__(self):
"skins/weewx-wdc/includes/body-alternative.inc",
"skins/weewx-wdc/includes/forecast.inc",
"skins/weewx-wdc/includes/forecast-table.inc",
"skins/weewx-wdc/includes/year-stats-table.inc",
"skins/weewx-wdc/includes/icons/barometer.svg",
"skins/weewx-wdc/includes/pictograms/sun.svg",
"skins/weewx-wdc/includes/pictograms/moon.svg",
Expand Down
4 changes: 1 addition & 3 deletions skins/weewx-wdc/includes/climatological-days.inc
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@
id="tab-diagram-rain"
target="panel-diagram-rain"
value="diagram-rain"
>
$gettext('rainDays')
</bx-tab>
>$obs.label.rain</bx-tab>
#end if
#if $getattr($get_time_span_from_context($context, $day, $week, $month, $year, $alltime, $yesterday), 'outTemp').has_data
<bx-tab
Expand Down
36 changes: 32 additions & 4 deletions skins/weewx-wdc/includes/year-stats-table.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#import calendar
#import datetime
#from weeutil.weeutil import startOfDay, startOfArchiveDay

#set $first_option = $DisplayOptions.get('climatological_days', [])[0].replace(' ', '_').lower()

Expand Down Expand Up @@ -77,16 +78,19 @@
#set $months_for_year = $filter_months($archive_months, $year)

#for $month in range(1, 13)
#if not $month in $totals_per_month
#set $totals_per_month[$month] = []
#end if
#set $month_from_range = $year + '-' + str($month).zfill(2)

#if $month_from_range in $months_for_year
<bx-structured-list-cell data-testid="$month_from_range">
#set $time_span_start_ts = $datetime.datetime.strptime($month_from_range, "%Y-%m").replace(day=1).timestamp()
#set $time_span_end_ts = $datetime.datetime.strptime($month_from_range, "%Y-%m").replace(day=$calendar.monthrange(int($year), int($month))[1]).timestamp()
#set $time_span_start_ts = $startOfDay($datetime.datetime.strptime($month_from_range, "%Y-%m").replace(day=1).timestamp())
#set $time_span_end_ts = $datetime.datetime.strptime($month_from_range, "%Y-%m").replace(day=$calendar.monthrange(int($year), int($month))[1], hour=23, minute=59).timestamp()

#set $number_of_days = $get_climatological_day($clim_day, $time_span_start_ts, $time_span_end_ts)
#set $totals_per_year[$year] = $number_of_days + $totals_per_year[$year] if $year in $totals_per_year else $number_of_days
#set $totals_per_month[$month] = $number_of_days + $totals_per_month[$month] if $month in $totals_per_month else $number_of_days
#silent $totals_per_month[$month].append($number_of_days)

$number_of_days
</bx-structured-list-cell>
Expand All @@ -111,7 +115,7 @@
#for $month in range(1, 13)
#if $month in $totals_per_month
<bx-structured-list-cell data-testid="month-$month">
<strong>$totals_per_month[$month]</strong>
<strong>$sum($totals_per_month[$month])</strong>
</bx-structured-list-cell>
#else
<bx-structured-list-cell>-</bx-structured-list-cell>
Expand All @@ -123,6 +127,30 @@
</strong>
</bx-structured-list-cell>
</bx-structured-list-row>
<bx-structured-list-row data-test="average">
<bx-structured-list-cell>
<strong>$gettext("Average")</strong>
</bx-structured-list-cell>
#for $month in range(1, 13)
#if $month in $totals_per_month and $len($totals_per_month[$month]) > 0
<bx-structured-list-cell data-testid="month-$month">
<strong>$round($sum($totals_per_month[$month]) / $len($totals_per_month[$month]), 1)</strong>
</bx-structured-list-cell>
#else
<bx-structured-list-cell>-</bx-structured-list-cell>
#end if
#end for

#if $len($SummaryByYear) > 0
<bx-structured-list-cell>
<strong>
$round($get_climatological_day($clim_day, $alltime.start.raw, $alltime.end.raw) / $len($SummaryByYear), 1)
</strong>
</bx-structured-list-cell>
#else
<bx-structured-list-cell>-</bx-structured-list-cell>
#end if
</bx-structured-list-row>
</bx-structured-list-body>
</bx-structured-list>
#end if
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ test.describe("Climatological days", () => {
test("Rain Stats table", async ({ page }) => {
// Stats page.
const rainTable = page
.getByRole("tabpanel", { name: "Rain days" })
.getByRole("tabpanel", { name: "Rain", exact: true })
.locator(".clim-days-extended-table");

await page.getByRole("tab", { name: "Rain days" }).click();
await page.getByRole("tab", { name: "Rain", exact: true }).click();
await expect(rainTable).toBeVisible();

await expect(rainTable.getByTestId("last-rain")).toContainText(
Expand All @@ -112,7 +112,7 @@ test.describe("Climatological days", () => {
await page.goto(
"artifacts-alternative-weewx-html/public_html/year-2021.html"
);
await page.getByRole("tab", { name: "Rain days" }).click();
await page.getByRole("tab", { name: "Rain", exact: true }).click();
await expect(rainTable).toBeVisible();

await expect(rainTable.getByTestId("last-rain")).toHaveCount(0);
Expand All @@ -130,7 +130,7 @@ test.describe("Climatological days", () => {
await page.goto(
"artifacts-alternative-weewx-html/public_html/year-2022.html"
);
await page.getByRole("tab", { name: "Rain days" }).click();
await page.getByRole("tab", { name: "Rain", exact: true }).click();
await expect(rainTable).toBeVisible();

await expect(rainTable.getByTestId("last-rain")).toHaveCount(0);
Expand Down

0 comments on commit c7f3537

Please sign in to comment.