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

add branch name to payload #27

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

FilipHarald
Copy link
Contributor

@FilipHarald FilipHarald commented May 15, 2022

A second try at adding branch name to payload #19 . This time with 5-second cache to reduce calls to systemlist, hopefully resolving #26 .

@FilipHarald
Copy link
Contributor Author

Still learning vimscript. @ErikBjare @johan-bjareholt , let me know if I can improve anything.

@@ -105,6 +107,20 @@ function! s:CreateBucket()
call HTTPPostJson(s:bucket_apiurl, l:body)
endfunc

function! s:GetGitBranch(localtime)
if a:localtime - s:last_branch_update > 5
let l:cmd_result = systemlist('git branch --show-current')[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call is still synchronous. So while it's an improvement, there's still a risk of VIM freezing when doing s blocking operation like systemlist. It would be optimal if we did something similar as in HTTPPostJson with jobstart.

@FilipHarald
Copy link
Contributor Author

@johan-bjareholt I think this will work. I update the branch async, but the branch is still sent with the rest of the data. I think this is preferred over sending it in a separate heartbeat?

@FilipHarald
Copy link
Contributor Author

FilipHarald commented May 21, 2022

@johan-bjareholt , do you want to have something added to the README about how to access the data through the query-api?
Like so:

afk_events = query_bucket(find_bucket("aw-watcher-afk_"));
editor_events = query_bucket(find_bucket("aw-watcher-vim_"));
editor_events = filter_period_intersect(editor_events, filter_keyvals(afk_events, "status", ["not-afk"]));
merged_events = merge_events_by_keys(editor_events, ["branch"]);
RETURN = sort_by_duration(merged_events);

@ErikBjare
Copy link
Member

do you want to have something added to the README about how to access the data through the query-api?

@FilipHarald That would be nice :)

Copy link
Member

@ErikBjare ErikBjare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Would like a review from @johan-bjareholt too though.

function! s:RefreshGitBranch(localtime)
if a:localtime - s:last_branch_update > 5
let s:last_branch_update = a:localtime
let l:cmd_result = systemlist('git branch --show-current')[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like I said before, systemlist is a synchronous operation and needs to be replaced with something asynchronous such as jobstart/job_start.

@varac
Copy link

varac commented Feb 6, 2023

@FilipHarald This is pretty stale already but I'd love to get this merged, any chance you would continue with this ?

@FilipHarald
Copy link
Contributor Author

@varac it helps a little bit now that I know that someone needs it :) I will see what I can do. No promises though!

@FilipHarald
Copy link
Contributor Author

@johan-bjareholt I made a second try now.

Also, instead of doing N/A for when not a git-repo, I'm just splitting the tag completely.

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

Successfully merging this pull request may close these issues.

4 participants