Advertisement:

Scheduled Task for recount member stats

Aloittaja Acans, elokuu 10, 2013, 06:05:06 AP

« edellinen - seuraava »

Acans

Hey guys,

I'm trying to create a Scheduled Task for recount basic member stats (Total members/Latest Member). The actual task has been created thanks to Arantor's tutorial, however the code for the task itself doesn't work. (Mainly because I'm no programmer :P)

I thought if I stole the code from ManageMaintenance for recounting the data it would work, however sadly it doesn't :(

// Recount total number of members.
function scheduled_recount()
{
global $sourcedir;

// Update all the basic statistics.
updateStats('member');

// Finally, update the latest event times.
require_once($sourcedir . '/ScheduledTasks.php');
CalculateNextTrigger();

}


Perhaps a real programmer could shed some light on how this can be done :)

P.S: The reason I'm doing this is because I have shared forums, and if a member registered at one, it doesn't update the others with the new member count. Hence, this idea.
"The Book of Arantor, 17:3-5
  And I said unto him, thy database query shalt always be sent by the messenger of $smcFunc
  And $smcFunc shall protect you against injections and evil
  And so it came to pass that mysql_query was declared deprecated and even though he says he is not
  dead yet, the time was soon to come to pass when mysql_query shall be gone and no more

NanoSector

LainaaP.S: The reason I'm doing this is because I have shared forums, and if a member registered at one, it doesn't update the others with the new member count. Hence, this idea.
Wait, you did not tell me this.

updateStats('member'); only updates the count of the forum it is run on. Not the others. Either you'd have to use custom queries or edit the updateStats function.
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Acans

That's why I was just going the Task running on all the forums every hour.
"The Book of Arantor, 17:3-5
  And I said unto him, thy database query shalt always be sent by the messenger of $smcFunc
  And $smcFunc shall protect you against injections and evil
  And so it came to pass that mysql_query was declared deprecated and even though he says he is not
  dead yet, the time was soon to come to pass when mysql_query shall be gone and no more

Arantor

There are several things wrong with the above.

Firstly, you do not need to manually call the retriggering, just return true and SMF will deal with the rest for you.

Secondly, updateStats('member') really isn't the way to fix this. If they're all linked, add some code after registration to update that rather than having to run extra queries every hour. Push, not pull, the information.
Holder of controversial views, all of which my own.


Acans

Thanks for the advise.

I found this post and changed it to work for 2.0 and it's working perfectly regardless of what forum the user registers at.

However I just realized I should unshare log_online, doesn't play well with action=who :)
"The Book of Arantor, 17:3-5
  And I said unto him, thy database query shalt always be sent by the messenger of $smcFunc
  And $smcFunc shall protect you against injections and evil
  And so it came to pass that mysql_query was declared deprecated and even though he says he is not
  dead yet, the time was soon to come to pass when mysql_query shall be gone and no more

Advertisement: