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

File statistics #80

Closed
Syndamia opened this issue Jan 4, 2021 · 15 comments
Closed

File statistics #80

Syndamia opened this issue Jan 4, 2021 · 15 comments
Assignees
Labels

Comments

@Syndamia
Copy link

Syndamia commented Jan 4, 2021

I would like to be able to get info for how long I've been working on a given file, not only on a given project. This is especially important for the "unknown" project.

@muety muety added the enhancement New feature or request label Jan 4, 2021
@muety
Copy link
Owner

muety commented Jan 4, 2021

Great feature request. I'm thinking of adding another bar- or pie chart for this. However, the file statistics should be project-specific, otherwise, things would become too messy. There could be a drop-down to select a specific project for which file statistics are shown then.

@Syndamia
Copy link
Author

Syndamia commented Jan 4, 2021

the file statistics should be project-specific [...] drop-down to select a specific project

Honestly, this is more than perfect. File statistics per project will be extremely useful but statistics for all files in general won't be that helpful, in my opinion.

@muety
Copy link
Owner

muety commented Jan 4, 2021

I'll add this feature to my project roadmap. But please be aware that this is a change of more than just a few lines of code, as a whole new SummaryType will have to be introduced, so it might take a bit.

@Syndamia
Copy link
Author

Syndamia commented Jan 4, 2021

No worries, I know how FOSS projects, developed by one guy go. Also, is the file data being collected right now (and just not displayed)?

@muety
Copy link
Owner

muety commented Jan 4, 2021

is the file data being collected right now

Yes, every heartbeat sent by the Wakatime CLI contains an entity field, which is the absolute file system path of the file subject to this heartbeat. This path is already used to try to infer unknown / custom languages from the file's ending.

@muety
Copy link
Owner

muety commented Jan 8, 2021

What would you like to be considered a "file"?

A raw heartbeat looks like so:

[
  {
    "time": 1610092483.0600193,
    "entity": "/home/ferdinand/dev/website-watcher-script/adapters/email.py",
    "type": "file",
    "category": null,
    "is_write": false,
    "project": "website-watcher",
    "branch": "master",
    "language": "Python",
    "dependencies": [],
    "lines": 77,
    "lineno": null,
    "cursorpos": null,
    "user_agent": "wakatime/13.0.7 (Linux-5.9.16-200.fc33.x86_64-x86_64-with-glibc2.4) Python3.8.0.final.0 vscode/1.50.1 vscode-wakatime/5.0.0"
  }
]

Probably it would be cool to have a file path relative to the project root, i.e. adapters/email.py in this case. Unfortunately, we only have the entire, absolute file paths. That is, if you're working on the same file of the same project on two different machines, they files are no necessarily considered the same unless the whole absolute file path is identical, too.

Would this still be acceptable for you? Or do you have any further ideas?

@Syndamia
Copy link
Author

Syndamia commented Jan 8, 2021

Oh, this will be more than enough! The only thing that comes to mind, is that in WakaTime, it shows just the file name and when you hover over it, the full path is shown:
Peek 2021-01-08 10-03
But even if you don't implement that, it won't be a big deal!

@muety muety added the prio c label Jan 12, 2021
@muety muety added the effort:3 label Jan 26, 2021
@hypervtechnics
Copy link

This would be great. Just a question: How would editing the same project on different machines would be handled? Especially when the project is in a different path?

@muety
Copy link
Owner

muety commented May 7, 2021

The easiest way would be to aggregate by the unique, absolute file paths. However, editing the same file on two different computers under two different paths would result in it being considered two separate files. I.e. /home/ferdinand/proj1/file.go and /home/ferdinand-work/proj1/file.go would be considered two distinct entities.

If you can come up with a smarter solution how to address this issues, feel free to share your thoughts.

@hypervtechnics
Copy link

Well the only thing doable for me is taking the project field of the heartbeat into account. This would mean comparing filepaths from the right and summarizing heartbeats when they have the same project. Although this would cause issues when you e.g. have the same filename in multiple directories as we don't have a project path.

@muety
Copy link
Owner

muety commented May 7, 2021

Although this would cause issues when you e.g. have the same filename in multiple directories as we don't have a project path

Yes, right, the project name is not necessarily an infix of the file's path. You could well have a project called webapp located at ~/dev/web-app-frontend. That has to be kept in mind.

@hypervtechnics
Copy link

Another why I could imagine is additionally taking the machine field into account. Then grouping by project is possible as the project path is available (calculatable by evaluating all file paths + project + machine and taking the path beginning equal for all file paths). Although this would cause issues with the WSL as the machine name is the same but a different file system and therefore other paths might be used. But I think thats okay, as one might solve this using (project maps)?

@muety
Copy link
Owner

muety commented Oct 13, 2021

I revisited this issue while planning the feature for v2. Just for the record, what WakaTime does is group file paths by projects and ignore the fact that those paths may vary for same project on different machines. Here's an example from the durations endpoint:

{
    "branches": [],
    "data": [
        {
            "branch": "",
            "dependencies": [],
            "duration": 19.376436,
            "entity": "/tmp/my-new-project-1/src/index.js",
            "language": "JavaScript",
            "project": "my-new-project-1",
            "time": 1634130204.408579,
            "type": "file"
        },
        {
            "branch": "",
            "dependencies": [],
            "duration": 70.211374,
            "entity": "/tmp/my-new-project-1/src/utils.js",
            "language": "JavaScript",
            "project": "my-new-project-1",
            "time": 1634130223.785015,
            "type": "file"
        },
        {
            "branch": "",
            "dependencies": [],
            "duration": 6.22923,
            "entity": "/home/ferdinand/dev/my-new-project-1/src/index.js",
            "language": "JavaScript",
            "project": "my-new-project-1",
            "time": 1634130293.996389,
            "type": "file"
        },
        {
            "branch": "",
            "dependencies": [],
            "duration": 3.001593,
            "entity": "/home/ferdinand/dev/my-new-project-1/src/app.js",
            "language": "JavaScript",
            "project": "my-new-project-1",
            "time": 1634130300.225619,
            "type": "file"
        }
    ],
    "end": "2021-10-13T21:59:59Z",
    "start": "2021-10-12T22:00:00Z",
    "timezone": "Europe/Berlin"
}

I want to implement this the same way. Files without a project (project field in the heartbeat being null) are disregarded.

@muety muety added the blocked label Oct 13, 2021
@muety muety modified the milestone: v2 Oct 13, 2021
@muety muety added prio b and removed prio c labels Oct 13, 2021
@muety muety mentioned this issue Oct 30, 2021
@muety
Copy link
Owner

muety commented Dec 14, 2021

I thought about this again and decided that Wakapi is not going to implement file statistics. Sorry for all shattered hopes.

@muety
Copy link
Owner

muety commented Mar 16, 2023

File statistics are required in order to display domains / web pages for the Chrome / Firefox plugin. I guess we'll add them in, after all.

Implementation will be analogously to branches. Also, in WakaTime /home/ferdi/wakapi.go and ~/wakapi.go are interpreted as two distinct files, so I'm feeling comfortable with simply doing it the same way.

Can't give a promise about how soon I'll get to this, though. Sorry!

@muety muety reopened this Mar 16, 2023
@muety muety added prio a and removed blocked labels Mar 16, 2023
@muety muety self-assigned this Mar 16, 2023
@muety muety closed this as completed in 4ee3da6 Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants