You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

event_classifier.py 1.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # 遍历issue列表时调用,以判断该条issue是否满足三个条件
  2. def is_promoted(owner_id, issue_operate_logs, issue_comments):
  3. # 这里某些项以后可以设置成integer,用以表示单条issue里正面行为的次数(比如打了多个标签)
  4. total_flag = False
  5. label_flag = False
  6. assign_flag = False
  7. other_flag = False
  8. # 先看日志里是否有推进issue解决的正面行为
  9. for action in issue_operate_logs:
  10. action_owner_id = action['user']['id']
  11. action_icon = action['icon']
  12. # 有没有打标签
  13. if action_owner_id == owner_id and action_icon == 'tag icon':
  14. label_flag = True
  15. # 有没有指派负责人/协作人
  16. if action_owner_id == owner_id and action_icon == 'add user icon':
  17. assign_flag = True
  18. # 有没有其他推进issue解决的行为(如设置schedule/milestone)
  19. if action_owner_id == owner_id and (action_icon != 'add user icon' and action_icon != 'tag icon'):
  20. other_flag = True
  21. # 再看评论区里是否有推进issue解决的正面行为
  22. def is_label_comment(issue_comment):
  23. # 先简单判断一下前两个字符是不是均为/
  24. if issue_comment['body'][0] == '/' and issue_comment['body'][1] == '/':
  25. return True
  26. else:
  27. return False
  28. for comment in issue_comments:
  29. comment_owner_id = comment['user']['id']
  30. # 有没有通过评论打标签
  31. if comment_owner_id == owner_id and is_label_comment(comment):
  32. label_flag = True
  33. # 有没有在自己的issue下做回复(不包括与bot互动)
  34. if comment_owner_id == owner_id and comment['body'][0] != '/':
  35. other_flag = True
  36. total_flag = label_flag or assign_flag or other_flag
  37. return total_flag, label_flag, assign_flag, other_flag