-
Notifications
You must be signed in to change notification settings - Fork 275
Conversation
56f7021
to
5eeb48f
Compare
It looks like |
Absolutely. I'll get on it . |
5eeb48f
to
278c168
Compare
I have absolutely no clue why apm decided to alter the returned JSON from its own API to make Anyway, the API allows for a Here's the version that I wrote while investigating a different issue. I think the only thing that's missing from this one is the changing of new Promise (resolve, reject) ->
qs = {q: query}
if options.themes
qs.filter = 'theme'
else if options.packages
qs.filter = 'package'
if options.sortBy
qs.sort = options.sortBy
options = {
url: "https://atom.io/api/packages/search"
headers: {'User-Agent': navigator.userAgent}
qs: qs
json: true
}
request options, (err, res, body) ->
if err
error = new Error("Searching for \u201C#{query}\u201D failed.")
error.stderr = err.message
reject(error)
else
resolve(body) |
@50Wliu thank you for the feedback. I made some changes based on your version, should look nicer now. |
lib/install-panel.js
Outdated
const opts = {} | ||
opts[this.searchType] = true | ||
opts['sortBy'] = 'downloads' | ||
const options = {sort: {downloads: 'desc'}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should just be const options = {sort: 'downloads'}
. The atom.io API is documented at https://flight-manual.atom.io/atom-server-side-apis/sections/atom-package-server-api/. Though it seems like the direction
parameter is a bit broken for downloads because I can't get it to sort ascending...luckily we sort descending 😀.
Also, seems weird how we sort by downloads. Now that the relevance sorting has been improved maybe we can default to relevance instead, probably in a different PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering sorting was not done before, I am guessing it can be straight omitted and perhaps the reason why it works is because it has no effect (unconfirmed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it was because of the garbage value in sort field why it seemed to work.
However, when properly sorting on serverside vs not sorting at all, we are getting way different results. The default, unsorted search seems to give more relevant results compared to what is popular, but less relevant. I will roll back the sorting part from last night.
lib/atom-io-client.coffee
Outdated
} | ||
|
||
new Promise (resolve, reject) -> | ||
request options, (err, res, body) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unfamiliar with proxying but is there anything special that needs to be done here to avoid proxy issues?
EDIT: Seems like some ongoing proxy work in #1010 that you could look at.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if @httpsProxy?
options.proxy = @httpsProxy
if @strictSsl is false
options.rejectUnauthorized = false
is what is needed to be added to the request options when that pull request is merged.
7ba72a3
to
c8efff1
Compare
Packages containing the search term will be moved to the top with the exact match always being the first one if there is one. This is done later in the process. settings-view/lib/install-panel.js Lines 221 to 223 in 9315802
|
Gzip compression was enabled 🎉 . Seeing additional ~100ms improvement, but I will try rerunning the measurements from the opening post to get more accurate numbers. Currently on a moving bus with 4G internet, I am seeing sub-second or close-to-a-second overall response times.
Update: For some reason I am not getting quite 100ms improvement on |
Description of the Change
This pull request implements the search capability equivalent to previously used
apm search --json (--packages|--themes)? term
, sorted by download count in descending order. Measuring the web request that is done insideapm
, with ~118ms network latency it takes around 750-800ms to respond (according to Chrome devtools), whereas the total execution time forapm search
takes around 1.5 seconds.Searching for
github
and measuring usingperformance.now()
:Before:
packageManager.search()
1587ms averageAfter:
client.search()
853ms averageAlthough using just
apm
would be cleaner, this is a significant gain in terms of perceived responsiveness. Search functionality doesn't depend onapm
existing in any way and being one of the most frequently used parts of settings-view where user has to wait, it makes sense to reduce any delays where possible. Ideally there should be a library which bothsettings-view
andapm
use as that eliminates the duplication concern.It is possible that by enabling compression at atom.io, the request response time can be further improved, making responses a fair amount faster on slower connections as huge amounts of text typically compress well.
Alternate Designs
None considered.
Benefits
Search returns faster ⚡️, doesn't feel as slow to the user.
Possible Drawbacks
A little bit more code duplication between
apm
and this package.Applicable Issues
None.