Comments (3)
I noticed this slowness in my testing too, the biggest two offenders were :
feed.updateTopic(tid);
feed.updateRecent();
https://github.com/designcreateplay/NodeBB/blob/master/src/posts.js#L73
Commenting them out really sped up post creation.
from nodebb-plugin-import.
oh, thanks, ill test that out
from nodebb-plugin-import.
woah ! i made these changes, along with taking out the part where each post.content's get parsed, and I was able to migrate 350k+ records in 13 minutes on my macbook, it was taking hours, 6 or more before then, i honestly never was able to finish a full run before i got bored.
do you think we can 'rewrite' Post.create, refactor it a little, maybe have an essential Post._create
which the importer can use, and Post.create
will call Post._create
along with the other feed stuff and the plugin.firehook ?
Posts.create = function(uid, tid, content, callback) {
if (uid === null) {
return callback(new Error('invalid-user'), null);
}
topics.isLocked(tid, function(err, locked) {
if(err) {
return callback(err, null);
} else if(locked) {
return callback(new Error('topic-locked'), null);
}
db.incrObjectField('global', 'nextPid', function(err, pid) {
if(err) {
return callback(err, null);
}
plugins.fireHook('filter:post.save', content, function(err, newContent) {
if(err) {
return callback(err, null);
}
var timestamp = Date.now(),
postData = {
'pid': pid,
'uid': uid,
'tid': tid,
'content': newContent,
'timestamp': timestamp,
'reputation': 0,
'editor': '',
'edited': 0,
'deleted': 0
};
db.setObject('post:' + pid, postData);
postData.favourited = false;
postData.display_moderator_tools = true;
postData.relativeTime = new Date(timestamp).toISOString();
topics.addPostToTopic(tid, pid);
topics.increasePostCount(tid);
topics.updateTimestamp(tid, timestamp);
db.incrObjectField('global', 'postCount');
topics.getTopicFields(tid, ['cid', 'pinned'], function(err, topicData) {
var cid = topicData.cid;
// [import-temp] uncomment after migration
// feed.updateTopic(tid);
// feed.updateRecent();
db.sortedSetAdd('categories:recent_posts:cid:' + cid, timestamp, pid);
if(parseInt(topicData.pinned, 10) === 0) {
db.sortedSetAdd('categories:' + cid + ':tid', timestamp, tid);
}
db.setCount('cid:' + cid + ':active_users', function(err, amount) {
if (amount > 15) {
db.setRemoveRandom('cid:' + cid + ':active_users');
}
categories.addActiveUser(cid, uid);
});
});
user.onNewPostMade(uid, tid, pid, timestamp);
// [import-temp], delete this statement and uncomment block below after migration
callback(null, postData);
// plugins.fireHook('filter:post.get', postData, function(err, newPostData) {
// if(err) {
// return callback(err, null);
// }
//
// postData = newPostData;
//
// postTools.parse(postData.content, function(err, content) {
// if(err) {
// return callback(err, null);
// }
// postData.content = content;
//
// plugins.fireHook('action:post.save', postData);
//
// db.searchIndex('post', content, pid);
//
// callback(null, postData);
// });
// });
});
});
});
};
from nodebb-plugin-import.
Related Issues (20)
- NodeBB 1.0.3 is Broken HOT 3
- Type Error - Redis internal_send_command HOT 3
- TypeError: callFn.apply is not a function HOT 2
- nodebb-plugin-import error at nodebb start (TypeError: path must be a string or Buffer) HOT 6
- Mysql old and insecure pre-4.1 auth mechanism
- Some special characters not supported? Polish MyBB import HOT 5
- How do I change the batch size? HOT 2
- Plugin installation fails. HOT 1
- Can I migrate from discourse to NodeBB using this tool? HOT 7
- Error on plugin install (error on [email protected] step) HOT 1
- Error while exporting Xenforo v1.5.5 to nodeBB v1.12.1 HOT 8
- SMF import hangs at getPaginatedTopics HOT 2
- Releasing 0.4.10 to npm? HOT 1
- Failed to lookup view "admin/plugins/import" HOT 6
- error
- are nested categories supported during import from vbulletin HOT 1
- JS heap out of memory issue
- phpbb import hangs at topicsimportstart HOT 1
- Cannot find details on which versions of phpbb this works with
- Trouble importing phpBB any help appreciated. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodebb-plugin-import.