プロジェクト

全般

プロフィール

Vote #80165

未完了

CSV and PDF export don't respect Time span format

Admin Redmine さんがほぼ4年前に追加. ほぼ4年前に更新.

ステータス:
Confirmed
優先度:
通常
担当者:
-
カテゴリ:
Time tracking_13
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
13
version_id:
32
issue_org_id:
31637
author_id:
405859
assigned_to_id:
0
comments:
24
status_id:
9
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
132
ステータス-->[Confirmed]

説明

In Spent time section I have issues displaying the hours in standard time format, but when I export to CSV the hours are displayed in decimal format.

For example: I have a issue with 00:45h (standard), but in the CSV file I have 0.75 (decimal).

How can I export with standard time format?

I'm using the Bitnami Redmine Stack and this are my Redmine configurations:
Environment:
Redmine version 3.4.2.stable
Ruby version 2.3.4-p301 (2017-03-30) [x86_64-linux]
Rails version 4.2.8
Environment production
Database adapter Mysql2
SCM:
Subversion 1.9.7
Cvs 1.12.13
Filesystem
Redmine plugins:
redmine_checklists 3.1.15
redmine_custom_css 0.1.6


journals

--------------------------------------------------------------------------------
Looks like it is related to [[RedmineTimeTracking#Decimal-time-format|Redmine Document(RedmineTimeTracking#Decimal-time-format)]].
--------------------------------------------------------------------------------
I think the exported CSV file should follow the "time span format" as well. Probably users who want to see the time in "00:45" format on the screen want to see in the same format in the CSV file.
--------------------------------------------------------------------------------
PDF export has same bug
--------------------------------------------------------------------------------
I wrote a patch with Kusukawa and Mattani
--------------------------------------------------------------------------------
Seiei Miyagi wrote:
> I wrote a patch with Kusukawa and Mattani

Thanks for writing the patch. Can you add a new test or new assertions to existing tests?
--------------------------------------------------------------------------------
Marius BALTEANU wrote:
> Seiei Miyagi wrote:
> > I wrote a patch with Kusukawa and Mattani
>
> Thanks for writing the patch. Can you add a new test or new assertions to existing tests?

I added a test.
--------------------------------------------------------------------------------
I also write a patch for PDF download timespan format.
Should I create a new ticket for that?
--------------------------------------------------------------------------------
Seiei Miyagi wrote:
> I also write a patch for PDF download timespan format.
> Should I create a new ticket for that?

I updated the patch, added a test for IssuesPdfHelper too.
--------------------------------------------------------------------------------
Thank you for posting the patches but @issues_pdf_test.rb@ fails.

<pre>
Error:
IssuesPdfHelperTest#test_fetch_row_values_should_round_float_values:
NoMethodError: undefined method `format_hours' for #<IssuesPdfHelperTest:0x00007fcaf3326b60>
lib/redmine/export/pdf/issues_pdf_helper.rb:389:in `block in fetch_row_values'
lib/redmine/export/pdf/issues_pdf_helper.rb:376:in `collect'
lib/redmine/export/pdf/issues_pdf_helper.rb:376:in `fetch_row_values'
test/unit/lib/redmine/export/pdf/issues_pdf_test.rb:36:in `test_fetch_row_values_should_round_float_values'

bin/rails test test/unit/lib/redmine/export/pdf/issues_pdf_test.rb:28
</pre>

Maybe we have to add @include Redmine::I18n@ as follows, don't we?

<pre><code class="diff">
diff --git a/lib/redmine/export/pdf/issues_pdf_helper.rb b/lib/redmine/export/pdf/issues_pdf_helper.rb
index b49691695..8dcd52245 100644
--- a/lib/redmine/export/pdf/issues_pdf_helper.rb
+++ b/lib/redmine/export/pdf/issues_pdf_helper.rb
@@ -21,6 +21,8 @@ module Redmine
module Export
module PDF
module IssuesPdfHelper
+ include Redmine::I18n
+
# Returns a PDF string of a single issue
def issue_to_pdf(issue, assoc={})
pdf = ITCPDF.new(current_language)
</code></pre>
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Go MAEDA wrote:
> Thank you for posting the patches but @issues_pdf_test.rb@ fails.
>
> [...]
>
> Maybe we have to add @include Redmine::I18n@ as follows, don't we?
>
> [...]

Sorry, I applied the older patch. The latest patch has no problem. The patches work fine now.
--------------------------------------------------------------------------------
Setting the target version to 4.2.0.
--------------------------------------------------------------------------------
The patch attachment:0001-Fix-csv-format-of-hours.patch breaks an existing test:

<pre>
Failure:
IssuesControllerTest#test_index_csv_fr [/Users/maeda/redmines/redmine-trunk/test/functional/issues_controller_test.rb:1064]:
"24;1234,50;test_index_csv_fr" not found in "["#;Temps estim\xE9;Sujet", "24;1234.50;test_index_csv_fr"]"

bin/rails test test/functional/issues_controller_test.rb:1048
</pre>
--------------------------------------------------------------------------------
Go MAEDA wrote:
> The patch attachment:0001-Fix-csv-format-of-hours.patch breaks an existing test:
>
> [...]

It is because the suggested patch does not take @general_csv_decimal_separator@ (source:branches/4.1-stable/config/locales/en.yml#L148) into account. After applying the patch, "." is always used as a decimal separator for time values ignoring @general_csv_decimal_separator@.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Go MAEDA wrote:
> Go MAEDA wrote:
> > The patch attachment:0001-Fix-csv-format-of-hours.patch breaks an existing test:
> >
> > [...]
>
> It is because the suggested patch does not take @general_csv_decimal_separator@ (source:branches/4.1-stable/config/locales/en.yml#L148) into account. After applying the patch, "." is always used as a decimal separator for time values ignoring @general_csv_decimal_separator@.

The following changes should fix it.
<pre><code class="diff">
diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb
index 6271334ae..54aec4f24 100644
--- a/app/helpers/queries_helper.rb
+++ b/app/helpers/queries_helper.rb
@@ -267,7 +267,7 @@ module QueriesHelper
when :attachments
value.to_a.map {|a| a.filename}.join("\n")
when :hours, :estimated_hours, :total_estimated_hours, :spent_hours, :total_spent_hours
- format_hours(value)
+ format_hours(value).gsub('.', l(:general_csv_decimal_separator))
else
format_object(value, false) do |value|
case value.class.name
</code></pre>
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Setting the target version to 4.2.0.
--------------------------------------------------------------------------------
The fix #31637#note-20 changes decimal separators of the web UI as well as CSV and PDF.

However, after applying it, even though the decimal point is displayed according to the general_csv_decimal_separator on the screen, the form currently only accepts ". This can confuse users.

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


related_issues

relates,Confirmed,35726,Time Formatting does not apply to CSV exports

Admin Redmine さんがほぼ4年前に更新

  • カテゴリTime tracking_13 にセット
  • 対象バージョンCandidate for next major release_32 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0