﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
989	Query to detect completed chip run is tautological	Paul Price	jhoblitt	"""chiptool -addprocessedimfile"", after adding the processed imfile, checks to see if the exposure is complete, using the SQL in chiptool_completely_processed_exp.sql  However, this seems to always return a line, regardless of how many imfiles have been processed.  Here's a demonstration using database 'gpctest':

mysql> select count(class_id) from rawImfile where exp_id = 450; +-----------------+
| count(class_id) |
+-----------------+
|              60 |
+-----------------+
1 row in set (0.00 sec)
 
mysql> select count(class_id) from chipProcessedImfile where exp_id = 450;
+-----------------+
| count(class_id) |
+-----------------+
|              20 |
+-----------------+
1 row in set (0.00 sec)

### This is the essence of the query in chiptool_completely_processed_exp.sql:

mysql> SELECT
    ->         chipRun.*,
    ->         rawImfile.class_id as rawimfile_class_id,
    ->         chipProcessedImfile.class_id
    ->     FROM chipRun
    ->     JOIN rawImfile
    ->         USING(exp_id)
    ->     LEFT JOIN chipProcessedImfile
    ->         ON chipRun.chip_id = chipProcessedImfile.chip_id
    ->         AND rawImfile.exp_id = chipProcessedImfile.exp_id
    ->         AND rawImfile.class_id = chipProcessedImfile.class_id
    ->     WHERE
    ->         chipRun.state = 'run'
    ->         AND chipProcessedImfile.fault = 0
    ->     GROUP BY
    ->         chipRun.chip_id,
    ->         chipRun.exp_id
    ->     HAVING COUNT(rawImfile.class_id) = COUNT(chipProcessedImfile.class_id);
+---------+--------+-------+------------------+---------------+-------+-----------+----------+-------+--------------------+----------+
| chip_id | exp_id | state | workdir          | workdir_state | label | reduction | expgroup | dvodb | rawimfile_class_id | class_id |
+---------+--------+-------+------------------+---------------+-------+-----------+----------+-------+--------------------+----------+
|     450 |    450 | run   | path://GPC1/pap/ | dirty         | NULL  | OVERSCAN  | NULL     | NULL  | XY01               | XY01     |
+---------+--------+-------+------------------+---------------+-------+-----------+----------+-------+--------------------+----------+
1 row in set (0.01 sec)
 

This prevents us from processing a full GPC exposure.  Not sure why we haven't noticed it from running MegaCam.  I expect I only got 20 processed imfiles through because pantasks takes 20 imfiles at a time, so the first triggered the completed chipRun, and the other 19 ran anyway and then added themselves as processed."	defect	closed	highest		ippTools	unspecified	major	fixed	VERIFIED	
