Skip to content

Commit 0661071

Browse files
authored
Show Currency FX chart interval in tooltip (#123)
1 parent c263433 commit 0661071

3 files changed

Lines changed: 18 additions & 10 deletions

File tree

docking/applets/currencyfx/state.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -736,11 +736,8 @@ def build_tooltip(
736736
) -> str:
737737
"""Build tooltip text."""
738738
pair = f"{base}/{quote}"
739-
verb = (
740-
_("Day samples")
741-
if normalize_chart_interval(chart_interval) == ChartInterval.DAY
742-
else None
743-
)
739+
interval = normalize_chart_interval(chart_interval)
740+
verb = _("Day samples") if interval == ChartInterval.DAY else None
744741
state_error = error or (_("Unavailable") if fetch_failed else None)
745742
status = resolve_live_status(
746743
has_data=snapshot is not None,
@@ -767,7 +764,10 @@ def build_tooltip(
767764
rate=format_rate(snapshot.rate),
768765
quote=snapshot.quote,
769766
),
770-
details=(_("Change: {change}").format(change=format_change(snapshot.points)),),
767+
details=(
768+
_("Interval: {interval}").format(interval=interval.value.title()),
769+
_("Change: {change}").format(change=format_change(snapshot.points)),
770+
),
771771
freshness=live_freshness_lines(
772772
status=status,
773773
updated_at=snapshot.fetched_at,

docking/locale/docking.pot

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: docking\n"
1010
"Report-Msgid-Bugs-To: edumucelli@gmail.com\n"
11-
"POT-Creation-Date: 2026-05-23 19:05+0200\n"
11+
"POT-Creation-Date: 2026-05-24 00:08+0200\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -872,17 +872,22 @@ msgstr ""
872872
msgid "Quote"
873873
msgstr ""
874874

875-
#: docking/applets/currencyfx/state.py:744 docking/applets/live_state.py:91
875+
#: docking/applets/currencyfx/state.py:741 docking/applets/live_state.py:91
876876
#: docking/applets/weather/state.py:180
877877
msgid "Unavailable"
878878
msgstr ""
879879

880-
#: docking/applets/currencyfx/state.py:765
880+
#: docking/applets/currencyfx/state.py:762
881881
#, python-brace-format
882882
msgid "1 {base} = {rate} {quote}"
883883
msgstr ""
884884

885-
#: docking/applets/currencyfx/state.py:770
885+
#: docking/applets/currencyfx/state.py:768
886+
#, python-brace-format
887+
msgid "Interval: {interval}"
888+
msgstr ""
889+
890+
#: docking/applets/currencyfx/state.py:769
886891
#, python-brace-format
887892
msgid "Change: {change}"
888893
msgstr ""

tests/applets/test_currencyfx.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,8 @@ def test_build_tooltip(self):
597597
)
598598
assert "EUR/USD" in tooltip
599599
assert "1 EUR = 1.1 USD" in tooltip
600+
assert "Interval: Week" in tooltip
601+
assert "Change: +1.85%" in tooltip
600602
assert "Updated:" in tooltip
601603
assert "Updates every 15 minutes" in tooltip
602604

@@ -611,6 +613,7 @@ def test_build_tooltip_discloses_day_sample_cadence(self):
611613
)
612614

613615
assert "Day samples every 15 minutes" in tooltip
616+
assert "Interval: Day" in tooltip
614617

615618
def test_build_tooltip_empty_and_error_states(self):
616619
text = build_tooltip(

0 commit comments

Comments
 (0)