Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Mynij
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
Alexandra Rogova
Mynij
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 @@
body
.
innerHTML
=
""
;
list
.
appendChild
(
list_item
);
}
else
{
parser
=
new
DOMParser
();
xmlDoc
=
parser
.
parseFromString
(
item
.
body
,
"
text/xml
"
);
body_text
=
xmlDoc
.
getElementsByTagName
(
"
description
"
)[
0
].
childNodes
[
0
].
nodeValue
;
return
this
.
cut_description
(
body_text
,
key
)
return
this
.
cut_description
(
item
.
description
,
key
)
.
push
(
function
(
result
){
if
(
result
===
null
)
body
.
innerHTML
=
""
;
else
body
.
innerHTML
=
result
.
slice
(
1
);
...
...
@@ -63,7 +60,6 @@
result
;
regEx
=
new
RegExp
(
'
[^.?!]*
'
+
'
'
+
key
+
'
'
+
'
[^.?!]*[.?!]
'
,
'
gm
'
);
result
=
regEx
.
exec
(
body
);
console
.
log
(
"
result:
"
);
console
.
log
(
result
);
if
(
result
===
null
)
return
null
;
else
return
result
[
0
];
});
...
...
search.js
View file @
852f9e93
...
...
@@ -67,62 +67,33 @@
.
declareMethod
(
"
search
"
,
function
(
key
){
var
gadget
=
this
;
return
gadget
.
state
.
model_gadget
.
allDocs
()
.
push
(
function
(
result
){
return
gadget
.
state
.
result_gadget
.
clear
()
.
push
(
function
(){
return
gadget
.
state
.
model_gadget
.
allDocs
();
})
.
push
(
function
(
all_attachments
){
var
i
,
j
,
promise_list
=
[];
for
(
i
=
0
;
i
<
result
.
length
;
i
+=
1
){
for
(
j
=
1
;
j
<
result
[
i
].
data
.
rows
.
length
;
j
+=
1
){
promise_list
.
push
(
gadget
.
state
.
model_gadget
.
get
(
i
,
result
[
i
].
data
.
rows
[
j
].
id
));
for
(
i
=
0
;
i
<
all_attachments
.
length
;
i
+=
1
){
for
(
j
=
1
;
j
<
all_attachments
[
i
].
data
.
rows
.
length
;
j
+=
1
){
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
);
}).
push
(
function
(
result
){
console
.
log
(
"
result :
"
);
console
.
log
(
result
);
});
/*var options = { query:'title:"% mai %"'};
return gadget.state.model_gadget.search(options)
.push(function(result){
console.log("result : "); console.log(result);
});*/
/*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){
}).
push
(
function
(
all_items
){
var
i
,
regEx
=
new
RegExp
(
'
((.*
'
+
key
+
'
.*)|(
'
+
key
+
'
.*))
'
,
'
gi
'
),
promise_list
=
[];
for
(
i
=
0
;
i
<
all_items
.
length
;
i
+=
1
){
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
));
}
if
(
promise_list
.
length
===
0
)
{
return
gadget
.
state
.
result_gadget
.
addItem
({
title
:
"
No results found
"
,
link
:
""
},
""
);
}
var i,
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);
});*/
else
return
RSVP
.
all
(
promise_list
);
});
})
.
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