PDA

View Full Version : Letter Statistics in Member Profile v1.0


Sho
03-15-2003, 10:00 PM
This hack will add several new statistics to your member's profile pages:

- The number of letters all his/her posts contain.
- The average number of letters he/she posts per day.
- His/her percentage of all letters in all posts in the database.
- The average number of letters a post by him/her contains.


File Modifications: 1 (member.php)
Template Modifications: 1 (getinfo)


This hack was tested with vBulletin 2.2.7 and 2.3.0 Release Candidate 3. I'm confident it will work with every version of vBulletin in the 2.2.x branch. Probably even with older versions.


Two screenshots of the hack in action are included in the ZIP archive:

screenshot1.gif: Plain vBulletin 2.3.0 RC3.
screenshot2.gif: My own forums, a heavily modified vBulletin 2.2.7 translated into German (hack's in English, though).


Special thanks to Logician for helping with the SQL syntax used in this hack. :)


Have fun with it!

gmarik
03-16-2003, 06:11 AM
Perfect. Just perfect. Still you could add a link to a demo site.

Sho
03-16-2003, 06:15 AM
Thanks. :)

Live demo site: http://www.forenplanet.de/member.php?s=&action=getinfo&userid=450

It's German, though. Buchstaben = letters. (Hack's in English; screenshot of plain English vB 2.3.0 RC3 included.)

pattox
03-16-2003, 07:34 AM
I installed it, nice hack.

Intex
03-16-2003, 07:36 AM
Nice hack m8. I'll install this soon.

Dean C
03-16-2003, 08:45 AM
Lovely idea. I guess this will be server intensive as it breaks down every word and then processes it into a table?

- miSt

Sho
03-16-2003, 08:54 AM
No, not significantly. We have about 120.000 posts in our database, and for a user with 2500 posts it slows down the generation of the profile page by circa 0.2 seconds (according to vBMicrostats in our footer). On a not particularly powerful, shared server.

The MySQL function LENGTH() returns the length of the specified fields contents for all records in the table, SUM() adds those values together and returns the result. So it's a SUM(LENGTH(pagetext)) for the table "post" WHERE userid=X. That's a pretty fast way to do it - and it doesn't require multiple changes to newthread/editpost/newreply and new table fields to do it statically.

I'd advice against using the same technique for the postbit, but for the profile pages its good enough.

(Yes, that means spaces between words get counted as well. Well, the user had to push the space button, after all. Fair enough, eh? :))

One-Team
03-16-2003, 09:04 AM
Nice hack Install it :pirate:

Koopa
03-16-2003, 09:21 AM
Nice hack, I might use this :)

dstruct2k
03-17-2003, 02:21 AM
Hey, I like! :D

* dstruct2k clicks install

zajako
03-19-2003, 12:23 PM
nice hack ill post a hack based of your query for forumhome.

Sho
03-19-2003, 01:06 PM
Sure, go ahead. Mentioning me & Logician would be cool, though. And a link to this hack? :)

Xenon
03-19-2003, 01:24 PM
hmm, your profile page loads quite slow...

So it's a SUM(LENGTH(pagetext)) for the table "post" WHERE userid=X.
yes you are right here, that part should be relativ fast
but for getting the global percentage you need also that query:
So it's a SUM(LENGTH(pagetext)) for the whole table "post"
which will become slower and slower how more posts you have.
ok, getprofile isn't called so often, but also there i don't think that's such a good way.
i'd use a sort of caching the absulote letter ammount and just update it rarely :)

Sho
03-19-2003, 01:28 PM
I'd hate having to do that manually by loading up a script, and I don't have access to the crontab task scheduler, so I prefer doing it dynamically. :)

Yep, my profile pages load quite slow, mostly because this is just a small part of a shared server and really underpowered. The letter statistics do not account for a major part of the generation time, though. Granted, that's because there are some other modifications in there.

Overall, I think it's the best way to do it in a case similar to mine.

Xenon
03-19-2003, 01:34 PM
:) you can do it 'nearly' dynamically without having acces to a crontab scheduler :)

but i'll leave it up to you ;)

just as a hint, look at the cached birthdays on forumhome ;)

Sho
03-19-2003, 01:37 PM
Alright, gonna do that. ;)

I also want to look at your forumhome optimization hack on the weekend, caching the moderators sounds like a nice idea.

Xenon
03-19-2003, 01:56 PM
thx :)

i currently have a chaching hype ;)

Xenon
03-19-2003, 02:43 PM
https://vborg.vbsupport.ru/showthread.php?postid=369297#post369297

i'm sure it can help you, too from what i know :)

Entourage
04-09-2003, 02:02 PM
Nice hack! installe whas super easy, works great, tnx!