Skip to content

Commit 5829682

Browse files
author
travis
committed
corrections after rubocop
corrected method naming conventions and cleaned up syntax.
1 parent 01c3354 commit 5829682

File tree

3 files changed

+42
-37
lines changed

3 files changed

+42
-37
lines changed

app/views/issues/_floating_report.html.erb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
<h3>Spent Time Report</h3>
33

44
<% @issue.time_entries.last( Setting.plugin_redmine_spent_time_in_issue_description['spent_time_max_display'].to_i ).each_with_index do |entry, index| %>
5-
<div class="spenttimeentry <%= ( index % 2 == 0 ? "even" : "odd" ) %>">
5+
<div class="spenttimeentry <%= (index % 2 == 0 ? "even" : "odd") %>">
66
<p>
7-
<%= content_tag(:span, entry.spent_on.strftime("%m/%d/%Y") ) if is_spent_on_shown( entry ) %>
8-
<%= content_tag(:span, link_to_user( entry.user )) if is_user_shown( entry ) %>
9-
<%= content_tag(:span, entry.activity ) if is_activity_shown( entry ) %>
10-
<%= content_tag(:span, report_time_spent( entry ) ) if is_report_time_shown( entry ) %>
11-
<%=raw "<br />" << content_tag(:span, entry.comments ) if is_comment_shown( entry ) %>
7+
<%= content_tag(:span, entry.spent_on.strftime("%m/%d/%Y")) if spent_on_shown? %>
8+
<%= content_tag(:span, link_to_user(entry.user)) if user_shown? %>
9+
<%= content_tag(:span, entry.activity) if activity_shown? %>
10+
<%= content_tag(:span, report_time_spent(entry)) if report_time_shown? %>
11+
<%=raw "<br />" << content_tag(:span, entry.comments) if comment_shown? %>
1212
</p>
1313
</div>
1414
<% end %>

app/views/issues/_time_spent_report.html.erb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
<tbody>
1616
<% @issue.time_entries.last( Setting.plugin_redmine_spent_time_in_issue_description['spent_time_max_display'].to_i ).each do |entry| %>
1717
<tr>
18-
<%= content_tag(:td, entry.spent_on.strftime("%m/%d/%Y") ) if is_spent_on_shown( entry ) %>
19-
<%= content_tag(:td, link_to_user( entry.user )) if is_user_shown( entry ) %>
20-
<%= content_tag(:td, report_time_spent( entry ) ) if is_report_time_shown( entry ) %>
21-
<%= content_tag(:td, entry.comments ) if is_comment_shown( entry ) %>
22-
<%= content_tag(:td, entry.activity ) if is_activity_shown( entry ) %>
18+
<%= content_tag(:td, entry.spent_on.strftime("%m/%d/%Y") ) if spent_on_shown? %>
19+
<%= content_tag(:td, link_to_user( entry.user )) if user_shown? %>
20+
<%= content_tag(:td, report_time_spent(entry) ) if report_time_shown? %>
21+
<%= content_tag(:td, entry.comments ) if comment_shown? %>
22+
<%= content_tag(:td, entry.activity ) if activity_shown? %>
2323
</tr>
2424
<% end %>
2525
</tbody>

lib/issue_helper_patch.rb

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,66 @@
1+
# Helper Patch to be include in Issue Helper
12
module IssuesHelperPatch
2-
33
def self.included(base) # :nodoc:
44
base.send(:include, InstanceMethods)
55
end
66

7+
# Helper provides shorter conditional calls and humanized_time format
78
module InstanceMethods
8-
99
def humanized_time(entry_hours)
1010
hours = entry_hours.to_i
1111
minutes = entry_hours * 60
12-
minutes = (minutes - hours * 60 ).to_i
12+
minutes = (minutes - hours * 60).to_i
1313

14-
time_spent = case
15-
when hours == 1
16-
t('plugin_spent_time_in_issue.datetime.hours.one')
17-
when hours > 1
18-
t('plugin_spent_time_in_issue.datetime.hours.other', hours: hours)
19-
else
20-
""
21-
end
14+
time_spent = humanized_hour(hours)
15+
time_spent << ' ' << humanized_minute(minutes) unless minutes < 1
16+
end
17+
end
2218

23-
if minutes == 1
24-
time_spent << " " << t('plugin_spent_time_in_issue.datetime.minutes.one')
25-
elsif minutes > 1
26-
time_spent << " " << t('plugin_spent_time_in_issue.datetime.minutes.other', minutes: minutes)
27-
else
28-
time_spent
29-
end
19+
def humanized_hour(hours)
20+
if hours == 1
21+
t('plugin_spent_time_in_issue.datetime.hours.one')
22+
elsif hours > 1
23+
t('plugin_spent_time_in_issue.datetime.hours.other', hours: hours)
24+
else
25+
''
3026
end
27+
end
3128

29+
def humanized_minute(minutes)
30+
if minutes == 1
31+
' ' << t('plugin_spent_time_in_issue.datetime.minutes.one')
32+
elsif minutes > 1
33+
' ' << t('plugin_spent_time_in_issue.datetime.minutes.other', minutes: minutes)
34+
else
35+
''
36+
end
3237
end
3338

3439
def report_time_spent(entry)
35-
if Setting.plugin_redmine_spent_time_in_issue_description['time_format'].eql? "human"
36-
time_spent = humanized_time( entry.hours )
40+
if Setting.plugin_redmine_spent_time_in_issue_description['time_format'].eql? 'human'
41+
humanized_time(entry.hours)
3742
else
38-
time_spent = entry.hours
43+
entry.hours
3944
end
4045
end
4146

42-
def is_report_time_shown( entry )
47+
def report_time_shown?
4348
Setting.plugin_redmine_spent_time_in_issue_description['display_columns'].include? 'hours'
4449
end
4550

46-
def is_spent_on_shown( entry )
51+
def spent_on_shown?
4752
Setting.plugin_redmine_spent_time_in_issue_description['display_columns'].include? 'spentOn'
4853
end
4954

50-
def is_user_shown( entry )
55+
def user_shown?
5156
Setting.plugin_redmine_spent_time_in_issue_description['display_columns'].include? 'user'
5257
end
5358

54-
def is_comment_shown( entry )
59+
def comment_shown?
5560
Setting.plugin_redmine_spent_time_in_issue_description['display_columns'].include? 'comments'
5661
end
5762

58-
def is_activity_shown( entry )
63+
def activity_shown?
5964
Setting.plugin_redmine_spent_time_in_issue_description['display_columns'].include? 'activity'
6065
end
6166

0 commit comments

Comments
 (0)