TatriX / pomidor

Pomidor is a simple and cool pomodoro technique timer.
238 stars 17 forks source link

Support productivity log #20

Closed azzamsa closed 6 years ago

azzamsa commented 6 years ago

Hi TatriX. Thank you so much for this awesome app.

Can we have a support to save pomodoro data to file. e.g

Maybe the structure like this

Thank you for your contribution to community.

TatriX commented 6 years ago

Hi. I glad you like it ;) It's a useful feature, but I'm not sure it should be added to the core yet.

Probably we should start from using advice to log the data. The idea is pretty simple: when you finish the current timer by pressing RET, log the data to a csv file for further analysis.

(defadvice pomidor-stop (before pomidor-save-log activate)
  "Log pomidor data to the ~/pomidor-log.csv file.
Columns: date,work,overwork,break"
  (write-region (format "%s,%d,%d,%d\n"
                        (format-time-string "%d/%m/%Y")
                        (time-to-seconds (pomidor-work-duration))
                        (time-to-seconds (or (pomidor-overwork-duration) 0))
                        (time-to-seconds (or (pomidor-break-duration) 0)))
                nil
                "~/pomidor-log.csv"
                'append))
Fuco1 commented 6 years ago

Instead of an advice rather provide a hook you will fire from the start/stop methods. Then users can create extra packages and attach to those hooks getting the events as necessary. Advices are pretty fragile and imo should be used as last effort.

I can imagine org-journal like logs from this, you could probably hook it up automatically to produce entries in that format, that would be wicked rad. I might try it someday.

azzamsa commented 6 years ago

I can imagine org-journal like logs from this, you could probably hook it up automatically to produce entries in that format, that would be wicked rad. I might try it someday.

Hi Fuco1. Nice idea. Please tell us here if you've done playing with it.

I also want to have this ability with pomodoro baudtack

Fuco1 commented 6 years ago

@azzamsa I was under the impression I'm using org-journal but I'm in fact just using regular file+datetree capture template :D Sometimes I forget what packages I have installed.

I'm sure there is some way to make org-capture fire an automatic capture (you can program the template with lisp) and then submit itself automatically through an event in org-capture-mode-hook. I haven't done any of this but I can imagine it being doable.

azzamsa commented 6 years ago

@TatriX Sorry for late reply. Lately I use baudtack's pomodoro. I come back today to pomidor cause I need this logging data for me to analyze my productivity.

I am not good at elisp. So instead of using baudtack's pomodoro to have logging capability, I use pomidor instead, cause your defadvice is what I really need.

I disabled tic tac sounds and change default overwork sound. I have two different sounds to remind me that works is over and other work need to be started. Next time, maybe I want to use other notification method in case I work in quite room.

(defadvice pomidor-stop (before pomidor-save-log activate)
  "Log pomidor data to the ~/pomidor-log.csv file.
Columns: date,work,overwork,break"
  (write-region (format "%s,%d,%d,%d\n"
                        (format-time-string "%d/%m/%Y")
                        (time-to-seconds (pomidor-work-duration))
                        (time-to-seconds (or (pomidor-overwork-duration) 0))
                        (time-to-seconds (or (pomidor-break-duration) 0)))
                nil
                "~/pomidor-log.csv"
                'append))

This advice work well for me. Thank you very much for the code.

Thank you for pomidor.

azzamsa commented 6 years ago

I am curious why you use seconds instead of minutes to put in the log.

28/06/2018 | 34 | 0 | 0 |  
28/06/2018 | 425 | 0 | 0 |  
28/06/2018 | 427 | 0 | 0 |  

I think minutes will be much more efficient :)

Any other more efficient way to make those seconds into minutes, other than this ?

(/ (time-to-seconds (pomidor-work-duration)) 60)

I also don't understand the result of pomidor-work-duration

ELISP> (pomidor-work-duration)
(0 856 203521 515000)
TatriX commented 6 years ago

I don't really use logs myself, so it was just an example.

See C-h f current-time for documentation about elisp's time representation.

azzamsa commented 6 years ago

Yes. I visited that page before asking :)

I use this code instead.

(defadvice pomidor-stop (before pomidor-save-log activate)
    "Log pomidor data to the ~/pomidor-log.csv file.
Columns: date,work,overwork,break"
    (write-region (format "%s,%d,%d,%d\n"
                          (format-time-string "%d/%m/%Y")
                          (/ (time-to-seconds (pomidor-work-duration)) 60)
                          (/ (time-to-seconds (or (pomidor-overwork-duration) 0)) 60)
                          (/ (time-to-seconds (or (pomidor-break-duration) 0)) 60))
                  nil
                  "~/pomidor-log.csv"
                  'append))

thank you for pomidor.