예제 #1
0
 def __init__(self,
              handler=None,
              formdata=None,
              obj=None,
              prefix='',
              data=None,
              meta=None,
              **kwargs):
     if formdata and handler:
         # 获取指派用户
         assigned_ids = [
             int(sid) for sid in formdata['assigneds'][0].split(',')
         ] if formdata['assigneds'][0] else []
         assigned_ids = set(assigned_ids)
         assigneds = [
             ud for ud in handler.p_users if ud['id'] in assigned_ids
         ]
         formdata['assigneds'] = [
             json.dumps(assigneds),
         ]
         # 填充剩余表单数据
         formdata['creator_id'] = [
             str(handler.user.id),
         ]
         formdata['creator_name'] = [
             handler.user.name,
         ]
         formdata['project_id'] = [
             handler.pid,
         ]
         formdata['created'] = [
             date_to_str(datetime.now()),
         ]
     super(TaskForm, self).__init__(formdata, obj, prefix, **kwargs)
예제 #2
0
파일: model.py 프로젝트: Geew/issue-task
 def get_diff(self, data):
     """ 设置更新日志
     """
     diffs = []
     for field, name in self._checks.items():
         old = getattr(self, field)
         new = data.get(field)
         if field == 'status':
             old = self._status.get(int(old))
             new = self._status.get(int(new))
         elif field == 'priority':
             old = self._priority.get(int(old))
             new = self._priority.get(int(new))
         elif field == 'type':
             old = self._type.get(int(old))
             new = self._type.get(int(new))
         elif field == 'assigneds':  # 指派用户对比, 取名字即可
             old = self.assigned_names
             new = set([ud['name'] for ud in json.loads(new)])
             old = ','.join(sorted(old))
             new = ','.join(sorted(new))
         elif field == 'expires':
             old = date_to_str(old) if old else None
             new = date_to_str(new) if new else None
             if new:
                 new = new[: 10]
             if old:
                 old = old[: 10]
         new = new or ''
         old = old or ''
         old = old.strip()
         new = new.strip()
         if old != new:
             if not old:
                 t = 'set'
             elif not new:
                 t = 'del'
             else:
                 t = 'update'
             if field == 'desc':  # 描述只记录前20个字符
                 old = old[: 20]
                 new = new[: 20]
             diffs.append((name, old, new, t))
     return json.dumps(diffs)
예제 #3
0
 def get_diff(self, data):
     """ 设置更新日志
     """
     diffs = []
     for field, name in self._checks.items():
         old = getattr(self, field)
         new = data.get(field)
         if field == 'status':
             old = self._status.get(int(old))
             new = self._status.get(int(new))
         elif field == 'priority':
             old = self._priority.get(int(old))
             new = self._priority.get(int(new))
         elif field == 'type':
             old = self._type.get(int(old))
             new = self._type.get(int(new))
         elif field == 'assigneds':  # 指派用户对比, 取名字即可
             old = self.assigned_names
             new = set([ud['name'] for ud in json.loads(new)])
             old = ','.join(sorted(old))
             new = ','.join(sorted(new))
         elif field == 'expires':
             old = date_to_str(old) if old else None
             new = date_to_str(new) if new else None
             if new:
                 new = new[:10]
             if old:
                 old = old[:10]
         new = new or ''
         old = old or ''
         old = old.strip()
         new = new.strip()
         if old != new:
             if not old:
                 t = 'set'
             elif not new:
                 t = 'del'
             else:
                 t = 'update'
             if field == 'desc':  # 描述只记录前20个字符
                 old = old[:20]
                 new = new[:20]
             diffs.append((name, old, new, t))
     return json.dumps(diffs)
예제 #4
0
파일: model.py 프로젝트: Geew/issue-task
 def __init__(self, handler=None, formdata=None, obj=None, prefix='', data=None, meta=None, **kwargs):
     if formdata and handler:
         # 获取指派用户
         assigned_ids = [int(sid) for sid in formdata['assigneds'][0].split(',')] if formdata['assigneds'][0] else []
         assigned_ids = set(assigned_ids)
         assigneds = [ud for ud in handler.p_users if ud['id'] in assigned_ids]
         formdata['assigneds'] = [json.dumps(assigneds), ]
         # 填充剩余表单数据
         formdata['creator_id'] = [str(handler.user.id), ]
         formdata['creator_name'] = [handler.user.name, ]
         formdata['project_id'] = [handler.pid, ]
         formdata['created'] = [date_to_str(datetime.now()), ]
     super(TaskForm, self).__init__(formdata, obj, prefix, **kwargs)
예제 #5
0
            top_committers[author] -= 1
            if top_committers[author] <= 0:
                del top_committers[author]

        date = data_manager.get_last_included_date()
        date_to_top_committers[date] = sort_dict(
            top_committers, by_value=True, reverse=True
        )

        try:
            change_sets_add, change_sets_remove = data_manager.forward_one_day()
        except SlidingNotPossible:
            break

    return date_to_top_committers


if __name__ == "__main__":
    # Lets extract top committers:
    k = 10
    for project_name in ["pig", "hive", "hadoop", "hbase", "derby", "zookeeper"]:
        sws = 365
        text = ""
        date_to_top_committers = generate_date_to_top_committers(project_name, sws)
        for date, dev_to_commit_count in date_to_top_committers.items():
            topk_committers = highest_k(dev_to_commit_count, k)
            text += date_to_str(date) + "," + ",".join(topk_committers) + "\n"

        with open("data/{}_top_committers.csv".format(project_name), "w") as f:
            f.write(text)
예제 #6
0
        date_to_top_commenters[date] = sort_dict(top_commenters,
                                                 by_value=True,
                                                 reverse=True)

        try:
            change_sets_add, change_sets_remove = data_manager.forward_one_day(
            )
        except SlidingNotPossible:
            break

    return date_to_top_commenters


if __name__ == "__main__":
    # Lets extract top10 commenters into csv files to check manually.
    for project_name in project_list:
        for sws in sws_list:
            date_to_top_commenters = generate_date_to_top_commenters(
                project_name, sws)

            text = ""
            for date, counter in date_to_top_commenters.items():
                top10_commenters = highest_k(counter, 10)
                text += date_to_str(date) + "," + ",".join(
                    top10_commenters) + "\n"

            with open("data/{}_top_commenters.csv".format(project_name),
                      "w",
                      encoding="utf8") as f:
                f.write(text)
                    if top_commenters[commenter] <= 0:
                        del top_commenters[commenter]

        date = data_manager.get_last_included_date()
        date_to_top_commenters[date] = sort_dict(
            top_commenters, by_value=True, reverse=True
        )

        try:
            change_sets_add, change_sets_remove = data_manager.forward_one_day()
        except SlidingNotPossible:
            break

    return date_to_top_commenters


if __name__ == "__main__":
    # Lets extract top10 commenters into csv files to check with eyes
    for project_name in ["pig", "hive", "hadoop"]:
        date_to_top_commenters = generate_date_to_top_commenters(project_name)

        text = ""
        for date, counter in date_to_top_commenters.items():
            top10_commenters = highest_k(counter, 10)
            text += date_to_str(date) + "," + ",".join(top10_commenters) + "\n"

        with open(
            "data/{}_top_commenters.csv".format(project_name), "w", encoding="utf8"
        ) as f:
            f.write(text)
예제 #8
0
 def to_json(self) -> typing.Dict:
     return {'base_chore_key': self.base_chore.key,
             'happened_on': util.date_to_str(self.happened_on),
             'was_deep_clean': self.was_deep_clean,
             'cleaner_name': self.cleaner.name}