Undo reputations
-
Hi, we had a problem that I made an issue for it.
problem with reward system 路 Issue #6769 路 NodeBB/NodeBB
Nodebb Version: 1.10.1 Database type: mongo Database version: 3.2.11 Hi, we set a reward algorithm for users. If a user post 50 replies, Nodebb will give him 1000 reputation. But now the users reputation is ten times more. For example a ...
GitHub (github.com)
Can we Undo the reputations that the system has given to users?
-
Not from the UI, but you can change a users reputation in the database, the two places you need to modify are the users objects at
user:<uid>
the field name isreputation
. And the sorted setusers:reputation
where you need to set the score to the new reputation. Below are the sample mongodb queries you need to run to set the users reputation to X.db.objects.update({_key: "user:<replace_with_uid>"}, {$set: {"reputation": X}}); db.objects.update({_key: "users:reputation", value: "<replace_with_uid>"}, {$set: {"score": X}});
-
@baris said in Undo reputations:
Not from the UI, but you can change a users reputation in the database, the two places you need to modify are the users objects at
user:<uid>
the field name isreputation
. And the sorted setusers:reputation
where you need to set the score to the new reputation. Below are the sample mongodb queries you need to run to set the users reputation to X.db.objects.update({_key: "user:<replace_with_uid>"}, {$set: {"reputation": X}}); db.objects.update({_key: "users:reputation", value: "<replace_with_uid>"}, {$set: {"score": X}});
What is reputation Algorithm?
maybe we can recalculate it for every users. And update it. -
There is no reputation algorithm as far as I know. It's just a number stored in the database.
-
You can recalculate the reputations by using this user script. We do not guarantee the effectiveness of our scripts, and you run them at your own risk. Always back up your database before running them.
Place this in a new file in your NodeBB's root directory, and then run it with
node
executable:'use strict'; /* globals require, console, process */ var nconf = require('nconf'); var async = require('async'); nconf.file({ file: 'config.json', }); var db = require('./src/database'); db.init((err) => { if (err) { console.log('Error:', err.message); process.exit(1); } var batch = require('./src/batch'); var posts = require('./src/posts'); var user = require('./src/user'); batch.processSortedSet('users:joindate', (uids, next) => { async.each(uids, (uid, next) => { // Find all posts by this uid and tally up their reputation async.waterfall([ async.apply(db.getSortedSetRange, 'uid:' + uid + ':posts', 0, -1), (pids, next) => { async.map(pids, (pid, next) => { posts.getPostFields(pid, ['upvotes', 'downvotes'], next); }, next); }, (data, next) => { // Collate result set let reputation = 0; if (data.length) { data.forEach((set) => { reputation += parseInt(set.upvotes, 10) || 0; reputation -= parseInt(set.downvotes, 10) || 0; }); } process.nextTick(next, null, { uid: uid, rep: reputation, }); }, (data, next) => { console.log('Resetting reputation for uid', data.uid, 'to', data.rep); user.setUserField('user:' + data.uid, 'reputation', parseInt(data.rep, 10) || 0, next); }, ], next); }, next); }, {}, function (err) { if (err) { console.log('Error:', err.message); } process.exit(0); }); });