Jeremy D commited on 2011-09-28 14:10:58
Showing 1 changed files, with 63 additions and 2 deletions.
... | ... |
@@ -296,6 +296,35 @@ class mbt_to_tbg |
296 | 296 |
{ |
297 | 297 |
$substep = $this->getSubStep(__FUNCTION__); |
298 | 298 |
|
299 |
+ // Obtain any current builds. |
|
300 |
+ $query = ' |
|
301 |
+ SELECT |
|
302 |
+ id, name |
|
303 |
+ FROM ' . $this->mbt_db_prefix . 'builds'; |
|
304 |
+ $builds = array(); |
|
305 |
+ foreach ($this->db->query($sql) as $row) |
|
306 |
+ $builds[$row['name']] = $row['id']; |
|
307 |
+ |
|
308 |
+ $query = ' |
|
309 |
+ SELECT |
|
310 |
+ id, project_id, version, released AS isreleased |
|
311 |
+ FROM ' . $this->mbt_db_prefix . 'project_version_table |
|
312 |
+ LIMIT ' . $substep . ' 500'; |
|
313 |
+ |
|
314 |
+ foreach ($this->db->query($sql) as $row) |
|
315 |
+ { |
|
316 |
+ if (isset($builds[$version])) |
|
317 |
+ continue; |
|
318 |
+ |
|
319 |
+ $this->db->query(' |
|
320 |
+ INSERT INTO (' . $this->tbg_db_prefix . 'builds (name) VALUES (' . $row['version'] . ')'); |
|
321 |
+ |
|
322 |
+ $builds[$row['version']] = $this->db->lastInsertId(); |
|
323 |
+ |
|
324 |
+ } |
|
325 |
+ |
|
326 |
+ $this->updateSubStep($substep + 500); |
|
327 |
+ $this->checkTimeout(__FUNCTION__); |
|
299 | 328 |
} |
300 | 329 |
|
301 | 330 |
|
... | ... |
@@ -307,6 +336,15 @@ class mbt_to_tbg |
307 | 336 |
{ |
308 | 337 |
$substep = $this->getSubStep(__FUNCTION__); |
309 | 338 |
|
339 |
+ // Obtain any current builds. |
|
340 |
+ $query = ' |
|
341 |
+ SELECT |
|
342 |
+ id, name |
|
343 |
+ FROM ' . $this->mbt_db_prefix . 'builds'; |
|
344 |
+ $builds = array(); |
|
345 |
+ foreach ($this->db->query($sql) as $row) |
|
346 |
+ $builds[$row['name']] = $row['id']; |
|
347 |
+ |
|
310 | 348 |
$query = ' |
311 | 349 |
SELECT |
312 | 350 |
bt.id, bt.project_id, bt.summary AS title, bt.handler_id AS assigned_to, bt.duplicate_id AS duplicate_of, |
... | ... |
@@ -331,12 +369,18 @@ class mbt_to_tbg |
331 | 369 |
INSERT INTO ' . $this->tbg_db_prefix . 'issues (id, project_id, title, assigned_to, duplicate_of, posted, last_updated, state, category, resolution, priority, severity, reproducability) |
332 | 370 |
VALUES (' . $row['id'] . ', ' . $row['project_id'] . ', "' . $row['title'] . '", ' . $row['assigned_to'] . ', ' . $row['duplicate_of'] . ', ' . $row['posted'] . ', ' . $row['last_updated'] . ', ' . $row['state'] . ', ' . $row['category'] . ', ' . $row['category'] . ', ' . $row['resolution'] . ', ' . $row['priority'] . ', ' . $row['severity'] . ', ' . $row['reproducability'] . ')'); |
333 | 371 |
|
334 |
- // @ TODO: Make this detect duplicates. |
|
372 |
+ if (!isset(builds[$row['version']])) |
|
373 |
+ { |
|
335 | 374 |
$this->db->query(' |
336 | 375 |
INSERT INTO (' . $this->tbg_db_prefix . 'builds (name) VALUES (' . $row['version'] . ')'); |
337 | 376 |
|
377 |
+ $builds[$row['version']] = $this->db->lastInsertId(); |
|
378 |
+ } |
|
379 |
+ |
|
380 |
+ $affect_id = $builds[$row['version']]; |
|
381 |
+ |
|
338 | 382 |
$this->db->query(' |
339 |
- INSERT INTO (' . $this->tbg_db_prefix . 'issueaffectsbuild (id, build) VALUES(' . $row['id'] . ', ' . $this->db->lastInsertId() . ')'); |
|
383 |
+ INSERT INTO (' . $this->tbg_db_prefix . 'issueaffectsbuild (id, build) VALUES(' . $row['id'] . ', ' . $affect_id . ')'); |
|
340 | 384 |
} |
341 | 385 |
|
342 | 386 |
$this->updateSubStep($substep + 500); |
... | ... |
@@ -349,6 +393,23 @@ class mbt_to_tbg |
349 | 393 |
*/ |
350 | 394 |
function doStep6() |
351 | 395 |
{ |
396 |
+ $substep = $this->getSubStep(__FUNCTION__); |
|
397 |
+ |
|
398 |
+ $query = ' |
|
399 |
+ SELECT |
|
400 |
+ bn.id, bn.bug_id AS target_id, bn.last_modified AS updated, bn.date_submitted AS posted, |
|
401 |
+ bn.reporter_id AS updated_by, bn.reporter_id AS posted_by, bnt.note AS content |
|
402 |
+ FROM ' . $this->mbt_db_prefix . 'bugnote_table AS bn |
|
403 |
+ INNER JOIN ' . $this->mbt_db_prefix . 'butnote_text_table AS bnt ON (bn.id = bnt.bug_text_id) |
|
404 |
+ LIMIT ' . $substep . ' 500'; |
|
405 |
+ |
|
406 |
+ foreach ($this->db->query($sql) as $row) |
|
407 |
+ $this->db->query(' |
|
408 |
+ INSERT INTO ' . $this->tbg_db_prefix . 'comments (id, target_id, updated, posted, updated_by, posted_by, content) |
|
409 |
+ VALUES (' . $row['id'] . ', ' . $row['target_id'] . ', ' . $row['updated'] . ', ' . $row['posted'] . ', ' . $row['updated_by'] . ', ' . $row['posted_by'] . ', "' . $row['content'] . '")'); |
|
410 |
+ |
|
411 |
+ $this->updateSubStep($substep + 500); |
|
412 |
+ $this->checkTimeout(__FUNCTION__); |
|
352 | 413 |
} |
353 | 414 |
} |
354 | 415 |
|
355 | 416 |