Skip to content

Commit cb897fa

Browse files
committed
Further revise username and project completion
This reverts most of the code to the "simpler" calling convention. It also drops the initial rank-based ordering (which didn't appear to influence the result ordering). The other significant change is that we now quote the query string to avoid stemming, which keeps the results more focused on the original search term. The change also includes a bug fix for the previous change. We once again avoid sending the `contraints[query]` parameter when we don't have a query term (i.e. it's empty).
1 parent ceec162 commit cb897fa

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

autoload/phabricator.vim

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function! s:api_root() abort
6161
return api_root
6262
endfunction
6363

64-
function! s:request(method, params) abort
64+
function! s:request(method, order, query) abort
6565
if !executable('curl')
6666
call s:throw('cURL is required')
6767
endif
@@ -80,9 +80,10 @@ function! s:request(method, params) abort
8080
call extend(args, ['-A', 'vim-phabricator'])
8181
call extend(args, ['-d', 'api.token=' . token])
8282
call extend(args, ['-d', 'queryKey=active'])
83-
for [key, value] in items(a:params)
84-
call extend(args, ['-d', key . '=' . value])
85-
endfor
83+
call extend(args, ['-d', 'order[0]=' . a:order])
84+
if !empty(a:query)
85+
call extend(args, ['-d', 'constraints[query]=core%3A~"' . a:query . '"'])
86+
endif
8687
call add(args, s:api_root() . a:method)
8788

8889
let data = system('curl ' . join(args))
@@ -99,19 +100,11 @@ function! s:request(method, params) abort
99100
endfunction
100101

101102
function! phabricator#query_projects(query) abort
102-
return s:request('project.search', {
103-
\ 'order[0]': 'rank',
104-
\ 'order[1]': 'name',
105-
\ 'constraints[query]': 'core%3A~' . a:query,
106-
\ })
103+
return s:request('project.search', 'name', a:query)
107104
endfunction
108105

109106
function! phabricator#query_users(query) abort
110-
return s:request('user.search', {
111-
\ 'order[0]': 'rank',
112-
\ 'order[1]': 'username',
113-
\ 'constraints[query]': 'core%3A~' . a:query,
114-
\ })
107+
return s:request('user.search', 'username', a:query)
115108
endfunction
116109

117110
function! phabricator#complete(findstart, base) abort

0 commit comments

Comments
 (0)