chiark / gitweb /
yarrg database code: eliminate all NATURAL JOINs and turn them into JOIN USING
[ypp-sc-tools.main.git] / yarrg / web / query_age
index 419febc976277efae36a682129fabd428c657061..a115bbdd562dd53286be49ff175f5519f366cd28 100644 (file)
@@ -47,7 +47,7 @@ $dbh
 my $now= time;
 
 my $sth= $dbh->prepare("SELECT archipelago, islandid, islandname, timestamp
-                               FROM uploads NATURAL JOIN islands
+                               FROM uploads JOIN islands USING (islandid)
                                ORDER BY archipelago, islandname");
 $sth->execute();
 
@@ -81,7 +81,6 @@ $sth->execute();
 % $da_ages{'id_loaded'}= 0;
 % my $rowix= 0;
 % while ($row= $fetchrow->()) {
-%      print STDERR "$row\n";
 %      my $rowid= "id_$row->{'islandid'}";
 %      my $cellid= "c$rowid";
 %      my $age= $now - $row->{'timestamp'};
@@ -124,6 +123,7 @@ Time since this page loaded:
     var now= Date.now();
     debug('updating now='+now);
     for (var ageid in <% $jsprefix %>ages) {
+      if (!<% $jsprefix %>ages.hasOwnProperty(ageid)) continue;
       var oldage= <% $jsprefix %>ages[ageid];
       var el= document.getElementById(<% $elemidprefix %>ageid);
       var age= oldage + (now - da_pageload) / 1000;
@@ -142,6 +142,7 @@ Time since this page loaded:
 <& "lookup:formhidden", ours => sub { 0; } &>
 </form>
 
+</div>
 <%init>
 use POSIX;
 use CommodsWeb;