def query_pull_request_items(cls, model, pull_request_items_str: str):
     """
      查看打标的 pull request 信息
     :param model:
     :param pull_request_items_str:
     :return:
     """
     pull_request_items_list = pull_request_items_str.split(",")
     data = model.objects.filter(pull_request_id__in=pull_request_items_list).order_by('-pull_request_id').all()
     for model in data:
         if model.complete_time is not None:
             model.complete_time = Utils.utc_to_local(model.complete_time)  # utc 时间转为本地时间
     return Utils.model_objects_to_list(data)
 def query_pull_request_info(cls, model, page_num, select_word=None):
     """
     查询 pull request 信息
     :param model:
     :param page_num:
     :param select_word:
     :return:
     """
     start, end = Utils.page_rules(page_num)
     if select_word is not None:
         model_infos = model.objects.filter(title__contains=select_word).order_by('-pull_request_id').all()
     else:
         model_infos = model.objects.filter().order_by('-pull_request_id').all()
         for model in model_infos:
             if model.complete_time is not None:
                 model.complete_time = Utils.utc_to_local(model.complete_time)  # utc 时间转为本地时间
     total = len(model_infos)
     return total, Utils.model_objects_to_list(model_infos[start: end])
 def query_data_of_a_month_at_specific_time(cls, model, pull_request_id=None, end_time=None):
     """
     获取特定时间,一个月内的 pull request 信息
     :param model:
     :param pull_request_id:
     :param end_time:
     :return:
     """
     if end_time is None:
         end_time = model.objects.filter(pull_request_id__exact=pull_request_id).first().complete_time
         if end_time is None:  # 如果complete time为None,直接返回空数据
             return []
     month = end_time - datetime.timedelta(weeks=4)
     pull_request_models = model.objects.filter(complete_time__gte=month, complete_time__lte=end_time).order_by(
         '-complete_time')
     for model in pull_request_models:
         if model.complete_time is not None:
             model.complete_time = Utils.utc_to_local(model.complete_time)  # utc 时间转为本地时间
     return Utils.model_objects_to_list(pull_request_models)