[ARVADOS] created: 9a9e79d72b7e3d31df178f5c08f2624cd22d9d1c
Git user
git at public.curoverse.com
Thu Sep 7 21:40:08 EDT 2017
at 9a9e79d72b7e3d31df178f5c08f2624cd22d9d1c (commit)
commit 9a9e79d72b7e3d31df178f5c08f2624cd22d9d1c
Author: Tom Clegg <tclegg at veritasgenetics.com>
Date: Thu Sep 7 21:08:57 2017 -0400
12194: Fix accidentally mutated argument.
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>
diff --git a/apps/workbench/app/assets/javascripts/components/collections.js b/apps/workbench/app/assets/javascripts/components/collections.js
index fa13552..33fca6c 100644
--- a/apps/workbench/app/assets/javascripts/components/collections.js
+++ b/apps/workbench/app/assets/javascripts/components/collections.js
@@ -102,8 +102,10 @@ window.CollectionsSearch = {
sessionKey: key,
loadFunc: function(filters) {
var tsquery = to_tsquery(q)
- if (tsquery)
+ if (tsquery) {
+ filters = filters.slice(0)
filters.push(['any', '@@', tsquery])
+ }
return vnode.state.sessionDB.request(session, 'arvados/v1/collections', {
data: {
filters: JSON.stringify(filters),
commit 059027a1ea97b853649bad7e85a0d2da254f3178
Author: Tom Clegg <tclegg at veritasgenetics.com>
Date: Thu Sep 7 21:03:38 2017 -0400
12194: Construct @@ operands more carefully to avoid bad API munge.
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>
diff --git a/apps/workbench/app/assets/javascripts/components/collections.js b/apps/workbench/app/assets/javascripts/components/collections.js
index 6022889..fa13552 100644
--- a/apps/workbench/app/assets/javascripts/components/collections.js
+++ b/apps/workbench/app/assets/javascripts/components/collections.js
@@ -101,8 +101,9 @@ window.CollectionsSearch = {
return new MultipageLoader({
sessionKey: key,
loadFunc: function(filters) {
- if (q)
- filters.push(['any', '@@', q+':*'])
+ var tsquery = to_tsquery(q)
+ if (tsquery)
+ filters.push(['any', '@@', tsquery])
return vnode.state.sessionDB.request(session, 'arvados/v1/collections', {
data: {
filters: JSON.stringify(filters),
diff --git a/apps/workbench/app/assets/javascripts/filterable.js b/apps/workbench/app/assets/javascripts/filterable.js
index 938ad80..c85d40f 100644
--- a/apps/workbench/app/assets/javascripts/filterable.js
+++ b/apps/workbench/app/assets/javascripts/filterable.js
@@ -56,10 +56,11 @@
function updateFilterableQueryNow($target) {
var newquery = $target.data('filterable-query-new');
var params = $target.data('infinite-content-params-filterable') || {};
- if (newquery == null || newquery == '') {
- params.filters = [];
+ var tsquery = to_tsquery(newquery);
+ if (newquery == null) {
+ params.filters = [];
} else {
- params.filters = [['any', '@@', newquery.trim().concat(':*')]];
+ params.filters = [['any', '@@', tsquery]];
}
$(".modal-dialog-preview-pane").html("");
$target.data('infinite-content-params-filterable', params);
diff --git a/apps/workbench/app/assets/javascripts/to_tsquery.js b/apps/workbench/app/assets/javascripts/to_tsquery.js
new file mode 100644
index 0000000..0192d1f
--- /dev/null
+++ b/apps/workbench/app/assets/javascripts/to_tsquery.js
@@ -0,0 +1,23 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+// to_tsquery() converts a user-entered search query to a useful
+// operand for the Arvados API "@@" filter. It returns null if it
+// can't come up with anything valid (e.g., q consists entirely of
+// punctuation).
+//
+// Examples:
+//
+// "foo" => "foo:*"
+// "foo/bar" => "foo:*&bar:*"
+// "foo|bar" => "foo:*&bar:*"
+// " oo|ba " => "oo:*&ba:*"
+// "// " => null
+// "" => null
+window.to_tsquery = function(q) {
+ q = q.replace(/\W+/g, ' ').trim().replace(/ /g, ':*&')
+ if (q == '')
+ return null
+ return q + ':*'
+}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list