changeset 40:20870c5d9b45

Using name sorting, handling unknowns
author Dominic Cleal <dominic@computerkb.co.uk>
date Sun, 25 Jan 2009 20:40:36 +0000
parents b231022614aa
children e6bb8593c1e8 e9429d4a7942
files reproctool.cgi
diffstat 1 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/reproctool.cgi	Sun Jan 25 20:03:54 2009 +0000
+++ b/reproctool.cgi	Sun Jan 25 20:40:36 2009 +0000
@@ -220,7 +220,7 @@
 INNER JOIN eveGraphics graphics ON types.graphicID = graphics.graphicID
 WHERE $sql_typenames
 GROUP BY types.typeID
-ORDER BY groups.categoryID DESC, groupName ASC, typeName ASC
+ORDER BY typeName ASC
 END
 my $pre_reprocess = $db->prepare($sql_reprocess);
 
@@ -233,6 +233,7 @@
                              \$icon, \$ttrit, \$tpyer, \$tmexa, \$tisog,
                              \$tnocx, \$tzydr, \$tmega, \$tmorp);
 
+my $item_lookup = {};
 my @output = ();
 while ($pre_reprocess->fetch())
 {
@@ -246,11 +247,14 @@
     $meta = 0 unless defined $meta;
     $item = { id => $tid, name => $tname, meta => $meta, icon => $icon,
               price => $basePrice, reprocessIsk => $isk, reprocessDetails => $repDetails };
-    
-    # If this item exists multiple times in the input, then they weren't stacked
-    # so output it multiple times
-    my @matching_in = grep({ $_ eq $tname } @item_names);
-    push @output, $item foreach (0..$#matching_in);
+    $item_lookup->{$tname} = $item;
+}
+
+# Now match up the item lookups to the input list
+foreach (sort @item_names)
+{
+    push @output, (exists $item_lookup->{$_} ? $item_lookup->{$_}
+                                             : { name => $_ } );
 }
 
 my $col = 0;
@@ -282,8 +286,8 @@
 selling that item for a price below that number, its better to keep the item
 and reprocess it.
 <p />
-As you might see, the items are listed just like your inventory in EVE. The
-sorting is the same as when you sort by type. If you have this browser
+As you might see, the items are listed similarly to your inventory in EVE.
+You will need to sort your EVE window by name to match. If you have this browser
 window next to your inventory window, matching the columns(!), it is very
 easy to pick out those valuable items.
 <p />