SELECT DISTINCT
    'warp' as stage,
    warpRun.warp_id AS stage_id,
    warpRun.magicked,
    rawExp.exp_name as run_tag,
    distTarget.label,
    distTarget.target_id,
    distTarget.clean
FROM warpRun
JOIN fakeRun USING(fake_id)
JOIN camRun ON fakeRun.cam_id = camRun.cam_id
JOIN chipRun USING(chip_id)
JOIN rawExp USING(exp_id)
JOIN distTarget ON distTarget.stage = 'warp' 
    AND warpRun.label = distTarget.label
    AND rawExp.filter = distTarget.filter
JOIN rcInterest USING(target_id)
LEFT JOIN distRun ON distRun.stage = 'warp' AND (distRun.stage_id = warp_id)
    AND distRun.clean = distTarget.clean
WHERE  distTarget.state = 'enabled'
    AND rcInterest.state = 'enabled'
    AND distRun.dist_id IS NULL
    AND ((warpRun.state = 'full') OR (distTarget.clean AND warpRun.state = 'cleaned'))



