Open neocosmic2 opened 6 years ago
Hi, we are using 3.4.2.stable with the same error, any idea?
Thanks
@deecay maybe something you can take a look at? This would be greatly appreciated
I had the same problem. To fix it I had to change the language of my user from English to Portuguese/Brazil.
Please see if this is resolved with current master. Thanks!
Hi. Does not work if the custom date format is set.
any idea how to fix it?
Hi @marcin295
What version of Redmine and redmine_pivot_table version do you use? Do you use custom date format? If yes, what is the setting?
Redmine: 3.4.2.stable redmine_pivot_table 0.0.7 date format: dd.mm.yyyy Pivot settings: Max issue count 1000
Works fine for me with that configuration and date format.
Can you paste the error output? The line numbers in the one in the original post is no longer valid.
Ok, i see... That is another problem with queries not with dataFormat. Sorry.
ActionView::Template::Error (undefined method
id' for nil:NilClass):
55: <% if @table == "activity" %>
56: data = <%= raw parse_events(@events).to_json %>;
57: <% else %>
58: data = <%= raw parse_issues(@issues).to_json %>;
59: <% end %>
60:
61: var dateFormat = $.pivotUtilities.derivers.dateFormat;
plugins/extra_queries/lib/extra_queries/patches/helpers/queries_helper_patch.rb:19:in column_value_with_eq' app/helpers/queries_helper.rb:203:in
column_content'
plugins/a_common_libs/lib/acl/patches/helpers/queries_helper_patch.rb:13:in column_content_with_acl' plugins/redmine_pivot_table/app/helpers/pivottables_helper.rb:81:in
block (2 levels) in parse_issues'
plugins/redmine_pivot_table/app/helpers/pivottables_helper.rb:78:in each' plugins/redmine_pivot_table/app/helpers/pivottables_helper.rb:78:in
block in parse_issues'
plugins/redmine_pivot_table/app/helpers/pivottables_helper.rb:76:in each' plugins/redmine_pivot_table/app/helpers/pivottables_helper.rb:76:in
parse_issues'
plugins/redmine_pivot_table/app/views/pivottables/index.html.erb:58:in _70c30ab766d4ae71c1aca3f7cf00f766' lib/redmine/sudo_mode.rb:63:in
sudo_mode'
`
Ok. So this is about other plugins you have (usability? a common libs?). Since I don't use those plugins, I'm afraid I cannot help.
Fix for pivottables_helper.rb and incorrect date error.
It's a dirty hack. I don't know if it will work for all, but in my particular case the problem was solved. Proper fix would require a "try except" (rescue) block around Date.strptime(column_content(c, i), strpformat) method call.
How did I found the solution? By adding logging.
def parse_issues(issues)
...
myLog = Logger.new '/tmp/pt.log'
myLog.log( Logger::DEBUG, 'strpformat: ' + strpformat )
issues.each{|i|
formatted_issue = {}
@query.available_columns.each{|c|
if ...
elsif c.name.to_s.end_with?("_date") ||
(c.is_a?(QueryCustomFieldColumn) && c.custom_field.field_format == "date")
formatted_issue[c.caption] = column_content(c, i)
if column_content(c, i).to_s != ""
myLog.log( Logger::DEBUG, '1: ' + c.name.to_s + ' ' + + ' ' + column_content(c, i).to_s )
myLog.log( Logger::DEBUG, '2: ' + Date.strptime(column_content(c, i), strpformat).to_s )
myLog.log( Logger::DEBUG, '3: ' + Date.strptime(column_content(c, i), strpformat).strftime("%Y-W%U") )
end
Output was
D, [2020-01-15T16:19:09.541885 #72194] DEBUG -- : strpformat: %d.%m.%Y
D, [2020-01-15T16:19:09.584536 #72194] DEBUG -- : 1: start_date 10.09.2019
D, [2020-01-15T16:19:09.584695 #72194] DEBUG -- : 2: 2019-09-10
D, [2020-01-15T16:19:09.584804 #72194] DEBUG -- : 3: 2019-W36
D, [2020-01-15T16:19:09.718327 #72194] DEBUG -- : 1: start_date 10.09.2019
D, [2020-01-15T16:19:09.718465 #72194] DEBUG -- : 2: 2019-09-10
D, [2020-01-15T16:19:09.718571 #72194] DEBUG -- : 3: 2019-W36
D, [2020-01-15T16:19:09.739822 #72194] DEBUG -- : 1: expiration_date Expired
Note the last line. Field expiration_date (from some plugin) has value Expired in it. It's clearly not a valid date, so Date.strptime can't handle it. Quick and dirty fix is to add
c.name.to_s != 'expiration_date' to if statement:
elsif c.name.to_s != 'expiration_date' && ( c.name.to_s.end_with?("_date") ||
(c.is_a?(QueryCustomFieldColumn) && c.custom_field.field_format == "date") )
As mentioned it's just a dirty hack, this problem should be fixed in a more appropriate way by.
Fix for pivottables_helper.rb and incorrect date error.
It's a dirty hack. I don't know if it will work for all, but in my particular case the problem was solved. Proper fix would require a "try except" (rescue) block around Date.strptime(column_content(c, i), strpformat) method call.
How did I found the solution? By adding logging.
def parse_issues(issues) ... myLog = Logger.new '/tmp/pt.log' myLog.log( Logger::DEBUG, 'strpformat: ' + strpformat ) issues.each{|i| formatted_issue = {} @query.available_columns.each{|c| if ... elsif c.name.to_s.end_with?("_date") || (c.is_a?(QueryCustomFieldColumn) && c.custom_field.field_format == "date") formatted_issue[c.caption] = column_content(c, i) if column_content(c, i).to_s != "" myLog.log( Logger::DEBUG, '1: ' + c.name.to_s + ' ' + + ' ' + column_content(c, i).to_s ) myLog.log( Logger::DEBUG, '2: ' + Date.strptime(column_content(c, i), strpformat).to_s ) myLog.log( Logger::DEBUG, '3: ' + Date.strptime(column_content(c, i), strpformat).strftime("%Y-W%U") ) end
Output was
D, [2020-01-15T16:19:09.541885 #72194] DEBUG -- : strpformat: %d.%m.%Y D, [2020-01-15T16:19:09.584536 #72194] DEBUG -- : 1: start_date 10.09.2019 D, [2020-01-15T16:19:09.584695 #72194] DEBUG -- : 2: 2019-09-10 D, [2020-01-15T16:19:09.584804 #72194] DEBUG -- : 3: 2019-W36 D, [2020-01-15T16:19:09.718327 #72194] DEBUG -- : 1: start_date 10.09.2019 D, [2020-01-15T16:19:09.718465 #72194] DEBUG -- : 2: 2019-09-10 D, [2020-01-15T16:19:09.718571 #72194] DEBUG -- : 3: 2019-W36 D, [2020-01-15T16:19:09.739822 #72194] DEBUG -- : 1: expiration_date Expired
Note the last line. Field expiration_date (from some plugin) has value Expired in it. It's clearly not a valid date, so Date.strptime can't handle it. Quick and dirty fix is to add c.name.to_s != 'expiration_date' to if statement:
elsif c.name.to_s != 'expiration_date' && ( c.name.to_s.end_with?("_date") || (c.is_a?(QueryCustomFieldColumn) && c.custom_field.field_format == "date") )
As mentioned it's just a dirty hack, this problem should be fixed in a more appropriate way by.
can u explain that?
Started GET "/redmine/projects/bpsconnect-casino/pivottables" for 127.0.0.1 at 2017-11-04 17:43:30 +0800 Processing by PivottablesController#index as HTML Parameters: {"project_id"=>"bpsconnect-casino"} Current user: neo (id=1) Rendered plugins/redmine_pivot_table/app/views/pivottables/index.html.erb within layouts/base (42.1ms) Completed 500 Internal Server Error in 120ms (ActiveRecord: 23.5ms)
ActionView::Template::Error (invalid date): 57: <% if @table == "activity" %> 58: data = <%= raw parse_events(@events).to_json %>; 59: <% else %> 60: data = <%= raw parse_issues(@issues).to_json %>; 61: <% end %> 62: 63: var dateFormat = $.pivotUtilities.derivers.dateFormat; plugins/redmine_pivot_table/app/helpers/pivottables_helper.rb:68:in
parse' plugins/redmine_pivot_table/app/helpers/pivottables_helper.rb:68:in
block (2 levels) in parse_issues' plugins/redmine_pivot_table/app/helpers/pivottables_helper.rb:57:ineach' plugins/redmine_pivot_table/app/helpers/pivottables_helper.rb:57:in
block in parse_issues' plugins/redmine_pivot_table/app/helpers/pivottables_helper.rb:55:ineach' plugins/redmine_pivot_table/app/helpers/pivottables_helper.rb:55:in
parse_issues' plugins/redmine_pivot_table/app/views/pivottables/index.html.erb:60:in_plugins_redmine_pivot_table_app_views_pivottables_index_html_erb___789593742_75824952' lib/redmine/sudo_mode.rb:63:in
sudo_mode'