Merge lp://qastaging/~mhr3/unity-lens-applications/secondary-sorting into lp://qastaging/unity-lens-applications

Proposed by Michal Hruby
Status: Merged
Approved by: Mikkel Kamstrup Erlandsen
Approved revision: 276
Merged at revision: 276
Proposed branch: lp://qastaging/~mhr3/unity-lens-applications/secondary-sorting
Merge into: lp://qastaging/unity-lens-applications
Diff against target: 256 lines (+120/-20)
4 files modified
src/daemon.vala (+115/-18)
src/unity-package-search.cc (+3/-1)
src/unity-package-search.h (+1/-0)
vapi/unity-package-search.vapi (+1/-1)
To merge this branch: bzr merge lp://qastaging/~mhr3/unity-lens-applications/secondary-sorting
Reviewer Review Type Date Requested Status
Mikkel Kamstrup Erlandsen (community) Approve
Review via email: mp+96993@code.qastaging.launchpad.net

Commit message

Cluster applications according to relevancy of the match when searching and if multiple applications fall into the same cluster sort them according to frequency of use.

Description of the change

Implements secondary sorting of applications based on frequency of use.

To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote :

Note that there are pending changes to the lens view (it should display just 6 recent apps and these should be only filtered out on search), so currently this affects only the home view.

274. By Michal Hruby

Make sure we check the cancellable after updating popularities

Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

52 + if (popularities_dirty)
53 + yield update_popularities ();

Check for cancellation after here?

91 + popularity_map[uri] = relevancy--;

Should the decrement not be moved to the outermost for-loop? If one event has many apps they should all rank alike, no?

139 + results.results.sort_with_data ((a, b) =>
140 + {
141 + int rel_a = a.relevancy / 10;
142 + int rel_b = b.relevancy / 10;
        ...

Can you add a comment explaining the sorting please (also noting the rounding trick)? For the uninitiated this will look like dark magic.

I was wondering if it would be a significant speed increase if you simply iterated the results GSList but then inserted the hits sorted in a GSequence. I don't know the performance profile of sorting a GSList, but I'd assume it to be weak... But this prolly clashes with code elsewhere expecting the glist..?

184 + /* Make sure fresh install learns quickly */
185 + if (popularity_map.size <= 5) popularities_dirty = true;

Like this tweak. Clever you are!

review: Needs Information
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

75 + // simulate a kind of frecency

Also - this is not "frecency", but rather "relequency" or "frelevancy" whatever you wanna clal it :-)

Revision history for this message
Michal Hruby (mhr3) wrote :

> kamstrup wrote 4 minutes ago:
> 52 + if (popularities_dirty)
> 53 + yield update_popularities ();
>
> Check for cancellation after here?

8 minutes ago
Make sure we check the cancellable after updating popularities

Received the tachyons ;)

> Should the decrement not be moved to the outermost for-loop? If one event has many apps they should all rank alike, no?

I suppose you're right, at least I don't have to use 256 event limit and magical 512 constant five lines later.

> Can you add a comment explaining the sorting please (also noting the rounding trick)? For the uninitiated this will look like dark magic.

Fixed.

> I was wondering if it would be a significant speed increase if you simply iterated the results GSList but then inserted the hits sorted in a GSequence. I don't know the performance profile of sorting a GSList, but I'd assume it to be weak... But this prolly clashes with code elsewhere expecting the glist..?

I was thinking about this as well, but since there are usually just a few hundred apps (and only a few dozen search hits), the time spent building a sequence and sorting it would probably be higher than just sorting the linked list. (moreover looking at glib's sources it seems to be using mergesort which is O(N logN) therefore a non-issue really).

275. By Michal Hruby

Explain the magical sorting

276. By Michal Hruby

Treat multi-subject events equally

Revision history for this message
Michal Hruby (mhr3) wrote :

> 75 + // simulate a kind of frecency
>
> Also - this is not "frecency", but rather "relequency" or "frelevancy"
> whatever you wanna clal it :-)

Actually that was a comment on the time range I'm using there (only last 3 weeks), so it indeed is frecency in this context. (so overall the sorting is "frecevancy" ;)

Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Great! You have me sold!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches