feat: configurable distance display unit - #411
Merged
Merged
Conversation
First part of #10: a distance_unit plugin setting (m, km, ft, mi, nm) that drives what users see. Meters remain the internal unit everywhere (storage, SQL, filter wire format, REST API). - RedmineGtt::DistanceUnit: unit table, current/api_unit readers with fallback, to/from-meters conversion - distance column: header carries the unit (caption proc), list and CSV cells render converted via a QueriesHelper prepend - api_distance_unit setting reserved with meters as the only option, so the API contract can widen later without a settings migration - settings UI selects + en/ja/de locales The distance filter input and the nearby-watch radius field follow in separate PRs.
There was a problem hiding this comment.
Pull request overview
Adds configurable distance display units to the Redmine GTT plugin (part 1/3 of #10), keeping meters as the internal/storage/API contract while converting only the distance column header and rendered values.
Changes:
- Introduces a
distance_unit(and reservedapi_distance_unit) plugin setting plus aRedmineGtt::DistanceUnitconversion helper. - Updates the distance query column caption to include the configured unit, and converts list/CSV cell rendering via a
QueriesHelperprepend. - Adds unit tests covering conversions, defaults/fallbacks, caption unit, and column/CSV rendering.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/unit/queries_helper_patch_test.rb | Adds coverage for distance column rendering and CSV formatting. |
| test/unit/distance_unit_test.rb | Adds coverage for unit defaults, fallbacks, conversion table, API clamp, and caption unit. |
| lib/redmine_gtt/patches/queries_helper_patch.rb | Prepends QueriesHelper to render distance values in the configured unit for list/CSV. |
| lib/redmine_gtt/patches/issue_query_patch.rb | Appends the configured unit to the distance column header caption. |
| lib/redmine_gtt/distance_unit.rb | Implements unit conversion logic and settings readers. |
| lib/redmine_gtt.rb | Applies the new QueriesHelper patch during setup. |
| init.rb | Adds default plugin settings for distance_unit and api_distance_unit. |
| config/locales/ja.yml | Adds i18n strings for the new settings and unit labels. |
| config/locales/en.yml | Adds i18n strings for the new settings and unit labels. |
| config/locales/de.yml | Adds i18n strings for the new settings and unit labels. |
| app/views/settings/gtt/_general.html.erb | Adds settings UI for selecting display/API distance units. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Jul 27, 2026
- unknown units fall back to meters instead of raising KeyError (the setting can be hand-edited, callers may pass user-supplied strings) - the CSV separator test derives its expectation from the locale instead of hardcoding '.'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 1 of 3 for #10 (closes via a release PR once all parts are in).
Adds a
distance_unitplugin setting — m, km, ft, mi, nm (degrees/radians from the issue's list dropped as not meaningful for UI) — applied so far to the distance column: the header becomes e.g. "Distance (km)" (caption proc) and list/CSV cells render converted, via aQueriesHelperprepend.Meters stay the internal contract everywhere: storage, SQL, the filter wire format, and the REST API are untouched (the API behavior documented in #410 does not change). Per discussion, a second
api_distance_unitsetting is reserved with meters as its only allowed value — the reader clamps tom— so a later version can widen the API options without a settings migration.Still to come in follow-up PRs: the distance filter input (entered in the display unit, converted client-side) and the nearby-watch radius field from #14 (storage moving to meters while unreleased).
Verified: full plugin suite in the local Redmine 7.0 mirror — 98 runs, 533 assertions, 0 failures (12 new tests: conversion table, setting fallbacks, API-unit clamp, caption unit, column/CSV rendering).