Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix timer stop #155

Merged
merged 5 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Terminology doesn't seem correct yet on a first glance. Let's bring it on an correct it in a separate PR. I find the graph useful. Let's discuss this in person.


## 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?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be moved into the model perhaps?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not nicely possible, because a timer session without end time is valid, right?


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
Loading