Commit 04b2ec22 authored by Alexandra Rogova's avatar Alexandra Rogova

lint

parent fc90baef
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
}); });
index.setRef(id); index.setRef(id);
// do not store the documents in the index // do not store the documents in the index
//index.saveDocument(false); index.saveDocument(false);
return index; return index;
} }
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
boost: 1, boost: 1,
bool: 'AND' bool: 'AND'
}; };
// we can only do a single-string search, so we can // we can only do a single-string search, so we can
// stop on the first indexed field we find // stop on the first indexed field we find
return index.search(value, config).map(function (result) { return index.search(value, config).map(function (result) {
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
return null; return null;
} }
function recursiveIndexQuery(index, indexedFields, query, sub_storage) { function recursiveIndexQuery(index, indexedFields, query) {
var ids = null, var ids = null,
subquery, subquery,
i, i,
...@@ -132,7 +132,7 @@ ...@@ -132,7 +132,7 @@
} }
return ids; return ids;
} }
return searchQuery(index, indexedFields, query.key, query.value); return searchQuery(index, indexedFields, query.key, query.value);
} }
...@@ -302,42 +302,41 @@ ...@@ -302,42 +302,41 @@
ElasticlunrStorage.prototype.repair = function () { ElasticlunrStorage.prototype.repair = function () {
// rebuild index? // rebuild index?
var idx, var idx,
doc_ids = [], doc_ids = [],
context = this, context = this,
args = arguments; args = arguments;
return this._getIndex() return this._getIndex()
.push(function(index){ .push(function (index) {
idx = index; idx = index;
return context._sub_storage.repair.apply(context._sub_storage, args); return context._sub_storage.repair.apply(context._sub_storage, args);
}) })
.push(function(){ .push(function () {
return context._sub_storage.allDocs(); return context._sub_storage.allDocs();
}) })
.push(function(all_docs){ .push(function (all_docs) {
var i, var i,
queue = new RSVP.Queue(), queue = new RSVP.Queue(),
add_to_queue; add_to_queue;
add_to_queue = function(id){ add_to_queue = function (id) {
queue.push(function(){ queue.push(function () {
return context._sub_storage.get(id.toString()); return context._sub_storage.get(id.toString());
}) })
.push(function(doc){ .push(function (doc) {
var data = JSON.parse(JSON.stringify(doc)); var data = JSON.parse(JSON.stringify(doc));
data.id = id.toString(); data.id = id.toString();
idx.updateDoc(data); idx.updateDoc(data);
}); });
}; };
for (i=0; i<all_docs.data.rows.length; i+=1){ for (i = 0; i < all_docs.data.rows.length; i += 1) {
add_to_queue(all_docs.data.rows[i].id); add_to_queue(all_docs.data.rows[i].id);
doc_ids.push(all_docs.data.rows[i].id); doc_ids.push(all_docs.data.rows[i].id);
} }
return queue; return queue;
}) })
.push(undefined, function (my_error) { .push(undefined, function (my_error) {
if (my_error.status_code === 501) { //501 = sub_storage does not have allDocs capacity if (my_error.status_code !== 501) {
// throw my_error; //501 = sub_storage does not have allDocs capacity
} }
else throw my_error;
}); });
}; };
...@@ -355,7 +354,7 @@ ...@@ -355,7 +354,7 @@
return this._sub_storage.hasCapacity(name); return this._sub_storage.hasCapacity(name);
}; };
ElasticlunrStorage.prototype.buildQuery = function (options) { // Appelé par allDocs ElasticlunrStorage.prototype.buildQuery = function (options) {
var context = this, var context = this,
indexedFields = this._index_fields, indexedFields = this._index_fields,
runSubstorageQuery = options.select_list || options.include_docs, runSubstorageQuery = options.select_list || options.include_docs,
...@@ -365,7 +364,7 @@ ...@@ -365,7 +364,7 @@
parsedQuery = jIO.QueryFactory.create(options.query); parsedQuery = jIO.QueryFactory.create(options.query);
return context._getIndex() return context._getIndex()
.push(function (index) { .push(function (index) {
return recursiveIndexQuery(index, indexedFields, parsedQuery, context._sub_storage); return recursiveIndexQuery(index, indexedFields, parsedQuery);
}) })
.push(function (ids) { .push(function (ids) {
try { try {
......
...@@ -620,7 +620,6 @@ ...@@ -620,7 +620,6 @@
deepEqual(options, expected_options, "repair 200 called"); deepEqual(options, expected_options, "repair 200 called");
return "OK"; return "OK";
}; };
jio.repair(expected_options) jio.repair(expected_options)
/*.then(function (result) { /*.then(function (result) {
equal(result, "OK"); equal(result, "OK");
...@@ -632,15 +631,15 @@ ...@@ -632,15 +631,15 @@
start(); start();
}); });
}); });
test("repair adds missing documents", function(){ test("repair adds missing documents", function () {
stop(); stop();
expect(2); expect(2);
Index200.prototype.getAttachment = function () { Index200.prototype.getAttachment = function () {
return true; return true;
}; };
var sub_storage = jIO.createJIO({ var sub_storage = jIO.createJIO({
type: "indexeddb", type: "indexeddb",
database: "merge_test" database: "merge_test"
...@@ -655,17 +654,17 @@ ...@@ -655,17 +654,17 @@
type: "indexeddb", type: "indexeddb",
database: "merge_test" database: "merge_test"
} }
}); });
sub_storage.put("foo", {title: "bar"}); sub_storage.put("foo", {title: "bar"});
return jio.repair() return jio.repair()
.push(function(){ .push(function () {
return jio.allDocs({ return jio.allDocs({
query: 'title: "bar"' query: 'title: "bar"'
}); });
}) })
.push(function(result){ .push(function (result) {
equal(result.data.total_rows, 1); equal(result.data.total_rows, 1);
equal(result.data.rows[0].id, "foo"); equal(result.data.rows[0].id, "foo");
}) })
...@@ -676,15 +675,15 @@ ...@@ -676,15 +675,15 @@
start(); start();
}); });
}); });
test("repair updates documents", function(){ test("repair updates documents", function () {
expect(2); expect(2);
stop(); stop();
Index200.prototype.getAttachment = function () { Index200.prototype.getAttachment = function () {
return true; return true;
}; };
Index200.prototype.putAttachment = function () { Index200.prototype.putAttachment = function () {
return true; return true;
}; };
...@@ -703,19 +702,19 @@ ...@@ -703,19 +702,19 @@
type: "indexeddb", type: "indexeddb",
database: "merge_test" database: "merge_test"
} }
}); });
return jio.put("foo", {title: "bar"}) return jio.put("foo", {title: "bar"})
.push(function(){ .push(function () {
return sub_storage.put("foo", {title: "Hello world!"}); return sub_storage.put("foo", {title: "Hello world!"});
}) })
.push(function(){ .push(function () {
return jio.repair(); return jio.repair();
}) })
.push(function(){ .push(function () {
return jio.allDocs({query: 'title: "Hello world!"'}); return jio.allDocs({query: 'title: "Hello world!"'});
}) })
.push(function(result){ .push(function (result) {
equal(result.data.total_rows, 1); equal(result.data.total_rows, 1);
equal(result.data.rows[0].id, "foo"); equal(result.data.rows[0].id, "foo");
}) })
...@@ -726,7 +725,7 @@ ...@@ -726,7 +725,7 @@
start(); start();
}); });
}); });
/* /*
test("repair deletes outdated documents", function(){ test("repair deletes outdated documents", function(){
var sub_storage = jIO.createJIO({ var sub_storage = jIO.createJIO({
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment