zagortenay333 / cronomix

All-in-one timer, stopwatch, pomodoro, alarm, todo and time tracker gnome-shell extension
MIT License
581 stars 75 forks source link

Time tracker logging time #85

Closed Rj7 closed 5 years ago

Rj7 commented 5 years ago

I have been not able to use time tracking since I updated the extensions some 10 days ago. I had tried reinstalling/ resetting gnome multiple times and I still face this problem. I had this problem in gnome 3.28 and still have this problem in gnome 3.30. Had this problem in ubuntu 18.04 and 18.10 ( after updating )

This is how my TODAY_time_tracker.csv looks

raja@raja1:~/Documents/time++$ cat TODAY__time_tracker.csv 
2018-12-19, 00:00:00, ++, "+pnl", 20:27:27..20:27:27..
2018-12-19, 00:00:00, (), "2018-12-17 TT1815 +pnl ", 20:27:27..20:27:27..
raja@raja1:~/Documents/time++$ cat TODAY__time_tracker.csv 
2018-12-19, 00:00:00, ++, "+pnl", 20:27:29..20:27:29..
2018-12-19, 00:00:00, (), "2018-12-17 TT1815 +pnl ", 20:27:29..20:27:29..
raja@raja1:~/Documents/time++$ cat TODAY__time_tracker.csv 
2018-12-19, 00:00:00, ++, "+pnl", 20:27:30..20:27:30..
2018-12-19, 00:00:00, (), "2018-12-17 TT1815 +pnl ", 20:27:30..20:27:30..
raja@raja1:~/Documents/time++$ cat TODAY__time_tracker.csv 
2018-12-19, 00:00:00, ++, "+pnl", 20:27:34..20:27:34..
2018-12-19, 00:00:00, (), "2018-12-17 TT1815 +pnl ", 20:27:34..20:27:34..

When I turn off restart after abrupt restart I am not able to start timer for any tasks. If I leave it on, my start time and end time for the task gets updated to my current time. Find the log for journalctl /usr/bin/gnome-shell -f -o cat in this gist here

Would really appreciate a fix / solution for this because I love this extension so much.

zagortenay333 commented 5 years ago

Are you keeping your csv files in dropbox or something like that?

Rj7 commented 5 years ago

@zagortenay333 No I am not keeping my csv files in dropbox or any other service. I tried changing my folder location too. Somehow the logging the start time and end time is messed. Couldn't find a solution in your github issues.

zagortenay333 commented 5 years ago

Did you try using the github version?

Rj7 commented 5 years ago

@zagortenay333 Yes I did. I had the same problem. Another he icon for pomodoro doesn't show up in version from gnome. And it shows up in the version from github.

zagortenay333 commented 5 years ago

The tracker will stop whenever the csv file is updated externally. Internally, I disable the file monitors before I attempt to write to the file.

So either I'm failing to disable the file monitors which immediately turns the tracker off (probably), or something on your system updates the file.

Could you throw in a little print statement here just to check this theory: https://github.com/zagortenay333/timepp__gnome/blob/master/sections/todo/time_tracker.js#L171-L172

Something like log(">>>>>>>>>>>>>>>> TIMEPP FILES MODIFIED"). Check in the journalctl output.

I don't know what to do here honestly; I've been struggling with these freakin' gnome file monitors since the start...

witpok commented 5 years ago

Hi @zagortenay333, I jump in as I have the same problem. Since last update (I did it on Thursday I think) all my attempts to track time result in 1s long time spans. I have inserted logging as you have described and in journalctl output I have a lot of: gru 23 21:23:53 pc tracker-miner-f[3144]: (Sparql buffer) Error in task 0 (--my-docs-path--/time/TODAY__time_tracker.csv) of the array-update: UNIQUE constraint failed: nie:DataObject.nie:url gru 23 21:23:53 pc tracker-miner-f[3144]: Could not execute sparql: UNIQUE constraint failed: nie:DataObject.nie:url and those fire several times each second when the tracker is running. Any other help needed, just let me know. ps. I use the gnome-extensions version, haven't tried with github one.

zagortenay333 commented 5 years ago

@witpok , just throwing a wild guess here: do you have the gnome tracker (the file tracker) running and could you disable it?

Also, could you try the version of timepp on this commit: https://github.com/zagortenay333/timepp__gnome/tree/cb04983a5b14ec6ca8e23ea044f11b34d82a864d

Rj7 commented 5 years ago

@zagortenay333 I tried adding logging in _on_tracker_files_modified. When I start a task, it logs multiple times a second. Looks like something is modifying that folder. But I don't have gnome tracker installed it seems. I am not able to find. I just installed it sudo apt install tracker and will try to stop indexing from timepp folder

Rj7 commented 5 years ago

I disabled tracking in org.freedesktop.Tracker.Miner.Files enable-monitors and that doesn't fix the problem.

Rj7 commented 5 years ago

@zagortenay333 This version that you linked above works fine. I tried that version with tracker (enabled and disabled) and by purging the tracker. It worked in all of those scenarios. Anyways I will stick to this version for now, I guess. Thanks :+1:

@witpok , just throwing a wild guess here: do you have the gnome tracker (the file tracker) running and could you disable it?

Also, could you try the version of timepp on this commit: https://github.com/zagortenay333/timepp__gnome/tree/cb04983a5b14ec6ca8e23ea044f11b34d82a864d

zagortenay333 commented 5 years ago

Yeah, so the problem is definitely that the way I disable the file monitor prior to writing to the csv file doesn't work on your machine...

witpok commented 5 years ago

@zagortenay333 can confirm, github version works fine.

zagortenay333 commented 5 years ago

@witpok which version? Master branch?

witpok commented 5 years ago

@zagortenay333 the one linked above, https://github.com/zagortenay333/timepp__gnome/tree/cb04983a5b14ec6ca8e23ea044f11b34d82a864d

witpok commented 5 years ago

@zagortenay333 hi, I have reinstalled this extension with gnome extensions version (as it showed there is an update available) but it is not tracking time. I have removed it, then reinstalled latest version from this repository, but time tracking is still not working. I have the same errors as before - Could not execute sparql: UNIQUE constraint failed: nie:DataObject.nie:url Is there any progress here to fix that?

zexiangliu commented 5 years ago

I encountered the same issue and spent some time looking into this problem.

First, I checked with is_cancelled() after the line disabling the file monitor. It says that the monitor is canceled successfully.

However, even if the monitor is disabled before writing csv file, the callback function is still triggered after enabling the file monitor. I even tried to disconnect the "changed" signal while canceling the monitor, but the issue still exists.

Hope this observation can help. For now I have to disable the file monitor to make time tracking function work.

zexiangliu commented 5 years ago

@zagortenay333 I found out that whenever the file monitor is re-enabled after a file writing behavior, the file monitor starts before the writing process finishes. So I tried to add a 100ms timeout before re-enables the file monitor and that solved the issue. The modification to function _enable_file_monitors() is like the following:

    _enable_file_monitors () {
        Mainloop.timeout_add(100,()=>{
            [this.daily_csv_file_monitor,] = MISC_UTILS.file_monitor(this.daily_csv_file, () => {
                this._on_tracker_files_modified();
            });

            [this.yearly_csv_file_monitor,] = MISC_UTILS.file_monitor(this.yearly_csv_file, () => {
                this._on_tracker_files_modified();
            });

            [this.yearly_csv_dir_monitor,] = MISC_UTILS.file_monitor(this.yearly_csv_dir, () => {
                this._on_tracker_files_modified();
            });
        });

Suggestions: When I tested the code, I realized that you don't need to remove and re-create the file monitor each time modifying a file. It might be cheaper to just disconnect the 'changed' signal from the monitor using the function GFileMonitor.disconnect(monitor_id).

zagortenay333 commented 5 years ago

Pull requests are welcome.

witpok commented 5 years ago

@zexiangliu Can confirm, your fix is working.