Commit f53f1755 authored by Alain Takoudjou's avatar Alain Takoudjou

erp5_web_mynij_search: Move CreateIndexDoc method to model and reuse it for...

erp5_web_mynij_search: Move CreateIndexDoc method to model and reuse it for importing from torrent and file
parent 5c5e917e
...@@ -238,8 +238,11 @@ ...@@ -238,8 +238,11 @@
}) })
.push(function (evt) { .push(function (evt) {
var doc = JSON.parse(evt.target.result); var doc = JSON.parse(evt.target.result);
return gadget.createIndexDoc(doc.title, doc.links, torrent.infoHash, return gadget.state.model_gadget.createIndexDoc({
torrent.magnetURI); title: doc.title,
links: doc.links,
magnet_uri: torrent.magnetURI
});
}) })
} }
...@@ -289,7 +292,7 @@ ...@@ -289,7 +292,7 @@
} }
return insert_queue return insert_queue
.push(function () { .push(function () {
return gadget.pushIndex(index_name); return gadget.state.model_gadget.pushIndex(index_name);
}) })
.push(function () { .push(function () {
gadget.notifySubmitted({ gadget.notifySubmitted({
...@@ -306,28 +309,6 @@ ...@@ -306,28 +309,6 @@
gadget.state.redirect = ""; gadget.state.redirect = "";
}); });
}) })
.declareMethod("createIndexDoc", function (title, links, infoHash,
magnetURI) {
var gadget = this,
doc = {
title: title,
links: links
};
return gadget.getSetting("portal_type")
.push(function (portal_type) {
doc.portal_type = portal_type;
return gadget.getSetting("parent_portal_type");
})
.push(function (parent_portal_type) {
doc.parent_portal_type = parent_portal_type;
})
.push(function (parent_portal_type) {
return gadget.jio_post(doc)
.push(function (id) {
//
});
});
})
.onLoop(function () { .onLoop(function () {
var gadget = this, var gadget = this,
...@@ -485,7 +466,7 @@ ...@@ -485,7 +466,7 @@
return RSVP.all(promise_list); return RSVP.all(promise_list);
}) })
.push(function () { .push(function () {
return RSVP.delay(300000); return RSVP.delay(60000);
}) })
.push(function () { .push(function () {
return seedTorrent(); return seedTorrent();
...@@ -551,16 +532,6 @@ ...@@ -551,16 +532,6 @@
onProgress(gadget, torrent, element); onProgress(gadget, torrent, element);
}); });
}); });
})
.declareMethod("pushIndex", function (index_name) {
var gadget = this;
return gadget.getSetting('index_list', [])
.push(function (index_list) {
if (index_list.indexOf(index_name) === -1) {
index_list.push(index_name);
return gadget.setSetting('index_list', index_list);
}
});
}); });
}(window, RSVP, rJS, document, crypto, WebTorrent)); }(window, RSVP, rJS, document, crypto, WebTorrent));
\ No newline at end of file
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>988.55437.32344.9847</string> </value> <value> <string>988.55821.18802.45806</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1608722907.22</float> <float>1609152823.75</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
.declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("setSetting", "setSetting") .declareAcquiredMethod("setSetting", "setSetting")
.declareAcquiredMethod("jio_post", "jio_post")
.ready(function () { .ready(function () {
var indices = [], db; var indices = [], db;
...@@ -107,6 +108,18 @@ ...@@ -107,6 +108,18 @@
} }
}); });
}) })
.declareMethod("createIndexDoc", function (doc) {
var gadget = this;
return gadget.getSetting("portal_type")
.push(function (portal_type) {
doc.portal_type = portal_type;
return gadget.getSetting("parent_portal_type");
})
.push(function (parent_portal_type) {
doc.parent_portal_type = parent_portal_type;
return gadget.jio_post(doc);
});
})
.declareMethod("save_index", function (index_name) { .declareMethod("save_index", function (index_name) {
var gadget = this, var gadget = this,
......
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>988.53918.53330.53026</string> </value> <value> <string>988.62603.37288.24012</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1608674258.89</float> <float>1609162985.92</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
.declareAcquiredMethod("notifySubmitted", "notifySubmitted") .declareAcquiredMethod("notifySubmitted", "notifySubmitted")
.declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("jio_get", "jio_get") .declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_post", "jio_post")
.ready(function () { .ready(function () {
var gadget = this; var gadget = this;
...@@ -19,7 +18,6 @@ ...@@ -19,7 +18,6 @@
.declareMethod("preRenderDocument", function (parent_options) { .declareMethod("preRenderDocument", function (parent_options) {
var gadget = this; var gadget = this;
console.log(parent_options);
if (!parent_options.jio_key) if (!parent_options.jio_key)
return; return;
return gadget.jio_get(parent_options.jio_key) return gadget.jio_get(parent_options.jio_key)
...@@ -151,29 +149,17 @@ ...@@ -151,29 +149,17 @@
doc.title = index_dict.name; doc.title = index_dict.name;
doc.links = index_dict.links; doc.links = index_dict.links;
index_id = "index-" + doc.title; index_id = "index-" + doc.title;
//return gadget.createIndexDoc(doc.title, doc.links, torrent.infoHash,
// torrent.magnetURI);
return gadget.getSetting("portal_type");
})
.push(function (portal_type) {
doc.portal_type = portal_type;
return gadget.getSetting("parent_portal_type");
})
.push(function (parent_portal_type) {
doc.parent_portal_type = parent_portal_type;
})
.push(function () {
return gadget.state.model_gadget.pushIndexBlob( return gadget.state.model_gadget.pushIndexBlob(
index_id, index_id,
index_dict, index_dict,
{}); {});
}) })
.push(function (parent_portal_type) {
return gadget.jio_post(doc);
})
.push(function () { .push(function () {
return gadget.putIndexPage(index_dict.page); return gadget.putIndexPage(index_dict.page);
}) })
.push(function () {
return gadget.state.model_gadget.createIndexDoc(doc);
})
.push(function () { .push(function () {
return gadget.state.model_gadget.pushIndex(index_dict.name); return gadget.state.model_gadget.pushIndex(index_dict.name);
}); });
......
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