mozilla/datazilla — pull request #52 by jeads (2012-07-17 00:21:52+00:00)
Title: Ui sql fixes

This branch fixes the following issues:

1.) The UI was using cached reference data that was only loaded when the server was started, this means that any new reference data inserted after that would not be visible in the cache. To fix this the following changes were made:
- `PerformanceTestModel.get_test_reference_data()` was modified to cache reference data.
- An explicit method to cache data was added and is now called in the manage command `populate_summary_cache`. Any time cached summary data is modified the reference data cache is updated.

2.) The manage command, `populate_test_collections`, was failing on data integrity errors caused by inserting duplicate keys.
- The method was modified to only insert product test collections that have not already been inserted.

3.) The UI needs to specify a default branch when it first loads. This branch is different for different projects. A column, `default_product`, was added to the `product` table to be used as a boolean indicating which product is the default. get/set methods were added to `PerformanceTestModel` to support its use. When this branch is rolled the following alter statement needs to be run on all `perftest` databases:

`ALTER TABLE `*_perftest_1`.`product` ADD COLUMN `default_product` TINYINT NOT NULL DEFAULT 0 AFTER `version`;

The default product is cached in memcached for rapid retrieval.

4.) All of the methods in `PerformanceTestModel` that insert reference data used an `ON DUPLICATE KEY UPDATE` strategy. In MySQL this causes the AUTO_INCREMENT to increment on every update which creates large gaps in the id column. This will be a problem if we exceed the max size of an int and it's also really ugly. To fix this all `ON DUPLICATE KEY UPDATE` SQL methods were modified to work as `INSERT INTO ... SELECT FROM DUAL WHERE NOT EXIST` statements. This will keep our ids consecutive and we won't have to worry about exceeding an int.