PDA

View Full Version : Event 3 results are up


MikeK
04-20-2008, 03:07 PM
We had 67 people/76 entries

nmhansen
04-20-2008, 03:58 PM
I can't believe the results are up before even most people will be getting home.

That is awesome. Thanks to Mike and Scott for streamlining this process.

sperry
04-20-2008, 06:25 PM
I can't believe the results are up before even most people will be getting home.

That is awesome. Thanks to Mike and Scott for streamlining this process.
Hey, It only took 300 lines of code and about 6 hours of programming and testing!

<?php
/************************************************** **********************
* results.php
* - Results Page
************************************************** ***********************/
include_once("config.php");
include_once("database.php");
include_once("helpers.php");

$versions["results.php"] = "1.2.0";

function DisplayResults($category="", $table_title="Event Results:")
{
global $results_query, $results_standings_postfixes, $results_rounds_postfixes;

global $hi_color, $hi_color_alt, $hi_text, $hi_text_alt,
$lo_color, $lo_color_alt, $lo_text, $lo_text_alt,
$bg_color, $tx_color, $lk_color,
$user_color, $user_color_alt, $user_text, $user_text_alt;

$results = BuildResultsArray($category);

PRINT "
<table width='100%' border='0' cellspacing='0' cellpadding='3' bgcolor='$lo_color'>
<tr><td bgcolor='$hi_color'><font color='$hi_text'><b>$table_title<b></font></td></tr>
";

if (count($results) > 0)
{
foreach ($results as $season => $files)
{
PRINT "
<tr bgcolor='$lo_color_alt'><td align='left'><font color='$lo_text_alt'><b>$season:</b></font></td></tr>
";

if (count($files) > 0)
{
foreach ($results_standings_postfixes as $postfix => $description)
{
if (isset($files[$postfix]))
{
$link = $files[$postfix]["link"];
$desc = $files[$postfix]["desc"];
PRINT "
<tr bgcolor='$lo_color'><td align='left'><font color='$lo_text'><a href='$link'><b>$desc</b></a></font></td></tr>
";
}
}

PRINT "
<tr bgcolor='$lo_color'><td align='left'><table width='400'>
";

$roundnum = 1;
while (isset($files[$roundnum]))
{
PRINT "
<tr><td align='right'><font color='$lo_text'><b>Round $roundnum:</b></font></td>
";
foreach ($results_rounds_postfixes as $postfix => $description)
{
if (isset($files[$roundnum][$postfix]))
{
$link = $files[$roundnum][$postfix]["link"];
$desc = $files[$roundnum][$postfix]["desc"];
PRINT "
<td align='center'><font color='$lo_text'><a href='$link'>$desc</a></font></td>
";
}
}
PRINT "
</tr>
";
$roundnum++;
}

PRINT "
</table></font></td></tr>
";
}
else
{
PRINT "
<tr bgcolor='$lo_color'><td align='center'><font color='$lo_text' size='2'><i>No results available.</i></font></td></tr>
";
}
}
}
else
{
PRINT "
<tr bgcolor='$lo_color'><td align='center'><font color='$lo_text' size='2'><i>No results available.</i></font></td></tr>
";
}

PRINT "
</table>
";

}

function DisplayMiniResults($max_events, $url, $category="", $table_title="Event Results:")
{
global $results_query, $results_standings_postfixes, $results_rounds_postfixes;

global $hi_color, $hi_color_alt, $hi_text, $hi_text_alt,
$lo_color, $lo_color_alt, $lo_text, $lo_text_alt,
$bg_color, $tx_color, $lk_color,
$user_color, $user_color_alt, $user_text, $user_text_alt;

$results = BuildResultsArray($category);

PRINT "
<table width='100%' border='0' cellspacing='0' cellpadding='3' bgcolor='$lo_color'>
<tr><td bgcolor='$hi_color'><font color='$hi_text'><b>$table_title<b></font></td></tr>
";

if (count($results) > 0)
{
foreach ($results as $season => $files)
{
if (count($files) > 0)
{
PRINT "
<tr bgcolor='$lo_color_alt'><td align='left'><font color='$lo_text_alt' size='2'><b>$season:</b></font></td></tr>
";

$standings_count = 0;
foreach ($results_standings_postfixes as $postfix => $description)
{
if (isset($files[$postfix]))
{
$link = $files[$postfix]["link"];
$desc = $files[$postfix]["desc"];
PRINT "
<tr bgcolor='$lo_color'><td align='left'><font color='$lo_text' size='2'><a href='$link'><b>$desc</b></a></font></td></tr>
";
$standings_count++;
}
}

PRINT "
<tr bgcolor='$lo_color'><td align='left'><table width='400'>
";

$roundnum = count($files) - $standings_count;
while (isset($files[$roundnum]) && ($max_events > 0))
{
PRINT "
<tr><td align='right'><font color='$lo_text' size='2'><b>Round $roundnum:</b></font></td>
";
foreach ($results_rounds_postfixes as $postfix => $description)
{
if (isset($files[$roundnum][$postfix]))
{
$link = $files[$roundnum][$postfix]["link"];
$desc = $files[$roundnum][$postfix]["desc"];
PRINT "
<td align='center'><font color='$lo_text' size='2'><a href='$link'>$desc</a></font></td>
";
}
}
PRINT "
</tr>
";
$roundnum--;
$max_events--;
}

PRINT "
</table></font></td></tr>
";
}
else
{
PRINT "
<tr bgcolor='$lo_color'><td align='center'><font color='$lo_text' size='2'><i>No results available.</i></font></td></tr>
";
}
break; // out of foreach
}

}
else
{
PRINT "
<tr bgcolor='$lo_color'><td align='center'><font color='$lo_text' size='2'><i>No results available.</i></font></td></tr>
";
}

PRINT "
</table>
";
}

function HandleResultsPosts()
{
$rval = "";

return $rval;
}

function BuildResultsArray($category="")
{
global $root_results_dir, $results_categories, $results_standings_postfixes, $results_rounds_postfixes;

$results = Array();

$categorydirs = BuildSortedSubdirArray(getcwd() . $root_results_dir);
foreach ($categorydirs as $categorydir)
{
$curr_category = rtrim(strtolower($categorydir), "/");

if (($category === "") || (strtolower($category) == $curr_category))
{
$yeardirs = BuildSortedSubdirArray(getcwd() . $root_results_dir . $categorydir);
foreach ($yeardirs as $yeardir)
{
$year = rtrim($yeardir, "/");
$path = getcwd() . $root_results_dir . $categorydir . $yeardir;

if ($dir = opendir($path))
{
while ($filename = readdir($dir))
{
if (($filename != ".") && ($filename != "..") && !is_dir($path . $filename))
{
foreach ($results_standings_postfixes as $postfix => $description)
{
if ((strrpos($filename, $postfix) !== false) && (strrpos($filename, $postfix) == strlen($filename) - strlen($postfix)))
{
$results[$year . " " . $results_categories[$curr_category]][$postfix] = Array("desc" => $description, "link" => $root_results_dir . $categorydir . $yeardir . $filename);
}
}

foreach ($results_rounds_postfixes as $postfix => $description)
{
if ((strrpos($filename, $postfix) !== false) && (strrpos($filename, $postfix) == strlen($filename) - strlen($postfix)))
{
$roundnum = (int)substr($filename, strrpos($filename, $postfix) - 2, 2);
$results[$year . " " . $results_categories[$curr_category]][$roundnum][$postfix] = Array("desc" => $description, "link" => $root_results_dir . $categorydir . $yeardir . $filename);
}
}
}
}

ksort($results[$year . " " . $results_categories[$curr_category]], SORT_NUMERIC);

closedir($path);
}

}

}
}

/*
print "<pre>";
print_r($results);
print "</pre>";
//*/

return $results;
}

function BuildSortedSubdirArray($path)
{
$rval = Array();

if ($dir = opendir($path))
{
while ($filename = readdir($dir))
{
if (($filename != ".") && ($filename != "..") && is_dir($path . $filename))
{
$rval[] = $filename . "/";
}
}

closedir($path);
}

rsort($rval, SORT_NUMERIC);

return $rval;
}

function DisplayResultsAdminPage()
{
PRINT "<h3>Event Results Management</h3>";
}

function HandleResultsAdminPosts()
{
$rval = "";


// handle table editor
$rval .= HandleTableEditor("results");

return $rval;
}


?>


IBAlexCritiquesMyTables

MattR
04-20-2008, 06:30 PM
Holy Crap! My morning time held up pretty well even with the 27* temperatures. Great event Randy and Jim, you guys always put together fun events. I think next season we need to start in May, tell the jerk that makes the schedule to do better.

nmhansen
04-20-2008, 07:15 PM
Holy Crap! My morning time held up pretty well even with the 27* temperatures. Great event Randy and Jim, you guys always put together fun events. I think next season we need to start in May, tell the jerk that makes the schedule to do better.

I actually think the grip went away in the afternoon a little bit. It was 20 degrees warmer, but much windier. It felt colder standing around.

Or, at least that's my excuse for being .5 seconds behind running RNP in the afternoon.

solonut
04-20-2008, 07:23 PM
Holy Crap! My morning time held up pretty well even with the 27* temperatures. Great event Randy and Jim, you guys always put together fun events. I think next season we need to start in May, tell the jerk that makes the schedule to do better.

we will just have his wife woop up on him & set him straight;)

Kevin M
04-20-2008, 08:02 PM
Holy Crap! My morning time held up pretty well even with the 27* temperatures. Great event Randy and Jim, you guys always put together fun events. I think next season we need to start in May, tell the jerk that makes the schedule to do better.

Why? It would just snow on us then. :(

dsmith
04-21-2008, 11:48 AM
Scott, very impressive work with the results. The whole region thanks you.

dsmith
04-21-2008, 11:50 AM
Has anyone else noticed that the weekend between Events 1 and 2-3 was gorgeous, and the Track Trial weekend coming up is supposed to be in the mid 70's? We just scheduled a week off for Solo events this year.

MikeK
04-21-2008, 12:22 PM
I vote no more events in april. If last weekend was my first introduction to autox, I wouldn't be coming back.

AlexR
04-21-2008, 12:42 PM
Wow, Crazy fast response time with the Results.

and Damn php is ugly, I'de much rather write 1 SQL Stored Proc, write 1 .net page that loads up a data set and binds it to the DataGrid. it would have taken me about 30 lines of code an 20 minutes :P Maybe an extra 20 minutes if i also wanted a program to import the xls (or flat file) directly into SQL , so i wouldn't have to fire up DTS (now SSIS in sql 05) But you can't exactly switch your hosting to IIS 6.0 with M$ SQL support.

#using System.Data.Sqlclient

sqlconnection Con = new sqlconnection("your con string");
sqlcommand ICommandIt = new sqlcommand("SP_getResults");
IcommandIT.parameters.add("@Event_Number",sqltype.Int);
IcommandIt.parameters["@Event_Number"];

sqldataadpater IAdapt = new sqldataadapter(IcommandIT);
DataTable TheResults = new datatable();
IAdapt.fill(TheRules);

MyResultsGrid.DataSource=TheResults;
MyResultsGrid.Bind();


:P :P :P :P Oh wait that's only 10 lines. and i Still recall Scott telling me it would be impossible to create a DB Driven system for the results... :P


On a non C# is cooler (for religious reasons) then php note.


Thanks for Taking the time to write code to make the html pages for us, Esp seeing how you have no plans to autoX. I can't think of anyone else would voluneteer coding time, to help a program they don't compete in. I'm way to much of a jerk to ever do something like that.

nmhansen
04-21-2008, 12:46 PM
The results are already pre-generated at the event into an HTML file. The code Scott wrote just reads the directory to see which results are available.

Kind of different than an DB driven results system.

solonut
04-21-2008, 12:50 PM
Wow, Crazy fast response time with the Results.

and Damn php is ugly, I'de much rather write 1 SQL Stored Proc, write 1 .net page that loads up a data set and binds it to the DataGrid. it would have taken me about 30 lines of code an 20 minutes :P Maybe an extra 20 minutes if i also wanted a program to import the xls (or flat file) directly into SQL , so i wouldn't have to fire up DTS (now SSIS in sql 05) But you can't exactly switch your hosting to IIS 6.0 with M$ SQL support.

#using System.Data.Sqlclient

sqlconnection Con = new sqlconnection("your con string");
sqlcommand ICommandIt = new sqlcommand("SP_getResults");
IcommandIT.parameters.add("@Event_Number",sqltype.Int);
IcommandIt.parameters["@Event_Number"];

sqldataadpater IAdapt = new sqldataadapter(IcommandIT);
DataTable TheResults = new datatable();
IAdapt.fill(TheRules);

MyResultsGrid.DataSource=TheResults;
MyResultsGrid.Bind();


:P :P :P :P Oh wait that's only 10 lines. and i Still recall Scott telling me it would be impossible to create a DB Driven system for the results... :P


On a non C# is cooler (for religious reasons) then php note.


Thanks for Taking the time to write code to make the html pages for us, Esp seeing how you have no plans to autoX. I can't think of anyone else would voluneteer coding time, to help a program they don't compete in. I'm way to much of a jerk to ever do something like that.

And I thought reading the High altitude pax thread made my head hurt.....:p

sperry
04-21-2008, 01:00 PM
The results are already pre-generated at the event into an HTML file. The code Scott wrote just reads the directory to see which results are available.

Kind of different than an DB driven results system.
Plus that code Alex put up just gets the data from the DB and displays it. It doesn't have any of the logic needed to actually correctly create the results in the first place.

Hey Mike, how many lines of code does your version of the results generator have? The source files for my time trials generator is around 45K, and that's for the much simpler task of creating trials results that doesn't have anywhere near the class/PAX/N/RNP/Ladies complexity.

Kevin M
04-21-2008, 01:14 PM
IBAlexCritiquesMyTables

Not by much though. :D

MikeK
04-21-2008, 01:26 PM
Hey Mike, how many lines of code does your version of the results generator have? The source files for my time trials generator is around 45K, and that's for the much simpler task of creating trials results that doesn't have anywhere near the class/PAX/N/RNP/Ladies complexity.

My scoring software has eleventeen billion lines of code, but that is because I learned early in my career that job security is the most important feature.

AlexR
04-21-2008, 04:04 PM
LoL yeah it only displays it. but the sql to pull out results by filter is easy, highly dynamic. as would the code to save the results from any format into the DB.

select * from results where event_number=@event and season=@year
Order by @Myfilter :P course then i have to add in 2 more paramters,

then you have a table for events with years, and you set up your global.asax to query that table and load an application hash table, that hashtable auto populates your drop downs choices for Year and Event #.

It makes a fast easy to use, flexible system, quickly. say like 2 hours TOPS for everything. :p Except that its windows Only. and they already have a solution, and I was already told its impossible, and i was further told specifically they don't want my help.

So all i'm doing is having some light hearted fun tossing around my sour grapes (cause it makes nasty Grape juice and my neighbor has a no grapes throwing restraining order against me)

AlexR
04-21-2008, 04:05 PM
My scoring software has eleventeen billion lines of code, but that is because I learned early in my career that job security is the most important feature.


I could learn a lot from Mike, I did not do that at my last job, and i got laid off after 10 years when they gave me some BS line about leaving the country , LOL Doh ... we live and we learn eh?

Dean
04-21-2008, 06:01 PM
LoL yeah it only displays it. but the sql to pull out results by filter is easy, highly dynamic. as would the code to save the results from any format into the DB.
...
I volunteer to be timing chief.
FIXED!

MikeK
04-21-2008, 09:00 PM
So Alex, we should meet up before the next event so that we can start your training

Cody
04-21-2008, 09:13 PM
I actually think the grip went away in the afternoon a little bit. It was 20 degrees warmer, but much windier. It felt colder standing around.

Or, at least that's my excuse for being .5 seconds behind running RNP in the afternoon.

You didn't have the motivation of beating me in front of my girlfriend in the afternoon. :P

sperry
04-21-2008, 09:34 PM
LoL yeah it only displays it. but the sql to pull out results by filter is easy, highly dynamic. as would the code to save the results from any format into the DB.

select * from results where event_number=@event and season=@year
Order by @Myfilter :P course then i have to add in 2 more paramters,

then you have a table for events with years, and you set up your global.asax to query that table and load an application hash table, that hashtable auto populates your drop downs choices for Year and Event #.

It makes a fast easy to use, flexible system, quickly. say like 2 hours TOPS for everything. :p Except that its windows Only. and they already have a solution, and I was already told its impossible, and i was further told specifically they don't want my help.

So all i'm doing is having some light hearted fun tossing around my sour grapes (cause it makes nasty Grape juice and my neighbor has a no grapes throwing restraining order against me)
Sure, it's so simple! :p

Now, how do you handle the fact that every season the scoring rules change? That PAX factors change? That drivers get entered with misspelled names and have to be aliased? That Novice drivers have to be removed from the results as soon as they run a round in a points scoring class? That event results need to be audited and modified sometimes months after the event? That the Pro class is a PAX sorted class based on multiple base classes? That a driver can run in more than one class during the season and his/her points results have to be separated properly by class? What about trophy eligibility? And so on.

I'm not saying a DB based approach is impossible... there are certainly benefits to the dynamic creation of content. On the other hand, the logic is so complicated, every time a person hits the results page, you're running 30% of the server's CPU to generate the html for an event (oh wait, you were including page caching too, weren't you!).

My point is only that the system is non-trivial. A database of runs and driver names can't score a season. You'd end up with 1000's of lines of SQL handling the scoring logic, and you'd have to re-write it every year once the supps are approved. Not impossible, but certainly more than 2 hours of work. It's more like 2 weeks to 2 months of work depending on how much time you have away from your real job.

PS: this is turning into a massive dejavu thread!

nmhansen
04-21-2008, 09:56 PM
You didn't have the motivation of beating me in front of my girlfriend in the afternoon. :P


Yeah, well... she still went home with you.

Cody
04-21-2008, 10:04 PM
Yah, but she would rather that I take up drag racing instead of autocross :eek: so what does that say about her judgement? :p

nmhansen
04-21-2008, 10:05 PM
Nothing more than the fact that she's dating you already does :p

Cody
04-22-2008, 07:30 AM
It's almost like I walked right into that one. :rolleyes:

sperry
04-22-2008, 08:29 AM
Nothing more than the fact that she's dating you already does :p
OMG. :lol:

Dean
04-22-2008, 08:36 AM
OMG. :lol:Error: 101 - Emoticon not found! Please contact system administrator.

Cody
04-22-2008, 08:55 AM
OMG. :lol:

Does your GF know your spending the Summer vacation money on a 6th engine rebuild?

nmhansen
04-22-2008, 08:58 AM
It's almost like I walked right into that one. :rolleyes:

Yeah, couldn't let that one slip by :p

sperry
04-22-2008, 09:44 AM
Does your GF know your spending the Summer vacation money on a 6th engine rebuild?
Who says I'm rebuilding the engine? Or didn't you notice the car is for sale as-is already?

Cody
04-22-2008, 09:48 AM
I did, but I think that there's a good chance you'll end up keeping it. Just ribbing you anyway.

Kevin M
04-22-2008, 09:53 AM
I did, but I think that there's a good chance you'll end up keeping it. Just ribbing you anyway.

How many engine rebuilds would your girlfriend tolerate? I bet Scott's gonna score higher there than most of us would!

sperry
04-22-2008, 10:02 AM
I did, but I think that there's a good chance you'll end up keeping it. Just ribbing you anyway.
If no one buys it and I have to put a motor in it to sell it, then I may or may not keep it. If I can get enough for the car to cover the cost of rebuilding the motor before selling it to buy a new STI, I'll probably still just sell it.

Cody
04-22-2008, 10:08 AM
How many engine rebuilds would your girlfriend tolerate? I bet Scott's gonna score higher there than most of us would!

Hopefully we never have to find out.