PDA

View Full Version : Based on Post Count


Justin M
02-21-2013, 10:40 PM
I'm wanting to create a template edit on my sports forum for "MLB ERA" - The more the member posts the lower the ERA goes down.

If you do not know what MLB ERA is:
http://www.ehow.com/how_9733_calculate-earned-run.html

What would I need to do to accomplish this?

kh99
02-22-2013, 03:30 PM
It sounds like it's very similar to "posts per day" that this site displays, except lower is better. So I guess you'd have to figure out how you want to calculate that. I suppose you could do something like decide that N or more posts per day is "perfect", then calculate the number of posts per day for a user and subtract from N (although then anyone with N or more posts per day would have an "era" of 0, so maybe you need something like 1/PPD instead?).

As for actually implementing it, you'd probably need a plugin to calculate it. If you only want to display it in the postbit then you could use postbit_display_complete and use the values in $post (which should contain the author's data), and set $post['era'] or something like that.

Justin M
02-22-2013, 07:25 PM
Thanks kh99! Seems like a very simple task, but I'm a beginner so I'll need a little help.

Will you help me with the plugin, as I'm not sure.

kh99
02-22-2013, 10:24 PM
I think it's probably only a few lines so I could do that, if you can tell me exactly how you want to calculate it. Do you want it to be a "lifetime" value? Hopefully that's OK because it's easy enough to get the time since a user joined and the total posts since they've joined, otherwise it gets more difficult. But one issue with it being a lifetime value is that it of course gets harder and harder to change as time goes on.

Justin M
02-22-2013, 10:28 PM
Yes lifetime value is okay - anything that's easy enough for you. Just make it go along with the ERA, the link I posted above. This will be greatly appreciated!

Justin M
02-24-2013, 07:11 PM
kh99, I'm not replying to disturb you if you're busy but about long will it take you to get the plugin done? I'm interested in adding this asap. Thanks much!

-Justin

kh99
02-24-2013, 07:15 PM
It's OK, it's good to remind me. But I had been hoping you'd specify how you wanted it calculated. The plugin's not an issue, it's figuring out the equation. Like I mentioned above, it doesn't really translate exactly because with era low is good. If you picked a certain number of posts per day or week that you wanted for someone to be "perfect" then a lot of people would probably have 0.00, which I figured you wouldn't want.

I can probably figure out something that works but I need to think about it.

mokujin
02-24-2013, 07:19 PM
What does "Earned Run Average" mean in MLB? I'm from Europe and only watch Football :D

Justin M
02-24-2013, 07:51 PM
Thanks kh99!

per predictem
Add up a pitchers innings. An inning is three outs. If you see 6.1 or 6.2 that means 6.33 or 6.67 innings. Unlike some other baseball stats, we don't round up when we're talking about ERA.

Now add up all the earned runs the pitcher gave up during the innings he's pitched. For arguments sake, lets say he gave up 3 earned runs.

Now multiply the earned runs by 9.

Now divide by the total innings pitched.

Example: A pitcher goes 5 innings and gives up 3 earned runs. We take the earned runs x 9 which gives us 27. We then divide this by the innings pitched 27 divided by 5 = 5.40.
In case you're wondering what the good, bad and the ugly are ERA-wise in the big leagues it could be said that:

An earned run average of 2.00 or lower is an ace and a very sharp pitcher. Anything 3.00 or under is ROCK solid. An ERA of 3.00 to 3.50 is GOOD. Conversely, 4.00 to 5.00 is average and anything above 5.00 a guy is probably struggling to stay in the bigs and is getting hit pretty hard.

If you can figure out how to make the users posts go along with the time registered to show the ERA (I think I'm on the right path), that is pure genius. I'm not that good with equations.

mokujin, ERA or earned run average, is another way of saying "what a pitcher gives up per nine innings that he pitches."

kh99
02-25-2013, 05:30 PM
I was hoping mokujin might decide to come up with something. Anyway, it's actually a pretty simple plugin, you just need to create a new plugin using hook postbit_display_complete and code something like:

if (!$post['posts'])
$post['era'] = "No Posts Yet";
else
{
$days = $post['joindateline'] / (3600 * 24); // 3600 * 24 = seconds in a day
$era = $days / $post['posts'];
$post['era'] = vb_number_format($era, 2);
}



Then use {vb:raw post.era} in your postbit or postbit_legacy template.

This just uses 1/posts per day so that lower is "better", but I'm kind of guessing that's going to give values for some users that don't look like reasonable ERA values, so you'll probably want some tweaking.

Justin M
02-25-2013, 09:16 PM
Thanks kh99! I really appreciate this.

Is there any way to get it to say "MLB ERA" - I've got the numbers showing up, just need MLB ERA:
ex.
Join Date
Posts:
Location:
MLB ERA:

mokujin
02-25-2013, 09:23 PM
Use: MLB ERA: {vb:raw post.era}

Justin M
02-25-2013, 09:32 PM
Use: MLB ERA: {vb:raw post.era}

Thanks mokujin!

Works great, thanks again for your support guys!

Justin M
05-29-2013, 06:53 PM
After 1,000 posts the ERA messes up. I went from 15.00 ERA to 1.000000000 so I disabled it. I was lurking around on other sports forums and seen that a baseball forum is using this. Although, they are using MiLB A ERA MiLB AA ERA, MLB AAA ERA & MLB ERA. How in the world could I get this to work correctly? Keep in mind a VERY good ERA is 2.50 and below.

Maybe I could use this for the total posts one has instead of join date being combined?

Lynne
05-29-2013, 08:19 PM
You'll need to remove the comma from the posts. Something like...

$post['posts'] = str_replace(",", "", $post['posts']);