Skip to content

Commit dc6988e

Browse files
committed
Clean "update-interval" from daemon subcommand
1 parent daa53a3 commit dc6988e

File tree

3 files changed

+4
-13
lines changed

3 files changed

+4
-13
lines changed

testcmd.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
timefor daemon [command options]
3333
3434
OPTIONS:
35-
--update-interval value interval to update activity time in db (default: 30s)
3635
--break-interval value interval to show a break reminder (default: 1h20m0s)
3736
--repeat-interval value interval to repeat a break reminder (default: 10m0s)
3837
--hook value a hook command template

timefor

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:11d3a45f9450ece64f77602eaf3a18f5cf14b92ca9ad350aa9aa3055c74ebb97
3-
size 9551664
2+
oid sha256:980f037d2f451353312bb85ab14c6459c0dd65c55a2e77188d0b7d751f7f568a
3+
size 9551736

timefor.go

+2-10
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424

2525
const (
2626
intervalToExpire = 10 * time.Minute
27-
defaultIntervalToUpdateDb = 30 * time.Second
2827
defaultIntervalToShowBreakReminder = 80 * time.Minute
2928
defaultIntervalToRepeatBreakReminder = 10 * time.Minute
3029
defaultTpl = "{{if .Active}}☭{{else}}☯{{end}} {{.FormatLabel}}"
@@ -221,11 +220,6 @@ func newCmd(db *sqlx.DB) error {
221220
Usage: "Update the duration for current activity and run hook if specified",
222221
ArgsUsage: " ",
223222
Flags: []cli.Flag{
224-
&cli.DurationFlag{
225-
Name: "update-interval",
226-
Usage: "interval to update activity time in db",
227-
Value: defaultIntervalToUpdateDb,
228-
},
229223
&cli.DurationFlag{
230224
Name: "break-interval",
231225
Usage: "interval to show a break reminder",
@@ -246,12 +240,11 @@ func newCmd(db *sqlx.DB) error {
246240
return cli.ShowSubcommandHelp(cCtx)
247241
}
248242

249-
intervalToUpdateDb := cCtx.Duration("update-interval")
250243
intervalToShowBreakReminder := cCtx.Duration("break-interval")
251244
intervalToRepeatBreakReminder := cCtx.Duration("repeat-interval")
252245
hook := cCtx.String("hook")
253246

254-
err := Daemon(db, intervalToUpdateDb, intervalToShowBreakReminder, intervalToRepeatBreakReminder, hook)
247+
err := Daemon(db, intervalToShowBreakReminder, intervalToRepeatBreakReminder, hook)
255248
if err != nil {
256249
return err
257250
}
@@ -488,7 +481,6 @@ func Show(db *sqlx.DB, tpl string) error {
488481
// Daemon updates the duration of current activity and runs the hook if specified
489482
func Daemon(
490483
db *sqlx.DB,
491-
intervalToUpdateDb time.Duration,
492484
intervalToShowBreakReminder time.Duration,
493485
intervalToRepeatBreakReminder time.Duration,
494486
hook string,
@@ -550,7 +542,7 @@ func Daemon(
550542
log.Println("change", c)
551543

552544
case <-time.After(nextUpdate):
553-
if activity.Active() && time.Since(activity.Updated()) > intervalToUpdateDb {
545+
if activity.Active() && time.Since(activity.Updated()) > time.Minute {
554546
fmt.Printf("updating time for %s\n", activity.Name)
555547
_, err := UpdateIfExists(db, "", false)
556548
if err != nil {

0 commit comments

Comments
 (0)