Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Mynij-test
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Mynij
Mynij-test
Commits
852f9e93
Commit
852f9e93
authored
May 29, 2019
by
Alexandra Rogova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
queries work but VERY SLOW (up to 10 seconds)
parent
fb0ce479
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
52 deletions
+19
-52
gadget_result.js
gadget_result.js
+1
-5
search.js
search.js
+18
-47
No files found.
gadget_result.js
View file @
852f9e93
...
@@ -37,10 +37,7 @@
...
@@ -37,10 +37,7 @@
body
.
innerHTML
=
""
;
body
.
innerHTML
=
""
;
list
.
appendChild
(
list_item
);
list
.
appendChild
(
list_item
);
}
else
{
}
else
{
parser
=
new
DOMParser
();
return
this
.
cut_description
(
item
.
description
,
key
)
xmlDoc
=
parser
.
parseFromString
(
item
.
body
,
"
text/xml
"
);
body_text
=
xmlDoc
.
getElementsByTagName
(
"
description
"
)[
0
].
childNodes
[
0
].
nodeValue
;
return
this
.
cut_description
(
body_text
,
key
)
.
push
(
function
(
result
){
.
push
(
function
(
result
){
if
(
result
===
null
)
body
.
innerHTML
=
""
;
if
(
result
===
null
)
body
.
innerHTML
=
""
;
else
body
.
innerHTML
=
result
.
slice
(
1
);
else
body
.
innerHTML
=
result
.
slice
(
1
);
...
@@ -63,7 +60,6 @@
...
@@ -63,7 +60,6 @@
result
;
result
;
regEx
=
new
RegExp
(
'
[^.?!]*
'
+
'
'
+
key
+
'
'
+
'
[^.?!]*[.?!]
'
,
'
gm
'
);
regEx
=
new
RegExp
(
'
[^.?!]*
'
+
'
'
+
key
+
'
'
+
'
[^.?!]*[.?!]
'
,
'
gm
'
);
result
=
regEx
.
exec
(
body
);
result
=
regEx
.
exec
(
body
);
console
.
log
(
"
result:
"
);
console
.
log
(
result
);
if
(
result
===
null
)
return
null
;
if
(
result
===
null
)
return
null
;
else
return
result
[
0
];
else
return
result
[
0
];
});
});
...
...
search.js
View file @
852f9e93
...
@@ -67,62 +67,33 @@
...
@@ -67,62 +67,33 @@
.
declareMethod
(
"
search
"
,
function
(
key
){
.
declareMethod
(
"
search
"
,
function
(
key
){
var
gadget
=
this
;
var
gadget
=
this
;
return
gadget
.
state
.
model_gadget
.
allDocs
()
return
gadget
.
state
.
result_gadget
.
clear
()
.
push
(
function
(
result
){
.
push
(
function
(){
return
gadget
.
state
.
model_gadget
.
allDocs
();
})
.
push
(
function
(
all_attachments
){
var
i
,
j
,
promise_list
=
[];
var
i
,
j
,
promise_list
=
[];
for
(
i
=
0
;
i
<
result
.
length
;
i
+=
1
){
for
(
i
=
0
;
i
<
all_attachments
.
length
;
i
+=
1
){
for
(
j
=
1
;
j
<
result
[
i
].
data
.
rows
.
length
;
j
+=
1
){
for
(
j
=
1
;
j
<
all_attachments
[
i
].
data
.
rows
.
length
;
j
+=
1
){
promise_list
.
push
(
gadget
.
state
.
model_gadget
.
get
(
i
,
result
[
i
].
data
.
rows
[
j
].
id
));
promise_list
.
push
(
gadget
.
state
.
model_gadget
.
get
(
i
,
all_attachments
[
i
].
data
.
rows
[
j
].
id
));
}
}
}
}
console
.
log
(
promise_list
.
length
);
return
RSVP
.
all
(
promise_list
);
return
RSVP
.
all
(
promise_list
);
}).
push
(
function
(
result
){
}).
push
(
function
(
all_items
){
console
.
log
(
"
result :
"
);
var
i
,
console
.
log
(
result
);
regEx
=
new
RegExp
(
'
((.*
'
+
key
+
'
.*)|(
'
+
key
+
'
.*))
'
,
'
gi
'
),
});
promise_list
=
[];
/*var options = { query:'title:"% mai %"'};
for
(
i
=
0
;
i
<
all_items
.
length
;
i
+=
1
){
return gadget.state.model_gadget.search(options)
if
(
regEx
.
test
(
all_items
[
i
].
title
)
||
regEx
.
test
(
all_items
[
i
].
description
))
promise_list
.
push
(
gadget
.
state
.
result_gadget
.
addItem
(
all_items
[
i
],
key
));
.push(function(result){
}
console.log("result : "); console.log(result);
if
(
promise_list
.
length
===
0
)
{
});*/
/*var gadget = this,
options;
options = {
query:'(title:"% '+key+' %") OR (title:"'+ key + ' %") OR (body:"% '+key+' %")'
};
return gadget.state.result_gadget.clear()
.push(function(){
return gadget.state.model_gadget.search(options);
})
.push (function(result){
if (result.data.rows.length === 0){
return
gadget
.
state
.
result_gadget
.
addItem
({
return
gadget
.
state
.
result_gadget
.
addItem
({
title
:
"
No results found
"
,
title
:
"
No results found
"
,
link
:
""
link
:
""
},
""
);
},
""
);
}
}
var i,
else
return
RSVP
.
all
(
promise_list
);
id,
});
promise_list = [];
for (i = 0; i < result.data.rows.length; i+=1){
id = result.data.rows[i].id;
promise_list.push(gadget.state.model_gadget.get(id));
}
return RSVP.all(promise_list);
})
.push(function(result_list){
var j,
promise_list = [];
for (j = 0; j < result_list.length; j+=1){
promise_list.push(gadget.state.result_gadget.addItem(result_list[j], key));
}
return RSVP.all(promise_list);
});*/
})
})
.
onEvent
(
"
submit
"
,
function
(
event
){
.
onEvent
(
"
submit
"
,
function
(
event
){
...
...
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