From 691b6611d0cc078dee152c28b7b2d0d37ff6e2de Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Thu, 29 Aug 2013 13:40:04 -0400 Subject: [PATCH] user search uses reds now --- src/user.js | 46 +++++++++++++++++++++++++++++++++------------- src/webserver.js | 12 +++++++++--- 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/src/user.js b/src/user.js index 5f84b492fb..d087cd4102 100644 --- a/src/user.js +++ b/src/user.js @@ -7,7 +7,8 @@ var utils = require('./../public/src/utils.js'), bcrypt = require('bcrypt'), notifications = require('./notifications.js'), topics = require('./topics.js'), - async = require('async'); + async = require('async'), + userSearch = require('reds').createSearch('nodebbusersearch'); (function(User) { User.create = function(username, password, email, callback) { @@ -90,6 +91,8 @@ var utils = require('./../public/src/utils.js'), RDB.zadd('users:postcount', 0, uid); RDB.zadd('users:reputation', 0, uid); + userSearch.index(username, uid); + io.sockets.emit('user.latest', {userslug: userslug, username: username}); if (password !== undefined) { @@ -385,25 +388,42 @@ var utils = require('./../public/src/utils.js'), }); } + User.reIndexAll = function(callback) { + User.getUsers('users:joindate', 0, -1, function(err, usersData) { + if(err) { + return callback(err, null); + } + + function reIndexUser(uid, username) { + userSearch.remove(uid, function(){ + userSearch.index(username, uid); + }) + } + + for(var i=0; i