Maybe this question is too-specific and should be posted in the Userpoints issue cue. But first i wanted to see if any of my friends here in the broader "Post Installation" forum had any insight.

Okay, it's a seemingly simple task: Add 150 userpoints to all users. I looked at Views Bulk Operations, Rules, and the userpoints UI... all without luck. VBO didn't seem to have access to increment that field and with Rules I could only change the points of the "acting user" and not all users.

How would you do this?

Maybe this is done on the database with a query? Anyone know how to globally add user points to all users?

Comments

Ayesh’s picture

VBO is the way.
0. Update VBO to latest DEV version.
1. You create a new view with User table, and username as a field.
2. You create a new Rule Set, with one User argument.
3. You create a new Rule inside the Rule set, and add "add user points" action.
4. In that action settings, enter 150. To reduce points, enter -150.
5. You save evetything and open the View created in #1.
6. You create a Page display.
7. You selecy VBO as output style, and select the rule set you just created.
8. Use batch API if you have many users.
9. Set pager to 0. If you have many users, try amount like. 50.
10. Save the View, and go to page display.
11. Select all users and jht the button.

mcfilms’s picture

I was hoping for some help. But I never expected a step-by-step recipe. I will try this on Monday and report back.

Thanks again Ayesh.

A list of some of the Drupal sites I have designed and/or developed can be viewed at motioncity.com

mcfilms’s picture

Hi Ayesh

I know it is a bit longer than I said. I just wanted to follow up. I got everything configured and I walk the process all the way to the confirmation page. I see:

Are you sure you want to perform Add User Days on selected rows?
You selected all 19219 rows in this view.

But when I click confirm I get:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 7731001 bytes) in /home/egmmain/public_html/dev/includes/database.mysql.inc on line 128

However if I just do the rule for the users on the page, it performs the rule and reports:
48 rows processed in about 870 ms

(I'm not sure why it is 48 -- my view was set to 50)

If I do 100 at a time I'd have to do it 192 times and keep track of which pages I've done.

Even with "Use Batch API" and "Maximize Batch API performance" selected I get

Warning: Got a packet bigger than 'max_allowed_packet' bytes query: INSERT INTO watchdog (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (1, 'php', '%message in %file on line %line.', 'a:4:{s:6:\"%error\";s:12:\"user warning\";s:8:\"%message\";s:5138275:\"Got a packet bigger than 'max_allowed_packet' bytes\nquery: UPDATE batch SET token = 'b82eb75cb5e5da6fe7f1f771ae665ca2', batch = 'a:10:{s:4:\\"sets\\";a:1:{i:0;a:10:{s:7:\\"sandbox\\";a:0:{}s:7:\\"results\\";a:0:{}s:7:\\"success\\";b:0;s:5:\\"title\\";s:53:\\"Performing <em>Add User Days</em> on selected rows...\\";s:8:\\"finished\\";s:39:\\"_views_bulk_operations_execute_finished\\";s:10:\\"operations\\";a:1: in /home/egmmain/public_html/dev/includes/database.mysql.inc on line 128

Any thoughts about what I might do to make this query work?

A list of some of the Drupal sites I have designed and/or developed can be viewed at motioncity.com

mcfilms’s picture

Hi Ayesh,

I am hoping this pops up on your tracker and you take pity on me.You were very helpful and your advice was spot on. It works if I just select 100 or so users and run the batch.

However, if a use the pull-down feature and select all users (there are close to 20,000) and execute the batch, within 10 seconds I get an error:

Warning: Got a packet bigger than 'max_allowed_packet' bytes query: INSERT INTO watchdog (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (1, 'php', '%message in %file on line %line.', 'a:4:{s:6:\"%error\";s:12:\"user warning\";s:8:\"%message\";s:16641966:\"Got a packet bigger than 'max_allowed_packet' bytes\nquery: UPDATE batch SET token = 'e9818f056de0bd1c1f819e847b412f25', batch = 'a:10:{s:4:\\"sets\\";a:1:{i:0;a:10:{s:7:\\"sandbox\\";a:0:{}s:7:\\"results\\";a:0:{}s:7:\\"success\\";b:0;s:5:\\"title\\";s:53:\\"Performing <em>Add User Days</em> on selected rows...\\";s:8:\\"finished\\";s:39:\\"_views_bulk_operations_execute_finished\\";s:10:\\"operations\\";a:1 in /home/egmmain/public_html/dev/includes/database.mysql.inc on line 128

My php memory is set to 512M and I confirmed this through admin/reports/status.

Do you have any idea why I cannot run a bulk operation on many users?

I have opened an issue about this at:
http://drupal.org/node/1268124

A list of some of the Drupal sites I have designed and/or developed can be viewed at motioncity.com

mcfilms’s picture

That was awesome!

Ayesh, if you are ever in Los Angeles, please let me know. I owe you a dinner. That was precisely the problem and once my VPS helped my configure MySql, changing the default max_allowed_packet variable as indicated, the batch ran without a hitch.

Thank you for your help. Did you recognize the issue was with MySql right away based on that error code, or did you dig around to find it? I'm curious how you were able to troubleshoot and soleve this issue, because I was dead in the water without your help.

Thanks again,

Jerry

A list of some of the Drupal sites I have designed and/or developed can be viewed at motioncity.com

itqan-2010’s picture

thanks for your hints