Skip to content

Commit

Permalink
Fix timer stop (#155)
Browse files Browse the repository at this point in the history
* Update timer params

* Refactor params

* Refactor

* Fix linter

* Update README.md
  • Loading branch information
CuddlyBunion341 authored Nov 5, 2024
1 parent 6071331 commit fe471ed
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,44 @@ Administration => Roles & Permissions
- Test: `rake test`
- Watch Assets: `rake watch`

## Time Tracking Flow

```mermaid
stateDiagram-v2
[*] --> CheckingSession : Start Request
CheckingSession --> Conflict : Session Exists
Conflict --> [*] : Return Conflict
CheckingSession --> SessionCreation : No Active Session
SessionCreation --> ValidatingSession : Create Session
ValidatingSession --> IssueAssociation : Valid Session
ValidatingSession --> Error : Invalid Session
Error --> [*] : Return Unprocessable
IssueAssociation --> ConnectorValidation : Issue Connector Init
ConnectorValidation --> Error : Connector Invalid
Error --> [*] : Return Unprocessable
ConnectorValidation --> CheckingFinished : Connector Valid
CheckingFinished --> Finalize : Session Finished
CheckingFinished --> UpdateTimer : Session Active
Finalize --> TimeEntryCreation : Mark Finished
TimeEntryCreation --> Success : Create Time Entries
Success --> [*] : Return Success
UpdateTimer --> TimerUpdated : Update Session
TimerUpdated --> Success : Valid Update
TimerUpdated --> Error : Invalid Update
Error --> [*] : Return Unprocessable
destroy : Destroy Session
destroy --> Cancel : Cancel Timer
Cancel --> [*] : Return Cancel
```

## Copyright

Copyright 2021-2024 [Renuo AG](https://www.renuo.ch/), published under the MIT license.
6 changes: 5 additions & 1 deletion app/controllers/time_tracker_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ def create
end

def update
return render_js(:update, :unprocessable_entity) unless @current_timer_session.update(timer_params)
updated_params = timer_params

updated_params[:timer_end] = user_time_zone.now.asctime if updated_params[:timer_end].blank?

return render_js(:update, :unprocessable_entity) unless @current_timer_session.update(updated_params)

if @current_timer_session.session_finished?
return render_js(:update, :unprocessable_entity) unless @current_timer_session.update(finished: true)
Expand Down
1 change: 1 addition & 0 deletions test/functional/time_tracker_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def setup
issue_ids: ['1']
} }, xhr: true
assert_response 200
assert_equal TimerSession.last.finished, true
end

test '#update - with no end time' do
Expand Down

0 comments on commit fe471ed

Please sign in to comment.