Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
3fe18c01
Commit
3fe18c01
authored
Sep 10, 2014
by
Gergely Ujvari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get rid of normalize parameter
We judge whether to normalize or not by the variable type
parent
12d2b302
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
24 deletions
+13
-24
searchfilters.coffee
h/static/scripts/searchfilters.coffee
+3
-15
services.coffee
h/static/scripts/services.coffee
+10
-9
No files found.
h/static/scripts/searchfilters.coffee
View file @
3fe18c01
...
...
@@ -50,7 +50,6 @@ class SearchFilter
# [facet_name]:
# [operator]: 'and'|'or'|'min' (for the elements of the facet terms list)
# [lowercase]: true|false
# [normalize]: true|flase (unicode normalization)
# [terms]: an array for the matched terms for this facet
# The facet selection is done by analyzing each token.
# It generally expects a <facet_name>:<facet_term> structure for a token
...
...
@@ -120,42 +119,34 @@ class SearchFilter
terms
:
any
operator
:
'and'
lowercase
:
true
normalize
:
true
quote
:
terms
:
quote
operator
:
'and'
lowercase
:
true
normalize
:
true
result
:
terms
:
result
operator
:
'min'
lowercase
:
false
normalize
:
false
since
:
terms
:
since
operator
:
'and'
lowercase
:
false
normalize
:
false
tag
:
terms
:
tag
operator
:
'and'
lowercase
:
true
normalize
:
true
text
:
terms
:
text
operator
:
'and'
lowercase
:
true
normalize
:
true
uri
:
terms
:
uri
operator
:
'or'
lowercase
:
true
normalize
:
true
user
:
terms
:
user
operator
:
'or'
lowercase
:
true
normalize
:
true
# This class will process the results of search and generate the correct filter
# It expects the following dict format as rules
...
...
@@ -163,7 +154,6 @@ class SearchFilter
# formatter: to format the value (optional)
# path: json path mapping to the annotation field
# case_sensitive: true|false (default: false)
# normalize: true| false (default: false)
# and_or: and|or for multiple values should it threat them as 'or' or 'and' (def: or)
# operator: if given it'll use this operator regardless of other circumstances
#
...
...
@@ -253,7 +243,6 @@ class QueryParser
# Now generate the clause with the help of the rule
case_sensitive
=
if
rule
.
case_sensitive
?
then
rule
.
case_sensitive
else
false
normalize
=
if
value
.
normalize
?
then
value
.
normalize
else
false
and_or
=
if
rule
.
and_or
?
then
rule
.
and_or
else
'or'
mapped_field
=
if
rule
.
path
?
then
rule
.
path
else
'/'
+
category
...
...
@@ -265,12 +254,12 @@ class QueryParser
t
=
if
rule
.
formatter
then
rule
.
formatter
term
else
term
value_part
.
push
t
filter
.
addClause
mapped_field
,
oper_part
,
value_part
,
case_sensitive
,
normalize
,
rule
.
options
filter
.
addClause
mapped_field
,
oper_part
,
value_part
,
case_sensitive
,
rule
.
options
else
oper_part
=
if
rule
.
operator
?
then
rule
.
operator
else
'matches'
for
val
in
terms
value_part
=
if
rule
.
formatter
then
rule
.
formatter
val
else
val
filter
.
addClause
mapped_field
,
oper_part
,
value_part
,
case_sensitive
,
normalize
,
rule
.
options
filter
.
addClause
mapped_field
,
oper_part
,
value_part
,
case_sensitive
,
rule
.
options
class
StreamFilter
...
...
@@ -355,13 +344,12 @@ class StreamFilter
@
filter
.
clauses
=
[]
this
addClause
:
(
field
,
operator
,
value
,
case_sensitive
=
false
,
normalize
=
false
,
options
=
{})
->
addClause
:
(
field
,
operator
,
value
,
case_sensitive
=
false
,
options
=
{})
->
@
filter
.
clauses
.
push
field
:
field
operator
:
operator
value
:
value
case_sensitive
:
case_sensitive
normalize
:
normalize
options
:
options
this
...
...
h/static/scripts/services.coffee
View file @
3fe18c01
...
...
@@ -439,7 +439,10 @@ class ViewFilter
constructor
:
(
searchfilter
,
stringHelpers
)
->
@
searchfilter
=
searchfilter
@
_normalize
=
(
e
)
->
stringHelpers
.
unidecode
(
e
)
@
_normalize
=
(
e
)
->
if
typeof
e
is
'string'
return
stringHelpers
.
unidecode
(
e
)
else
return
e
_matches
:
(
filter
,
value
,
match
)
->
matches
=
true
...
...
@@ -485,12 +488,12 @@ class ViewFilter
if
angular
.
isArray
value
if
filter
.
lowercase
value
=
value
.
map
(
e
)
->
e
.
toLowerCase
()
if
filter
.
normalize
value
=
value
.
map
(
e
)
=>
@
_normalize
(
e
)
value
=
value
.
map
(
e
)
=>
@
_normalize
(
e
)
return
@
_arrayMatches
filter
,
value
,
checker
.
match
else
value
=
value
.
toLowerCase
()
if
filter
.
lowercase
value
=
@
_normalize
(
value
)
if
filter
.
normalize
value
=
@
_normalize
(
value
)
return
@
_matches
filter
,
value
,
checker
.
match
# Filters a set of annotations, according to a given query.
...
...
@@ -527,8 +530,7 @@ class ViewFilter
for
_
,
filter
of
filters
if
filter
.
lowercase
filter
.
terms
=
filter
.
terms
.
map
(
e
)
->
e
.
toLowerCase
()
if
filter
.
normalize
filter
.
terms
=
filter
.
terms
.
map
(
e
)
=>
@
_normalize
(
e
)
filter
.
terms
=
filter
.
terms
.
map
(
e
)
=>
@
_normalize
(
e
)
# Now that this filter is called with the top level annotations, we have to add the children too
annotationsWithChildren
=
[]
...
...
@@ -564,11 +566,10 @@ class ViewFilter
if
angular
.
isArray
value
if
filter
.
lowercase
value
=
value
.
map
(
e
)
->
e
.
toLowerCase
()
if
filter
.
normalize
value
=
value
.
map
(
e
)
=>
@
_normalize
(
e
)
value
=
value
.
map
(
e
)
=>
@
_normalize
(
e
)
else
value
=
value
.
toLowerCase
()
if
filter
.
lowercase
value
=
@
_normalize
(
value
)
if
filter
.
normalize
value
=
@
_normalize
(
value
)
matchresult
=
@
_anyMatches
filter
,
value
,
conf
.
match
matchterms
=
matchterms
.
map
(
t
,
i
)
->
t
or
matchresult
[
i
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment