IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40757 for trunk/ippScripts


Ignore:
Timestamp:
May 29, 2019, 9:26:18 AM (7 years ago)
Author:
tdeboer
Message:

script adjusted to handle duplicate comment strings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/night_report.pl

    r40756 r40757  
    771771    print "Current status of SS and Euclid chunks:\n";
    772772
    773     #This is a long query, but it efficiently gathers all the necessary information
    774     my $query = "SELECT groupchunk.chunk,groupchunk.Nquad_firstvisit,group4.Nquad_fourvisits,groupdiff.Ndiffs FROM";
     773    #First find the number of chunks and their names
     774    my $query = "SELECT groupchunk.chunk,groupchunk.Nquad_firstvisit,group4.Nquad_fourvisits FROM";
    775775    $query .= "   (";
    776     $query .= "     SELECT dateobs,comment,substr(comment, 1, position(' ' in comment)) AS chunk,count(*) AS Nquad_firstvisit";
     776    $query .= "     SELECT dateobs,comment,substr(comment, 1, position(' ' in comment)) AS chunk,count(distinct(comment)) AS Nquad_firstvisit";
    777777    $query .= "     FROM rawExp";
    778778    $query .= "     WHERE dateobs LIKE '$date%'";
     
    784784    $query .= "   (";
    785785    $query .= "     SELECT groupobj.chunk,count(*) AS Nquad_fourvisits FROM ";
    786     $query .= "       (SELECT substr(comment, 1, position(' ' in comment)) AS chunk,count(*) AS Nvisits";
     786    $query .= "       (SELECT substr(comment, 1, position(' ' in comment)) AS chunk,count(distinct(comment)) AS Nvisits";
    787787    $query .= "         FROM rawExp";
    788788    $query .= "         WHERE dateobs LIKE '$date%' AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%')";
     
    794794    $query .= "   ) AS group4";
    795795    $query .= "   on groupchunk.chunk=group4.chunk";
    796     $query .= "   LEFT JOIN";
    797     $query .= "   (";
    798     $query .= "     SELECT substr(expall.comment, 1, position(' ' in expall.comment)) AS chunk,count(*) AS Ndiffs FROM ";
    799     $query .= "       (SELECT exp_name,comment,dateobs";
    800     $query .= "         FROM rawExp ";
    801     $query .= "         WHERE dateobs LIKE '$date%' AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%') AND obs_mode NOT LIKE 'ENGINEERING'";
    802     $query .= "       ) AS expall ";
    803     $query .= "     LEFT JOIN";
    804     $query .= "     (SELECT * FROM ";
    805     $query .= "       (";
    806     $query .= "         (SELECT exp_name FROM ";
    807     $query .= "           diffRun JOIN diffInputSkyfile USING (diff_id) JOIN publishRun ON (diff_id = stage_id) JOIN warpRun ON (warp1=warp_id)";
    808     $query .= "           JOIN fakeRun USING (fake_id) JOIN camRun USING (cam_id) JOIN camProcessedExp USING (cam_id) JOIN chipRun USING (chip_id) JOIN rawExp USING (exp_id)";
    809     $query .= "           WHERE rawExp.dateobs LIKE '$date%' AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%')";
    810     $query .= "           AND stack2 IS NULL AND diffRun.diff_id=stage_id";
    811     $query .= "         )  ";
    812     $query .= "         UNION ";
    813     $query .= "         (SELECT exp_name FROM";
    814     $query .= "           diffRun JOIN diffInputSkyfile USING (diff_id) JOIN publishRun ON (diff_id = stage_id) JOIN warpRun ON (warp2=warp_id)";
    815     $query .= "           JOIN fakeRun USING (fake_id) JOIN camRun USING (cam_id) JOIN camProcessedExp USING (cam_id) JOIN chipRun USING (chip_id) JOIN rawExp USING (exp_id)";
    816     $query .= "           WHERE rawExp.dateobs LIKE '$date%' AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%')";
    817     $query .= "           AND stack2 IS NULL AND diffRun.diff_id=stage_id";
    818     $query .= "         )";
    819     $query .= "       ) AS diffgather ";
    820     $query .= "       GROUP BY diffgather.exp_name";
    821     $query .= "     ) AS exppub";
    822     $query .= "     ON expall.exp_name=exppub.exp_name";
    823     $query .= "     WHERE exppub.exp_name=expall.exp_name";
    824     $query .= "     GROUP BY chunk ";
    825     $query .= "   ) AS groupdiff";
    826     $query .= "   ON groupchunk.chunk=groupdiff.chunk";
    827 
     796 
    828797    my $result = &mysql_select ($query);
    829798
    830799    printf "%18s | %18s | %18s | %18s |\n", "chunk", "Nquad_firstvisit", "Nquad_fourvisits", "Ndiffs done";
    831800    while (@row = $result->fetchrow_array()) {
    832           if ($row[1] ne $row[2]) {
    833             if ($row[3] ne ($row[1]*4)) {printf "%18s | %18s | %18s | %14s%4s | %18s\n", $row[0], $row[1], $row[2], $row[3], "/?  ", "chunk not finished";}  # chunk    Nquad_firstvisit        Nquad_fourvisits        Ndiffs
    834             if ($row[3] eq ($row[1]*4)) {printf "%18s | %18s | %18s | %14s%4s | %18s\n", $row[0], $row[1], $row[2], $row[3], "/?  ", "chunk done";}          # chunk    Nquad_firstvisit        Nquad_fourvisits        Ndiffs
     801          my $chunkname = $row[0];
     802          my $Nfirstvisits = $row[1];
     803          my $Nfourvisits = $row[2];
     804
     805          my $query2 .= "     SELECT warp_id FROM ";
     806          $query2 .= "           warpRun JOIN fakeRun USING (fake_id) JOIN camRun USING (cam_id) JOIN camProcessedExp USING (cam_id) JOIN chipRun USING (chip_id) JOIN rawExp USING (exp_id)";
     807          $query2 .= "           WHERE rawExp.dateobs LIKE '$date%' AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%')";
     808          $query2 .= "           AND substr(comment, 1, position(' ' in comment)) LIKE '$chunkname%'";
     809          my $result2 = &mysql_select ($query2);
     810
     811          my $Ndiffs = 0;
     812          while (@row2 = $result2->fetchrow_array()) {
     813              my $query3 .= "     SELECT diff_id FROM ";
     814              $query3 .= "           diffRun JOIN diffInputSkyfile USING (diff_id) JOIN publishRun ON (diff_id = stage_id) JOIN warpRun ON (warp1=warp_id)";
     815              $query3 .= "           WHERE stack2 IS NULL AND warp_id='$row2[0]' GROUP BY diff_id";
     816              my $result3 = &mysql_select ($query3);
     817              while (@row3 = $result3->fetchrow_array()) {if ($row3[0] !=0) {$Ndiffs ++;}}
     818
     819              my $query3 .= "     SELECT diff_id FROM ";
     820              $query3 .= "           diffRun JOIN diffInputSkyfile USING (diff_id) JOIN publishRun ON (diff_id = stage_id) JOIN warpRun ON (warp2=warp_id)";
     821              $query3 .= "           WHERE stack2 IS NULL AND warp_id='$row2[0]' GROUP BY diff_id";
     822              my $result3 = &mysql_select ($query3);
     823              while (@row3 = $result3->fetchrow_array()) {if ($row3[0] !=0) {$Ndiffs ++;}}
    835824          }
    836           if ($row[1] eq $row[2]) {
    837             if ($row[3] ne ($row[1]*4)) {printf "%18s | %18s | %18s | %14s%1s%3s | %18s\n", $row[0], $row[1], $row[2], $row[3],"/",$row[1]*4, "chunk not finished";}  # chunk   Nquad_firstvisit        Nquad_fourvisits        Ndiffs
    838             if ($row[3] eq ($row[1]*4)) {printf "%18s | %18s | %18s | %14s%1s%3s | %18s\n", $row[0], $row[1], $row[2], $row[3],"/",$row[1]*4, "chunk done";}          # chunk   Nquad_firstvisit        Nquad_fourvisits        Ndiffs
     825
     826          if ($Nfirstvisits ne $Nfourvisits) {
     827            if ($Ndiffs ne ($Nfirstvisits*4)) {printf "%18s | %18s | %18s | %14s%4s | %18s\n", $chunkname, $Nfirstvisits, $Nfourvisits, $Ndiffs, "/?  ", "chunk not finished";}  # chunk        Nquad_firstvisit        Nquad_fourvisits        Ndiffs
     828            if ($Ndiffs eq ($Nfirstvisits*4)) {printf "%18s | %18s | %18s | %14s%4s | %18s\n", $chunkname, $Nfirstvisits, $Nfourvisits, $Ndiffs, "/?  ", "chunk done";}          # chunk        Nquad_firstvisit        Nquad_fourvisits        Ndiffs
     829          }
     830          if ($Nfirstvisits eq $Nfourvisits) {
     831            if ($Ndiffs ne ($Nfirstvisits*4)) {printf "%18s | %18s | %18s | %14s%1s%3s | %18s\n", $chunkname, $Nfirstvisits, $Nfourvisits, $Ndiffs,"/",$Nfirstvisits*4, "chunk not finished";}  # chunk Nquad_firstvisit        Nquad_fourvisits        Ndiffs
     832            if ($Ndiffs eq ($Nfirstvisits*4)) {printf "%18s | %18s | %18s | %14s%1s%3s | %18s\n", $chunkname, $Nfirstvisits, $Nfourvisits, $Ndiffs,"/",$Nfirstvisits*4, "chunk done";}          # chunk Nquad_firstvisit        Nquad_fourvisits        Ndiffs
    839833          }
    840834    }
Note: See TracChangeset for help on using the changeset viewer.