I want to rank all the users in my site according to the score they have.but i am unable to otain all the score objects because of the limit on get_entities() which returns only 10 entities at max. I want to run this as a cron job so that ranks keep updating as and when score changes. even changing the limit to false does no good. how do i accomplish this now?
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Matt Beckett@Beck24
Matt Beckett - 0 likes
- Evan Winslow@ewinslow
Evan Winslow - 0 likes
- Matt Beckett@Beck24
Matt Beckett - 0 likes
- priyanka_menghani@priyanka_m
priyanka_menghani - 0 likes
- DhrupDeScoop@Dhrup2000
DhrupDeScoop - 0 likes
- priyanka_menghani@priyanka_m
priyanka_menghani - 0 likes
- priyanka_menghani@priyanka_m
priyanka_menghani - 0 likes
$entities = elgg_get_entities_from_metadata(array('types' => 'object', 'subtypes' => 'karma', 'limit' => FALSE, 'metadata_names' => 'total_score', 'order_by_metadata' => array('name' => 'total_score', 'direction' => 'DESC', 'as' => integer) )); Starting from the first entity returned in this array I assigned rank '1' and so on till the end. But this seems to work only with small number of entities. I tried with 12 it worked. when deployed with 15000 entities, it failed. The ranks were empty.
- DhrupDeScoop@Dhrup2000
DhrupDeScoop - 0 likes
You must log in to post replies.Use 0 for the limit - see http://reference.elgg.org/entities_8php.html#af085c8362e49c4f52d4f1fcf58ca6fb8
Use ElggBatch instead. Limit 0 is dangerous because you may run out of memory.
yes, good call
I am using elgg version 1.7 so can't use ElggBatch and unfortunately I am restricted with that version only.
yes you can ;-) elggBatch simple extends php's iterator. I'd say - just copy over ElggBatch.php, write your wrapper code to use it.. then see ;-P (only) one other option wud be to code to control via a bash script to control php cli (elgg) code.. cud get messier..
PHP Error reporting says ElggBatch class not defined.
This is what I was trying to do earlier.
' PHP Error... ElggBatch class not defined ' ? Did you include elggBatch.php with " class ElggBatch implements Iterator {... " ?