From db2bbad64bfe8efa44fad1c5016c9d4b44c2ca1f Mon Sep 17 00:00:00 2001 From: Yue-Long Date: Tue, 3 Sep 2024 10:22:06 +0100 Subject: [PATCH] fix: fixed to 2 decimals in the frontend --- app/javascript/components/stats/StatsCoverage.vue | 6 ++++-- app/presenters/statistic_presenter.rb | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/javascript/components/stats/StatsCoverage.vue b/app/javascript/components/stats/StatsCoverage.vue index 87ff8aa81..2f11fcb96 100644 --- a/app/javascript/components/stats/StatsCoverage.vue +++ b/app/javascript/components/stats/StatsCoverage.vue @@ -32,7 +32,7 @@ v-if="hasNationalReport" > - {{ protectedNationalReport }}% + {{ protectedNationalReportWithTwoDecimals }}% {{ nationalReportVersion }}{{ textNationalReport }}

@@ -120,7 +120,9 @@ export default { hasNationalReport () { return this.protectedNationalReport != null && this.nationalReportVersion != null }, - + protectedNationalReportWithTwoDecimals() { + return this.hasNationalReport? this.protectedNationalReport.toFixed(2):'' + }, hasPameData () { return this.pamePercentage != null && this.pameKm2 != null } diff --git a/app/presenters/statistic_presenter.rb b/app/presenters/statistic_presenter.rb index ba0b17475..08d5292de 100644 --- a/app/presenters/statistic_presenter.rb +++ b/app/presenters/statistic_presenter.rb @@ -51,7 +51,7 @@ def method_missing method nr_stat = "percentage_nr_#{land_type}_cover".to_sym define_method(nr_stat) do - (@statistic.send(nr_stat) && @statistic.send(nr_stat) > 100.0) ? 100.0 : @statistic.send(nr_stat).round(2) rescue nil + (@statistic.send(nr_stat) && @statistic.send(nr_stat) > 100.0) ? 100.00 : @statistic.send(nr_stat) rescue nil end percent_oecm_stat = "percentage_oecms_pa_#{land_type}_cover".to_sym