Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: Biology Forums - lokakuu 03, 2013, 06:57:26 IP

Otsikko: Get a count of users in a particular action
Kirjoitti: Biology Forums - lokakuu 03, 2013, 06:57:26 IP
Not sure if this is possible... How can I get a count of users in action x? I want to add this somewhere into the index.template.php.
Otsikko: Re: Get a count of users in a particular action
Kirjoitti: Arantor - lokakuu 03, 2013, 07:02:30 IP
Same way who's online does it - slowly. Relies on who's online being enabled, too. Also helps to know what the action is because that *directly* affects the code, as does whether it's SMF 1 or SMF 2.
Otsikko: Re: Get a count of users in a particular action
Kirjoitti: Biology Forums - lokakuu 03, 2013, 07:38:11 IP
Lainaus käyttäjältä: Arantor - lokakuu 03, 2013, 07:02:30 IP
Same way who's online does it - slowly. Relies on who's online being enabled, too. Also helps to know what the action is because that *directly* affects the code, as does whether it's SMF 1 or SMF 2.

1) SMF 1.x
2) 1st action is arcade
3) 2nd action is gallery
Otsikko: Re: Get a count of users in a particular action
Kirjoitti: Arantor - lokakuu 03, 2013, 07:39:26 IP
And you want to run two expensive queries every page for what reason?

Question of the day: are you using memcache or a similar proper caching method?
Otsikko: Re: Get a count of users in a particular action
Kirjoitti: Biology Forums - lokakuu 03, 2013, 08:05:27 IP
Lainaus käyttäjältä: Arantor - lokakuu 03, 2013, 07:39:26 IP
And you want to run two expensive queries every page for what reason?

Question of the day: are you using memcache or a similar proper caching method?

Yes... I want to see if it's possible, that's all. I make my decision based on performance. Many times I chuck an idea in the garbage 10 minutes after adding it. I want to learn how it's done and code needed to make it work.
Otsikko: Re: Get a count of users in a particular action
Kirjoitti: Arantor - lokakuu 03, 2013, 08:14:38 IP
Sure it's possible. Who's online does it. You can even display who's viewing a board or topic much the same way - going through the mess that is the log_online table searching for the right bit of string to do it.

But this is a table that is updated very regularly, and a table scan will not be quick - and you want to do this every single page, twice. (Since you can't differentiate efficiently between the two in a single query)

If you were using any kind of cache backend, I'd show you how to do it including using the cache to not kill your site's performance. But without that, not a chance. I will not help you cripple your site's performance by adding two slow queries to every single page.

If you want to see how it looks, mock it up with some numbers (you can see who's online to get an idea of what the numbers would be), and then if you like it and the cache backend is workable, then we can talk about doing it.
Otsikko: Re: Get a count of users in a particular action
Kirjoitti: Biology Forums - lokakuu 03, 2013, 08:39:10 IP
I have a clear vision for how I want it to look.

I am using APC as a caching agent.
Otsikko: Re: Get a count of users in a particular action
Kirjoitti: Biology Forums - lokakuu 10, 2013, 12:35:12 IP
Can anyone else help?