@@ -614,75 +614,50 @@ def __get_rich_repo(self, item):
614
614
rich_repo .update (self .get_grimoire_fields (item ['metadata__updated_on' ], "repository" ))
615
615
616
616
return rich_repo
617
-
617
+
618
618
def get_event_type (self , action_type , content ):
619
- if action_type == "label" and "add" in content :
620
- return "LabeledEvent"
621
- elif action_type == "label" and "delete" in content :
622
- return "UnlabeledEvent"
623
- elif action_type == "closed" :
624
- return "ClosedEvent"
625
- elif action_type == "opened" :
626
- return "ReopenedEvent"
627
- elif action_type == "assignee" and "assigned" in content :
628
- return "AssignedEvent"
629
- elif action_type == "assignee" and "unassigned" in content :
630
- return "UnassignedEvent"
631
-
632
-
633
-
634
- switch_event_type = {
635
- "add_label" : "LabeledEvent" ,
636
- "remove_label" : "UnlabeledEvent" ,
637
- "closed_pr" : "ClosedEvent" ,
638
- "reopened_pr" : "ReopenedEvent" ,
639
- "set_assignee" : "AssignedEvent" ,
640
- "setting_assignee" : "AssignedEvent" ,
641
- "unset_assignee" : "UnassignedEvent" ,
642
- "change_assignee" : "UnassignedEvent" ,
643
- "set_milestone" : "MilestonedEvent" ,
644
- "setting_milestone" : "MilestonedEvent" ,
645
- "unset_milestone" : "DemilestonedEvent" ,
646
- "change_milestone" : "DemilestonedEvent" ,
647
- "update_title" : "RenamedTitleEvent" ,
648
- "change_title" : "RenamedTitleEvent" ,
649
- "merged_pr" : "MergedEvent" ,
650
- "update_description" : "ChangeDescriptionEvent" ,
651
- "change_description" : "ChangeDescriptionEvent" ,
652
- "setting_priority" : "SettingPriorityEvent" ,
653
- "change_priority" : "ChangePriorityEvent"
654
- }
655
- if action_type in switch_event_type :
656
- return switch_event_type [action_type ]
657
- else :
658
- return '' .join (word .capitalize () for word in action_type .split ('_' )) + "Event"
619
+ rules = [
620
+ (lambda : action_type == "label" and "add" in content , "LabeledEvent" ),
621
+ (lambda : action_type == "label" and "delete" in content , "UnlabeledEvent" ),
622
+ (lambda : action_type == "closed" , "ClosedEvent" ),
623
+ (lambda : action_type == "opened" , "ReopenedEvent" ),
624
+ (lambda : action_type == "milestone" and "changed" in content , "MilestonedEvent" ),
625
+ (lambda : action_type == "milestone" and "removed" in content , "DemilestonedEvent" ),
626
+ (lambda : action_type == "locked" , "LockedEvent" ),
627
+ (lambda : action_type == "unlocked" , "UnlockedEvent" ),
628
+ (lambda : action_type == "title" , "RenamedTitleEvent" ),
629
+ (lambda : action_type == "merged" , "MergedEvent" ),
630
+ (lambda : action_type == "description" , "ChangeDescriptionEvent" ),
631
+ (lambda : action_type == "add_mr_issue_link" , "LinkIssueEvent" ),
632
+ (lambda : action_type == "delete_mr_issue_link" , "UnlinkIssueEvent" ),
633
+ (lambda : action_type == "add_issue_mr_link" , "LinkPullRequestEvent" ),
634
+ (lambda : action_type == "delete_issue_mr_link" , "UnlinkPullRequestEvent" ),
635
+ (lambda : action_type == "add_issue_branch_link" , "SettingBranchEvent" ),
636
+ (lambda : action_type == "delete_issue_branch_link" , "ChangeBranchEvent" ),
637
+ (lambda : action_type == "discussion" , "DiscussionEvent" ),
638
+ (lambda : action_type == "confidential" , "ConfidentialEvent" ),
639
+ (lambda : (action_type == "assignee" and "assigned" in content ) or (action_type == "mr_change" and ("Add assignees" in content or "Add approvers" in content )),"AssignedEvent" ),
640
+ (lambda : (action_type == "assignee" and "unassigned" in content ) or (action_type == "mr_change" and ("Delete assignees" in content or "Delete approvers" in content )),"UnassignedEvent" ),
641
+ (lambda : action_type == "mr_change" and "Add testers" in content , "SetTesterEvent" ),
642
+ (lambda : action_type == "mr_change" and "deleted testers" in content , "UnsetTesterEvent" ),
643
+ (lambda : action_type == "mr_change" and "Add reviewers" in content ,"SetReviewerEvent" ),
644
+ (lambda : action_type == "mr_change" and "Delete reviewers" in content ,"UnsetReviewerEvent" ),
645
+ (lambda : action_type == "mr_change" and "Approval Gate : pass" in content , "CheckPassEvent" ),
646
+ (lambda : action_type == "mr_change" and "Test Gate : pass" in content , "TestPassEvent" ),
647
+ (lambda : action_type == "mr_change" and "Review Gate : pass" in content , "ReviewPassEvent" ),
648
+ (lambda : action_type == "mr_change" and "Approval Gate : reset" in content , "ResetAssignResultEvent" ),
649
+ (lambda : action_type == "mr_change" and "Test Gate : reset" in content , "ResetTestResultEvent" ),
650
+ (lambda : action_type == "mr_change" and "Review Gate : reset" in content , "ResetReviewResultEvent" ),
651
+ (lambda : action_type == "mr_change" and "Approval Gate : reject" in content , "CheckRejectEvent" ),
652
+ (lambda : action_type == "mr_change" and "Test Gate : reject" in content , "TestRejectEvent" ),
653
+ (lambda : action_type == "mr_change" and "Review Gate : reject" in content , "ReviewRejectEvent" ),
654
+ ]
655
+
656
+ for condition , event_type in rules :
657
+ if condition ():
658
+ return event_type
659
+ return None
659
660
660
- def get_event_type (self , action_type , content ):
661
- switch_event_type = {
662
- "add_label" : "LabeledEvent" ,
663
- "remove_label" : "UnlabeledEvent" ,
664
- "closed_pr" : "ClosedEvent" ,
665
- "reopened_pr" : "ReopenedEvent" ,
666
- "set_assignee" : "AssignedEvent" ,
667
- "setting_assignee" : "AssignedEvent" ,
668
- "unset_assignee" : "UnassignedEvent" ,
669
- "change_assignee" : "UnassignedEvent" ,
670
- "set_milestone" : "MilestonedEvent" ,
671
- "setting_milestone" : "MilestonedEvent" ,
672
- "unset_milestone" : "DemilestonedEvent" ,
673
- "change_milestone" : "DemilestonedEvent" ,
674
- "update_title" : "RenamedTitleEvent" ,
675
- "change_title" : "RenamedTitleEvent" ,
676
- "merged_pr" : "MergedEvent" ,
677
- "update_description" : "ChangeDescriptionEvent" ,
678
- "change_description" : "ChangeDescriptionEvent" ,
679
- "setting_priority" : "SettingPriorityEvent" ,
680
- "change_priority" : "ChangePriorityEvent"
681
- }
682
- if action_type in switch_event_type :
683
- return switch_event_type [action_type ]
684
- else :
685
- return '' .join (word .capitalize () for word in action_type .split ('_' )) + "Event"
686
661
687
662
def __get_rich_event (self , item ):
688
663
rich_event = {}
@@ -710,7 +685,7 @@ def __get_rich_event(self, item):
710
685
rich_event ['content' ] = event ['content' ]
711
686
rich_event ['created_at' ] = event ['created_at' ]
712
687
rich_event ['action_type' ] = event ['action_type' ]
713
- rich_event ['event_type' ] = self .get_event_type (event ['action_type' ], ) #待定
688
+ rich_event ['event_type' ] = self .get_event_type (event ['action_type' ], event [ 'content' ])
714
689
rich_event ['repository' ] = item ["tag" ]
715
690
rich_event ['pull_request' ] = False if 'issue' in event else True
716
691
rich_event ['item_type' ] = 'issue' if 'issue' in event else 'pull request'
@@ -794,6 +769,7 @@ def __get_rich_stargazer(self, item):
794
769
rich_stargazer ['user_email' ] = user .get ('email' , None )
795
770
rich_stargazer ["user_domain" ] = self .get_email_domain (user ['email' ]) if user .get ('email' , None ) else None
796
771
rich_stargazer ['user_company' ] = user .get ('company' , None )
772
+ rich_stargazer ['user_location' ] = user .get ('location' , None )
797
773
rich_stargazer ["user_remark" ] = user .get ("remark" , None )
798
774
rich_stargazer ["user_type" ] = user ["type" ]
799
775
@@ -806,6 +782,7 @@ def __get_rich_stargazer(self, item):
806
782
rich_stargazer ['user_email' ] = None
807
783
rich_stargazer ["user_domain" ] = None
808
784
rich_stargazer ['user_company' ] = None
785
+ rich_stargazer ['user_location' ] = None
809
786
rich_stargazer ["user_remark" ] = None
810
787
rich_stargazer ["user_type" ] = None
811
788
@@ -838,6 +815,7 @@ def __get_rich_fork(self, item):
838
815
rich_fork ['user_email' ] = user .get ('email' , None )
839
816
rich_fork ["user_domain" ] = self .get_email_domain (user ['email' ]) if user .get ('email' , None ) else None
840
817
rich_fork ['user_company' ] = user .get ('company' , None )
818
+ rich_fork ['user_location' ] = user .get ('location' , None )
841
819
rich_fork ["user_remark" ] = user .get ("remark" , None )
842
820
rich_fork ["user_type" ] = user ["type" ]
843
821
@@ -850,6 +828,7 @@ def __get_rich_fork(self, item):
850
828
rich_fork ['user_email' ] = None
851
829
rich_fork ['user_domain' ] = None
852
830
rich_fork ['user_company' ] = None
831
+ rich_fork ['user_location' ] = None
853
832
rich_fork ["user_remark" ] = None
854
833
rich_fork ["user_type" ] = None
855
834
@@ -882,6 +861,7 @@ def __get_rich_watch(self, item):
882
861
rich_watch ['user_email' ] = user .get ('email' , None )
883
862
rich_watch ["user_domain" ] = self .get_email_domain (user ['email' ]) if user .get ('email' , None ) else None
884
863
rich_watch ['user_company' ] = user .get ('company' , None )
864
+ rich_watch ['user_location' ] = user .get ('location' , None )
885
865
rich_watch ["user_remark" ] = user .get ("remark" , None )
886
866
rich_watch ["user_type" ] = user ["type" ]
887
867
@@ -894,6 +874,7 @@ def __get_rich_watch(self, item):
894
874
rich_watch ['user_email' ] = None
895
875
rich_watch ['user_demain' ] = None
896
876
rich_watch ['user_company' ] = None
877
+ rich_watch ['user_location' ] = None
897
878
rich_watch ["user_remark" ] = None
898
879
rich_watch ["user_type" ] = None
899
880
0 commit comments