After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 707055 - SearchDisplay: handle certain result IDs specially
SearchDisplay: handle certain result IDs specially
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: search
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2013-08-29 14:39 UTC by Giovanni Campagna
Modified: 2013-10-14 17:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
SearchDisplay: handle certain result IDs specially (3.27 KB, patch)
2013-08-29 14:40 UTC, Giovanni Campagna
reviewed Details | Review
SearchDisplay: handle certain result IDs specially (2.96 KB, patch)
2013-10-13 17:19 UTC, Giovanni Campagna
none Details | Review
SearchDisplay: handle certain result IDs specially (2.98 KB, patch)
2013-10-13 18:22 UTC, Giovanni Campagna
committed Details | Review

Description Giovanni Campagna 2013-08-29 14:39:57 UTC
Allow the prefix 'special:' applied to result IDs to mark results
that should be always shown, even when they would overflow the
maximum results cap. This will be used by epiphany for the special
"Search the Web" result.
Comment 1 Giovanni Campagna 2013-08-29 14:40:00 UTC
Created attachment 253514 [details] [review]
SearchDisplay: handle certain result IDs specially
Comment 2 Giovanni Campagna 2013-10-13 16:46:35 UTC
This was deferred because it was meant for epiphany, and the search provider was not merged at that time, but now it's in, so we should land this one too.
Comment 3 Florian Müllner 2013-10-13 17:02:40 UTC
Review of attachment 253514 [details] [review]:

::: js/ui/remoteSearch.js
@@ +217,3 @@
+
+        let regularResults = results.filter(function(r) { return !_startsWith(r, 'special:') });
+        let specialResults = results.filter(function(r) { return _startsWith(r, 'special:'); });

Why a custom function instead of r.startsWith('special')?

@@ +219,3 @@
+        let specialResults = results.filter(function(r) { return _startsWith(r, 'special:'); });
+
+        return regularResults.slice(0, maxNumber).concat(specialResults);

So if I think my results are more important than anything, I can just mark all 50 of them as "special" and force them to be displayed? I'd rather see this as

let numSpecials = Math.min(specialResults.length, maxNumber);
let numRegulars = Math.min(regularResults.length - numSpecials, maxNumber);
return regularResults.slice(0, numRegulars).concat(specialResults.slice(0, numSpecials));
Comment 4 Giovanni Campagna 2013-10-13 17:14:31 UTC
(In reply to comment #3)
> Review of attachment 253514 [details] [review]:
> @@ +219,3 @@
> +        let specialResults = results.filter(function(r) { return
> _startsWith(r, 'special:'); });
> +
> +        return regularResults.slice(0, maxNumber).concat(specialResults);
> 
> So if I think my results are more important than anything, I can just mark all
> 50 of them as "special" and force them to be displayed? I'd rather see this as
> 
> let numSpecials = Math.min(specialResults.length, maxNumber);
> let numRegulars = Math.min(regularResults.length - numSpecials, maxNumber);
> return regularResults.slice(0, numRegulars).concat(specialResults.slice(0,
> numSpecials));

No. If you mark all 50 results as special, then you are a bad application author, you will get bug reports and if you don't fix them people will stop using your search provider.
The design calls for 3 regular results and the special one, not 2 + 1.
Comment 5 Giovanni Campagna 2013-10-13 17:19:12 UTC
Created attachment 257181 [details] [review]
SearchDisplay: handle certain result IDs specially

Allow the prefix 'special:' applied to result IDs to mark results
that should be always shown, even when they would overflow the
maximum results cap. This will be used by epiphany for the special
"Search the Web" result.
Comment 6 Florian Müllner 2013-10-13 17:44:59 UTC
(In reply to comment #4)
> 
> No. If you mark all 50 results as special, then you are a bad application
> author

Read this as: "how much want we allow bad application authors to fuck up?" then. We also expect app authors to choose reasonably catchy names, but if they pick "My Supercalifragilisticexpialidocious App" anyway, we deal with it by ellipsizing the name ...


> The design calls for 3 regular results and the special one, not 2 + 1.

So we only expect a single special result? If so, we should enforce that, if not, I'd still prefer some limit (just reusing the normal one being the least arbitrary I suppose, resulting in a max of 3+3)
Comment 7 Giovanni Campagna 2013-10-13 18:22:48 UTC
Created attachment 257186 [details] [review]
SearchDisplay: handle certain result IDs specially

Allow the prefix 'special:' applied to result IDs to mark results
that should be always shown, even when they would overflow the
maximum results cap. This will be used by epiphany for the special
"Search the Web" result.
Comment 8 Florian Müllner 2013-10-13 22:19:30 UTC
Review of attachment 257186 [details] [review]:

OK.
Comment 9 Giovanni Campagna 2013-10-14 16:59:55 UTC
Attachment 257186 [details] pushed as 002afda - SearchDisplay: handle certain result IDs specially