|
631 | 631 | </rollback>
|
632 | 632 | </changeSet>
|
633 | 633 |
|
| 634 | + <changeSet id="create UPDATE_TEST_RUN_STATS" author="v.kostyukevich"> |
| 635 | + <sql endDelimiter="#"> |
| 636 | + |
| 637 | + DROP PROCEDURE IF EXISTS `UPDATE_TEST_RUN_STATS`; |
| 638 | + |
| 639 | + # |
| 640 | + CREATE PROCEDURE `UPDATE_TEST_RUN_STATS`( |
| 641 | + In request_testrun_id varchar(11) |
| 642 | + ) |
| 643 | + BEGIN |
| 644 | + DELETE FROM testrun_statistic WHERE testrun_id = request_testrun_id; |
| 645 | + |
| 646 | + INSERT INTO testrun_statistic (testrun_id, failed, passed, not_executed, in_progress, pending, total, app_issue, warning, not_assigned, other) |
| 647 | + |
| 648 | + SELECT |
| 649 | + trn.id, |
| 650 | + sum(frs.color = 1) as failed, |
| 651 | + sum(frs.color = 5) as passed, |
| 652 | + sum(frs.color = 3) as not_executed, |
| 653 | + sum(frs.color = 2) as in_progress, |
| 654 | + sum(frs.color = 4) as pending, |
| 655 | + sum(frs.color != 0) as total, |
| 656 | + sum(rr.color = 1 AND frs.color != 5) as app_issue, |
| 657 | + sum(rr.color = 2 AND frs.color != 5) as warning, |
| 658 | + sum((rr.color = 3 or rr.color is null) AND frs.color != 5) as not_assigned, |
| 659 | + sum((rr.color = 4 OR rr.color = 5) AND frs.color != 5) as other |
| 660 | + |
| 661 | + from test_runs as trn |
| 662 | + right join test_results as trs on trn.id=test_run_id |
| 663 | + left join final_results as frs on trs.final_result_id = frs.id |
| 664 | + left join issues on trs.issue_id=issues.id |
| 665 | + left join result_resolution as rr on issues.resolution_id = rr.id |
| 666 | + |
| 667 | + Where trn.id = request_testrun_id; |
| 668 | + END |
| 669 | + |
| 670 | + </sql> |
| 671 | + <rollback> |
| 672 | + </rollback> |
| 673 | + </changeSet> |
| 674 | + |
| 675 | + <changeSet id="update test_results_AFTER_INSERT with UPDATE_TEST_RUN_STATS" author="v.kostyukevich"> |
| 676 | + <sql endDelimiter="#"> |
| 677 | + |
| 678 | + DROP TRIGGER IF EXISTS `test_results_AFTER_INSERT`; |
| 679 | + |
| 680 | + # |
| 681 | + CREATE TRIGGER test_results_AFTER_INSERT AFTER INSERT ON test_results FOR EACH ROW |
| 682 | + BEGIN |
| 683 | + |
| 684 | + IF NOT EXISTS (SELECT * FROM imports WHERE testrun_id= NEW.test_run_id AND finish_status = 0) |
| 685 | + THEN |
| 686 | + |
| 687 | + CALL UPDATE_TEST_RUN_STATS(NEW.test_run_id); |
| 688 | + |
| 689 | + END IF; |
| 690 | + |
| 691 | + CALL UPDATE_LAST_RESULT_COLORS_FOR_TEST ( |
| 692 | + NEW.test_id, |
| 693 | + (SELECT stability_count from projects where id = NEW.project_id)); |
| 694 | + END |
| 695 | + |
| 696 | + </sql> |
| 697 | + <rollback> |
| 698 | + </rollback> |
| 699 | + </changeSet> |
| 700 | + |
| 701 | + <changeSet id="update test_results_AFTER_INSERT with UPDATE_TEST_RUN_STATS" author="v.kostyukevich"> |
| 702 | + <sql endDelimiter="#"> |
| 703 | + |
| 704 | + DROP TRIGGER IF EXISTS `test_results_AFTER_INSERT`; |
| 705 | + |
| 706 | + # |
| 707 | + CREATE TRIGGER test_results_AFTER_INSERT AFTER INSERT ON test_results FOR EACH ROW |
| 708 | + BEGIN |
| 709 | + |
| 710 | + IF NOT EXISTS (SELECT * FROM imports WHERE testrun_id= NEW.test_run_id AND finish_status = 0) |
| 711 | + THEN |
| 712 | + |
| 713 | + CALL UPDATE_TEST_RUN_STATS(NEW.test_run_id); |
| 714 | + |
| 715 | + END IF; |
| 716 | + |
| 717 | + CALL UPDATE_LAST_RESULT_COLORS_FOR_TEST ( |
| 718 | + NEW.test_id, |
| 719 | + (SELECT stability_count from projects where id = NEW.project_id)); |
| 720 | + END |
| 721 | + |
| 722 | + </sql> |
| 723 | + <rollback> |
| 724 | + </rollback> |
| 725 | + </changeSet> |
| 726 | + |
| 727 | + <changeSet id="update test_results_AFTER_UPDATE with UPDATE_TEST_RUN_STATS" author="v.kostyukevich"> |
| 728 | + <sql endDelimiter="#"> |
| 729 | + |
| 730 | + DROP TRIGGER IF EXISTS `test_results_AFTER_UPDATE`; |
| 731 | + |
| 732 | + # |
| 733 | + CREATE TRIGGER test_results_AFTER_UPDATE AFTER UPDATE ON test_results FOR EACH ROW |
| 734 | + BEGIN |
| 735 | + IF NOT EXISTS (SELECT * FROM imports WHERE testrun_id= NEW.test_run_id AND finish_status = 0) |
| 736 | + THEN |
| 737 | + |
| 738 | + CALL UPDATE_TEST_RUN_STATS(NEW.test_run_id); |
634 | 739 |
|
| 740 | + END IF; |
| 741 | + |
| 742 | + CALL UPDATE_LAST_RESULT_COLORS_FOR_TEST ( |
| 743 | + NEW.test_id, |
| 744 | + (SELECT stability_count from projects where id = NEW.project_id) |
| 745 | + ); |
| 746 | + END |
| 747 | + |
| 748 | + </sql> |
| 749 | + <rollback> |
| 750 | + </rollback> |
| 751 | + </changeSet> |
| 752 | + |
| 753 | + <changeSet id="update test_results_BEFORE_DELETE with UPDATE_TEST_RUN_STATS" author="v.kostyukevich"> |
| 754 | + <sql endDelimiter="#"> |
| 755 | + |
| 756 | + DROP TRIGGER IF EXISTS `test_results_BEFORE_DELETE`; |
| 757 | + |
| 758 | + # |
| 759 | + CREATE TRIGGER `test_results_BEFORE_DELETE` BEFORE DELETE ON `test_results` FOR EACH ROW |
| 760 | + BEGIN |
| 761 | + IF NOT EXISTS (SELECT * FROM imports WHERE testrun_id= OLD.test_run_id AND finish_status = 0) |
| 762 | + THEN |
| 763 | + |
| 764 | + CALL UPDATE_TEST_RUN_STATS(OLD.test_run_id); |
| 765 | + |
| 766 | + END IF; |
| 767 | + |
| 768 | + CALL UPDATE_LAST_RESULT_COLORS_FOR_TEST ( |
| 769 | + OLD.test_id, |
| 770 | + (SELECT stability_count from projects where id = OLD.project_id) |
| 771 | + ); |
| 772 | + END |
| 773 | + |
| 774 | + </sql> |
| 775 | + <rollback> |
| 776 | + </rollback> |
| 777 | + </changeSet> |
| 778 | + |
| 779 | + <changeSet id="update test_results_AFTER_DELETE with UPDATE_TEST_RUN_STATS" author="v.kostyukevich"> |
| 780 | + <sql endDelimiter="#"> |
| 781 | + |
| 782 | + DROP TRIGGER IF EXISTS `test_results_AFTER_DELETE`; |
| 783 | + |
| 784 | + # |
| 785 | + CREATE TRIGGER test_results_AFTER_DELETE AFTER DELETE ON test_results FOR EACH ROW |
| 786 | + BEGIN |
| 787 | + IF NOT EXISTS (SELECT * FROM imports WHERE testrun_id= OLD.test_run_id AND finish_status = 0) |
| 788 | + THEN |
| 789 | + |
| 790 | + CALL UPDATE_TEST_RUN_STATS(OLD.test_run_id); |
| 791 | + |
| 792 | + END IF; |
| 793 | + |
| 794 | + CALL UPDATE_LAST_RESULT_COLORS_FOR_TEST (OLD.test_id, (SELECT stability_count from projects where id = OLD.project_id)); |
| 795 | + END |
| 796 | + |
| 797 | + </sql> |
| 798 | + <rollback> |
| 799 | + </rollback> |
| 800 | + </changeSet> |
| 801 | + |
| 802 | + <changeSet id="update UPDATE_LAST_RESULT_COLORS_FOR_TEST with Issues" author="v.kostyukevich"> |
| 803 | + <sql endDelimiter="#"> |
| 804 | + |
| 805 | + DROP PROCEDURE IF EXISTS `UPDATE_LAST_RESULT_COLORS_FOR_TEST`; |
| 806 | + |
| 807 | + # |
| 808 | + CREATE PROCEDURE `UPDATE_LAST_RESULT_COLORS_FOR_TEST`( |
| 809 | + IN request_test_id INT(10), |
| 810 | + IN request_limit INT(10) |
| 811 | + ) |
| 812 | + BEGIN |
| 813 | + DELETE FROM last_test_results WHERE test_id = request_test_id; |
| 814 | + |
| 815 | + INSERT INTO last_test_results (test_id, resolution_colors, result_colors, result_ids) |
| 816 | + |
| 817 | + select |
| 818 | + request_test_id, |
| 819 | + GROUP_CONCAT(resolutions SEPARATOR ',') as resolution_colors, |
| 820 | + GROUP_CONCAT(results SEPARATOR ',') as result_colors, |
| 821 | + GROUP_CONCAT(result_id SEPARATOR ',') as result_ids |
| 822 | + FROM ( |
| 823 | + select request_test_id, result_resolution.color as resolutions, final_results.color as results, test_results.id as result_id |
| 824 | + from test_results |
| 825 | + left join issues on issue_id=issues.id |
| 826 | + left join result_resolution on issues.resolution_id = result_resolution.id |
| 827 | + left join final_results on final_result_id = final_results.id |
| 828 | + |
| 829 | + where test_id = request_test_id AND test_results.debug = 0 |
| 830 | + order by finish_date DESC |
| 831 | + limit request_limit) as results; |
| 832 | + END |
| 833 | + |
| 834 | + </sql> |
| 835 | + <rollback> |
| 836 | + </rollback> |
| 837 | + </changeSet> |
635 | 838 |
|
636 | 839 | </databaseChangeLog>
|
0 commit comments