Jeremy D commited on 2011-11-06 14:50:11
Showing 1 changed files, with 32 additions and 12 deletions.
... | ... |
@@ -23,6 +23,14 @@ ini_set('display_errors', 1); |
23 | 23 |
* Add js to support ajax |
24 | 24 |
* Add ajax support |
25 | 25 |
* Test |
26 |
+* The version needs split into major, minor and revision.. Fun. |
|
27 |
+*/ |
|
28 |
+ |
|
29 |
+// exit(var_dump($this->tbg_db->errorInfo())); |
|
30 |
+/* |
|
31 |
+* @TODO Known Bugs |
|
32 |
+* Converting categories doesn't sort them properly for which category they existed. |
|
33 |
+* Converting versions doesn't work when repeated due to the data existing in builds already and is skipped. Step 0 anyone? |
|
26 | 34 |
*/ |
27 | 35 |
|
28 | 36 |
class tbg_converter |
... | ... |
@@ -378,6 +386,9 @@ class tbg_converter |
378 | 386 |
|
379 | 387 |
$this->step = (int) $step; |
380 | 388 |
|
389 |
+ // Reset. |
|
390 |
+ $this->updateSubStep(0); |
|
391 |
+ |
|
381 | 392 |
return true; |
382 | 393 |
} |
383 | 394 |
|
... | ... |
@@ -644,13 +655,10 @@ class mbt_to_tbg extends tbg_converter |
644 | 655 |
$i = 0; |
645 | 656 |
foreach ($this->mantis_db->query($query) as $row) |
646 | 657 |
{ |
647 |
-$temp = $this->tbg_db->quote(' |
|
658 |
+ $this->tbg_db->query(' |
|
648 | 659 |
INSERT INTO ' . $this->tbg_db_prefix . 'projects (id, name, locked, description) |
649 | 660 |
VALUES (' . $row['id'] . ', "' . $row['name'] . '", ' . $row['locked'] . ', "' . $row['description'] . '")'); |
650 | 661 |
|
651 |
-echo str_replace('\"', '"', $temp); |
|
652 |
-exit("\n"); |
|
653 |
- |
|
654 | 662 |
++$i; |
655 | 663 |
} |
656 | 664 |
|
... | ... |
@@ -659,10 +667,17 @@ exit("\n"); |
659 | 667 |
|
660 | 668 |
/** |
661 | 669 |
* Convert Categories. |
662 |
- * |
|
670 |
+ * WARNING: RUNNING THIS MULTIPLE TIMES MAY CAUSE DUPLICATE ENTRIES. |
|
663 | 671 |
*/ |
664 | 672 |
function doStep3() |
665 | 673 |
{ |
674 |
+ // This attempts to remove extras added by repeated conversions. |
|
675 |
+ $this->tbg_db->query(' |
|
676 |
+ DELETE FROM ' . $this->tbg_db_prefix . 'listtypes |
|
677 |
+ WHERE id NOT IN (1,2,3) |
|
678 |
+ AND itemtype = "category"'); |
|
679 |
+ |
|
680 |
+ |
|
666 | 681 |
$step_size = 500; |
667 | 682 |
$substep = $this->getSubStep(__FUNCTION__); |
668 | 683 |
|
... | ... |
@@ -675,9 +690,13 @@ exit("\n"); |
675 | 690 |
$i = 0; |
676 | 691 |
foreach ($this->mantis_db->query($query) as $row) |
677 | 692 |
{ |
693 |
+ // Mantis has some empty category names. |
|
694 |
+ if (empty($row['name']) || trim($row['name']) == '') |
|
695 |
+ continue; |
|
696 |
+ |
|
678 | 697 |
$this->tbg_db->query(' |
679 | 698 |
INSERT INTO ' . $this->tbg_db_prefix . 'listtypes (name, itemtype, scope) |
680 |
- VALUES (' . $row['name'] . ', "category", 1)'); |
|
699 |
+ VALUES ("' . $row['name'] . '", "category", 1)'); |
|
681 | 700 |
|
682 | 701 |
++$i; |
683 | 702 |
} |
... | ... |
@@ -705,20 +724,20 @@ exit("\n"); |
705 | 724 |
|
706 | 725 |
$query = ' |
707 | 726 |
SELECT |
708 |
- id, project_id, version, released AS isreleased |
|
727 |
+ id, project_id, version, released AS isreleased, project_id AS project |
|
709 | 728 |
FROM ' . $this->mbt_db_prefix . 'project_version_table |
710 | 729 |
LIMIT ' . $step_size . ' OFFSET ' . $substep; |
711 | 730 |
|
712 | 731 |
$i = 0; |
713 | 732 |
foreach ($this->mantis_db->query($query) as $row) |
714 | 733 |
{ |
715 |
- if (isset($builds[$version])) |
|
734 |
+ if (isset($builds[$row['version']])) |
|
716 | 735 |
continue; |
717 | 736 |
|
718 | 737 |
$this->tbg_db->query(' |
719 |
- INSERT INTO (' . $this->tbg_db_prefix . 'builds (name) VALUES (' . $row['version'] . ')'); |
|
738 |
+ INSERT INTO ' . $this->tbg_db_prefix . 'builds (name, isreleased, project) VALUES ("' . $row['version'] . '", ' . $row['isreleased'] . ', ' . $row['project'] . ')'); |
|
720 | 739 |
|
721 |
- $builds[$row['version']] = $this->db->lastInsertId(); |
|
740 |
+ $builds[$row['version']] = $this->tbg_db->lastInsertId(); |
|
722 | 741 |
|
723 | 742 |
++$i; |
724 | 743 |
} |
... | ... |
@@ -769,13 +788,14 @@ exit("\n"); |
769 | 788 |
{ |
770 | 789 |
$this->tbg_db->query(' |
771 | 790 |
INSERT INTO ' . $this->tbg_db_prefix . 'issues (id, project_id, title, assigned_to, duplicate_of, posted, last_updated, state, category, resolution, priority, severity, reproducability) |
772 |
- 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'] . ') |
|
791 |
+ VALUES (' . $row['id'] . ', ' . $row['project_id'] . ', "' . $row['title'] . '", ' . $row['assigned_to'] . ', ' . $row['duplicate_of'] . ', ' . $row['posted'] . ', ' . $row['last_updated'] . ', ' . $row['state'] . ', ' . $row['category'] . ', ' . $row['resolution'] . ', ' . $row['priority'] . ', ' . $row['severity'] . ', ' . $row['reproducability'] . ') |
|
773 | 792 |
'); |
774 | 793 |
|
794 |
+ // This attempts to find any versions that got missed, but isn't accurate. |
|
775 | 795 |
if (!isset($builds[$row['version']])) |
776 | 796 |
{ |
777 | 797 |
$this->tbg_db->query(' |
778 |
- INSERT INTO (' . $this->tbg_db_prefix . 'builds (name) VALUES (' . $row['version'] . ')'); |
|
798 |
+ INSERT INTO (' . $this->tbg_db_prefix . 'builds (name, project) VALUES (' . $row['version'] . ', ' . $row['project_id'] . ')'); |
|
779 | 799 |
|
780 | 800 |
$builds[$row['version']] = $this->tbg_db->lastInsertId(); |
781 | 801 |
} |
782 | 802 |