Limit number of "additional samples" in phylo tree creation (#3051)
Limit number of "additional samples" in phylo tree creation (#3051)

Limit number of "additional samples" in phylo tree creation# Description

In investigating a pipeline error, I discovered that phylo tree creation was broken for admins in prod. The root cause is a unscalable query. 

# Notes

* I isolated the slow query in the console 
* The SQL query is still really ugly and could be optimized more

```
SELECT `pipeline_runs`.`id`
FROM `pipeline_runs`
WHERE `pipeline_runs`.`sample_id` IN (3412, ...
  AND (id IN
         (SELECT max(id)
          FROM pipeline_runs
          WHERE job_status = 'CHECKED'
            AND sample_id IN
              (SELECT id
               FROM samples)
          GROUP BY sample_id))
  AND `pipeline_runs`.`id` IN (2913, ...
ORDER BY `pipeline_runs`.`id` DESC LIMIT 1000
```

# Tests

* See limit in query log

* Try advancing in localhost, see appropriate data return 

* Confirm 1000 rows in table


![image](https://user-images.githubusercontent.com/28797/74063731-ee9e3a80-49a5-11ea-81ec-3ced3bd86489.png)

![image](https://user-images.githubusercontent.com/28797/74064653-fb239280-49a7-11ea-8981-0370cff777ea.png)



![image](https://user-images.githubusercontent.com/28797/74063732-efcf6780-49a5-11ea-8f1b-1f02a639ff22.png)



chanzuckerberg/idseq-web,chanzuckerberg/idseq-web,chanzuckerberg/idseq-web,chanzuckerberg/idseq-web,chanzuckerberg/idseq-web