Skip to content

Commit

Permalink
Add project to tracked time entries overview (#161)
Browse files Browse the repository at this point in the history
* Add project to issue render helper

* Review

* Fix n+1

* Update
  • Loading branch information
CuddlyBunion341 authored Jan 15, 2025
1 parent 552ece5 commit b5c4bf5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/controllers/timer_sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class TimerSessionsController < TrackyController
def index
@timer_sessions_in_range = TimerSession.includes(:issues, :time_entries, :timer_session_time_entries)
@timer_sessions_in_range = TimerSession.includes(:time_entries, :timer_session_time_entries, issues: :project)
.finished
.created_by(User.current)
@non_matching_timer_session_ids = TimeDiscrepancyLoader.uneven_timer_session_ids(@timer_sessions_in_range)
Expand Down
14 changes: 11 additions & 3 deletions app/helpers/timer_sessions_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,21 @@ def sum_work_hours(timer_sessions)

def issue_information(issue)
subject = issue.subject
issue_information = issue.id.to_s

[
issue_information,
"#{subject[0..(MAX_SUBJECT_LENGTH - issue_information.length)]}#{subject_label_trail(subject)}"
issue_identifier(issue),
"#{truncated_subject(subject)}#{subject_label_trail(subject)}"
].join(': ')
end

def issue_identifier(issue)
"[#{issue.project.name}] #{issue.id}"
end

def truncated_subject(subject)
subject[0..(MAX_SUBJECT_LENGTH - subject.length)]
end

def subject_label_trail(subject)
'...' if subject.length > MAX_SUBJECT_LENGTH
end
Expand Down
1 change: 1 addition & 0 deletions test/functional/timer_sessions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def setup
get(:index)
assert_response 200
assert response.body.include?(@issue.subject)
assert response.body.include?(@issue.project.name)
assert response.body.include?(@timer_session.splittable_hours.round(2).to_s)
end

Expand Down
2 changes: 1 addition & 1 deletion test/unit/timer_sessions_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ class TimerSessionsHelperTest < ActionView::TestCase
end

test '#issue_link_list' do
assert_equal ['<a href="/issues/1">1: Cannot print recipes</a>'], issue_link_list([Issue.first])
assert_equal ['<a href="/issues/1">[eCookbook] 1: Cannot print recipes</a>'], issue_link_list([Issue.first])
end
end

0 comments on commit b5c4bf5

Please sign in to comment.