def add(self, one): white_list = bdb.get(self.dbkey, []) if one not in white_list: white_list.append(one) bdb.set(self.dbkey, white_list) return bdb.get(self.dbkey, []) return white_list
def remove(self, one): white_list = bdb.get(self.dbkey, []) if one in white_list: white_list.remove(one) bdb.set(self.dbkey, white_list) return bdb.get(self.dbkey, []) return white_list
def __init__(self, id, target_type, target_id, from_sha, to_sha, old_path, new_path, from_oid, to_oid, old_linenum, new_linenum, position, author, created_at, updated_at): self.id = id self.target_type = target_type self.target_id = target_id self.from_sha = from_sha self.to_sha = to_sha # diff: to_sha(from_ref) -> from_sha(to_ref) self.old_path = old_path.strip() self.new_path = new_path.strip() self.from_oid = from_oid self.to_oid = to_oid self.old_linenum = old_linenum self.new_linenum = new_linenum self.position = position # 新数据会为None self.author = author self.content = bdb.get(BDB_LINECOMMENT_CONTENT_KEY % id) self.created_at = created_at self.updated_at = updated_at # 做兼容... comment(commit comment)跟linecomment在dispatch里是一起处理的,兼容属性名... self.path = old_path self.ref = from_sha self.comment_id = id self.created = created_at
def __init__(self, id, title, creator, assignee=None, closer=None, created_at=None, updated_at=None, closed_at=None, type='default', target_id=0): self.id = id self.issue_id = id self.title = title bdb_description = bdb.get(BDB_ISSUE_DESCRIPTION_KEY % id) self.description = bdb_description self.creator_id = creator self.assignee_id = assignee self.closer_id = closer self.created_at = created_at self.updated_at = updated_at self.closed_at = closed_at self.type = type self.number = 0 self.target_id = target_id
def get_by_date(cls, username, given_date, limit=500, start=0): cached_result = bdb.get(cls.KEY_USER_DATE_CONTRIB % (given_date.strftime("%Y-%m-%d"), username)) if cached_result: return cached_result return {"owned_tickets": [], "commented_tickets": []}
def __init__(self, id, ticket_id, content, path, position, line_mark, from_ref, author, time, new_path=None): self.id = id self.ticket_id = ticket_id bdb_content = bdb.get(BDB_TICKET_LINECOMMENT_CONTENT_KEY % id) self.content = bdb_content or content self.path = path self.position = position self._line_mark = line_mark self.old = LINECOMMENT_INDEX_EMPTY self.new = LINECOMMENT_INDEX_EMPTY if len(line_mark.split('|')) > 1: old, new = line_mark.split('|') self.old = int(old) self.new = int(new) self.from_ref = from_ref self.author = author self.time = time self.new_path = new_path
def as_dict(self): d = {} d['number'] = self.number d['content'] = bdb.get(BDB_ISSUE_COMMENT_CONTENT_KEY % self.id) d['author'] = self.author_id d['created_at'] = self.created_at.strftime('%Y-%m-%dT%H:%M:%S') if self.updated_at: d['updated_at'] = self.updated_at.strftime('%Y-%m-%dT%H:%M:%S') return d
def get_by_date(cls, username, given_date, limit=500, start=0): cached_result = bdb.get(cls.KEY_USER_DATE_CONTRIB % ( given_date.strftime("%Y-%m-%d"), username)) if cached_result: return cached_result return {"owned_tickets": [], "commented_tickets": []}
def __init__(self, id, issue_id, author, number, created_at=None, updated_at=None): self.id = id self.issue_id = issue_id bdb_content = bdb.get(BDB_ISSUE_COMMENT_CONTENT_KEY % id) self.content = bdb_content self.author_id = author self.number = number self.created_at = created_at self.updated_at = updated_at
def __init__(self, id, ticket_number, project_id, title, description, author, time, closed): self.id = id self.ticket_number = ticket_number # start from #1 in each project self.project_id = project_id self.title = title bdb_description = bdb.get(BDB_TICKET_DESCRIPTION_KEY % id) self.description = bdb_description or description self.author = author self.time = time self.closed = closed
def __init__(self, comment_id, project_id, ref, path, position, author, created, content): self.comment_id = comment_id self.project_id = project_id self.ref = ref self.path = path self.position = position # TODO: 跟 pull linecomment 统一 self.old = LINECOMMENT_INDEX_EMPTY self.new = LINECOMMENT_INDEX_EMPTY self.author = author bdb_content = bdb.get(BDB_COMMIT_LINECOMMENT_CONTENT_KEY % comment_id) self.content = bdb_content or content self.created = created
def main(): ds = [] rs = store.execute("select id, project_id, issue_id " "from project_issues") for r in rs: id = r[0] project_id = r[1] issue_id = r[2] description = bdb.get(BDB_ISSUE_DESCRIPTION_KEY % id) bdb.delete(BDB_ISSUE_DESCRIPTION_KEY % id) ds.append([issue_id, description]) for d in ds: issue_id = d[0] description = d[1] bdb.set(BDB_ISSUE_DESCRIPTION_KEY % issue_id, description)
def content(self): return bdb.get(BDB_TICKET_COMMENT_CONTENT_KEY % self.id)
def get(self): return bdb.get(self.dbkey, [])
def set(self, white_list): bdb.set(self.dbkey, white_list) return bdb.get(self.dbkey, [])