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

hcl resume should be idempotent #68

Closed
aaronjensen opened this issue Jun 13, 2015 · 8 comments
Closed

hcl resume should be idempotent #68

aaronjensen opened this issue Jun 13, 2015 · 8 comments

Comments

@aaronjensen
Copy link

currently if i send resume for one task twice in a row it will start the timer and then stop it. Resume does not imply toggle.

@zenhob
Copy link
Owner

zenhob commented Jun 30, 2015

Good catch!

Here is the offending line, for future reference: https://github.com/zenhob/hcl/blob/master/lib/hcl/commands.rb#L174

@zenhob zenhob added the bug label Jun 30, 2015
@zenhob
Copy link
Owner

zenhob commented Jun 30, 2015

Um I think stop has the same bug:

https://github.com/zenhob/hcl/blob/master/lib/hcl/commands.rb#L130

@charneykaye
Copy link
Contributor

I have some time coming up to work on hcl. Top of my list is this issue (I think), or perhaps broader work to ensure that timer resume picks up any already-used-today timers.

@zenhob
Copy link
Owner

zenhob commented Dec 9, 2019

So it turns out that this is a limitation of the underlying timesheet API provided by Harvest.

Instead of attempting to work around this (or change APIs, which is a larger scope than I wish to tackle), I plan to deprecate stop and resume since they have a misleading name, and replace them both with something like toggle that has the same functionality while also properly describing what it does.

I'll plan to roll out a minor release with the new command and optional deprecation of the old commands, with a longer term plan to release a version with mandatory deprecation, concluding with the removal the deprecated commands for version 1.0 (if that ever happens)

@aaronjensen
Copy link
Author

Will there still be a way to stop the current timer that doesn't require knowing which timer is running and won't start a timer if there's nothing running?

@zenhob
Copy link
Owner

zenhob commented Dec 10, 2019

this is a great question! it turns out that the stop command already checks for a running timer so I left it in place. I've added a toggle command that works mostly like resume that will be in the next release. Good catch, thank you

@aaronjensen
Copy link
Author

aaronjensen commented Jun 25, 2020

Okay, coming around to trying this out today and it doesn't actually solve my problem. It gives a better name to resume, but it still fails to give me an idempotent resume timer.

I want to be able to call hcl XXX 1234 5678 twice in a row and have the result be that timer 1234 5678 is started once.

If I use toggle, the second call will stop it.

What I want is just like toggle, but it won't stop:

    def resume *args
      ident = get_ident args
      entry = if ident
          task_ids = get_task_ids ident, args
          DayEntry.last_by_task http, *task_ids
        else
          DayEntry.last(http)
        end
      if entry
        unless entry.running?
          "Starting #{entry} (at #{current_time})"
          entry.toggle http
        end
      else
        fail "No timer found."
      end
    end

As it is now, I have to call stop and then call toggle and the harvest api isn't exactly fast, so reducing the calls would be great.

@charneykaye
Copy link
Contributor

charneykaye commented Jun 25, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants