XF 1.1 Recalculate Trophy Points?

x7iBiT

Member
I edited some existing trophies in my Forum. For example, I edited one trophy from 100 likes to 250. Is there a way to recalculate the trophy user titles and the trophy points for all users?

Thanks a lot (and sorry, my english sucks)
 
Run these two queries:

Code:
TRUNCATE TABLE xf_user_trophy;

UPDATE xf_user AS u
SET u.trophy_points = (
	SELECT SUM(t.trophy_points)
	FROM xf_user_trophy AS ut
	LEFT JOIN xf_trophy AS t ON (t.trophy_id = ut.trophy_id)
	WHERE ut.user_id = u.user_id
);

That will make it so everyone gets their trophies awarded again.

Trophies are awarded by this cron, so you may wish to manually run the task after running these queries:

Admin CP -> Tools -> Cron Entries -> Update User Trophies -> Controls: Run

And note that the trophy cron only updates users who have been active in the last 24 hours, so there may be a delay for some users despite manually running the cron.
 
Run these two queries:

Trophies are awarded by this cron, so you may wish to manually run the task after running these queries:

Admin CP -> Tools -> Cron Entries -> Update User Trophies -> Controls: Run

And note that the trophy cron only updates users who have been active in the last 24 hours, so there may be a delay for some users despite manually running the cron.

This is an important point - my suggestion is to add it to the manual. I've been going nuts trying to figure out why some users are not being renamed with the default ladder (awarded points)......I've run the cron and waited a day and still no go.....duh, they won't get updated until later....after they login.

It would be nice to have buttons in XF which allowed those of us with lots of extra RAM and processing power to "award points to ALL users" or something similar.....instead of waiting for them to login and then the cron job after that.
 
This is an important point - my suggestion is to add it to the manual. I've been going nuts trying to figure out why some users are not being renamed with the default ladder (awarded points)......I've run the cron and waited a day and still no go.....duh, they won't get updated until later....after they login.

It would be nice to have buttons in XF which allowed those of us with lots of extra RAM and processing power to "award points to ALL users" or something similar.....instead of waiting for them to login and then the cron job after that.

Try this:

http://xenforo.com/community/thread...cron-running-out-of-memory.31541/#post-362699

It's a new version of the trophy cron which incorporates a memory fix. That should allow you to process all users by commenting out the last_activity condition:

Rich (BB code):
		$conditions = array(
			'user_state' => 'valid',
			'is_banned' => 0,
			// 'last_activity' => array('>', XenForo_Application::$time - 86400)
		);

I referenced a suggestion of mine in that thread to process all users only if the task is run manually, but you can temporarily comment out that line to force it to process all users. And the memory fix should avoid the usual memory problems associated with doing this.
 
sorry to bump an old thread but, is there an option to run a query from the xenforo admincp like in vbulletin or do I need to do it from myphp admin.

I had a go in myphp but im really sure how to do it.

I just keep getting - You have to choose at least one column to display -

trying to run these 2 query's

TRUNCATE TABLE xf_user_trophy;

UPDATE xf_user AS u
SET u.trophy_points = (
SELECT SUM(t.trophy_points)
FROM xf_user_trophy AS ut
LEFT JOIN xf_trophy AS t ON (t.trophy_id = ut.trophy_id)
WHERE ut.user_id = u.user_id
);
 
How do I run that query ?

TRUNCATE TABLE xf_user_trophy;

UPDATE xf_user AS u
SET u.trophy_points = (
SELECT SUM(t.trophy_points)
FROM xf_user_trophy AS ut
LEFT JOIN xf_trophy AS t ON (t.trophy_id = ut.trophy_id)
WHERE ut.user_id = u.user_id
);
 
Guys. Could someone help me with this on Xenforo 1.2 ?

I executed those codes. Points are recalulated for most of users, but some of them still have 0 points. Even thou they should have at least 100+.

Code i executed:
Code:
TRUNCATE TABLE xf_user_trophy;

UPDATE xf_user AS u
SET u.trophy_points = (
SELECT SUM(t.trophy_points)
FROM xf_user_trophy AS ut
LEFT JOIN xf_trophy AS t ON (t.trophy_id = ut.trophy_id)
WHERE ut.user_id = u.user_id
);

+ this:
ACP - > Tools > rebuild Trophy Point cron task.

Still after almost ~20h some of my users are on zero.

Can i just run some kind of phpmyadmin query just to recalculate Trohpy Points just for one specific user?
 
Don't run the cron task. Use the "Rebuild Trophies" option in Rebuild Caches (1.2.1 only). It will do what you want.

Does this mean if the entire trophy point system is "redone" it will erase all the old values and recalculate? I filled out some trophy points without really knowing what I was doing and now I need to change the scale.
 
OK, I have the same problem. I lost track of time and posts, and added a trophy for 3000 posts and missed one user who already went over that mark. I ran the cron job and the "Rebuild Trophies" option in the cache but the user still isn't awarded the trophy (and they have logged on). What am I missing.

I don't want to re-award the trophies for everyone, just want to fix this one user. Any way to do this in the UI?
 
Rebuilding trophies runs the criteria check against all users. If it doesn't award a trophy to a user (particularly if it does for other users), that would indicate that either the user doesn't meet the criteria or there's something wrong in the DB somewhere (things like this have happened when external systems create accounts). I would certainly double check the criteria though.
 
You are correct! PICNIC problem (problem in chair not in computer)! Thanks for making me check and sorry for bothering you! Neglected to set the criteria for one of the trophies!
 
Top Bottom