def add(cls, title, description, creator, assignee=None, closer=None, created_at=None, updated_at=None, closed_at=None, type='default', target_id=0): time = datetime.now() issue_id = store.execute( 'insert into issues (title, creator_id, ' 'assignee_id, closer_id, created_at, updated_at, type, target_id) ' 'values (%s, %s, %s, %s, NULL, NULL, %s, %s)', (title, creator, assignee, closer, type, target_id)) store.commit() mc.delete(MC_KEY_ISSUE % issue_id) mc.delete(MC_KEY_ISSUES_IDS_BY_CREATOR_ID % creator) mc.delete(MC_KEY_ISSUES_IDS_BY_ASSIGNEE_ID % assignee) mc.delete(MC_KEY_ISSUES_DATA_BY_TARGET % (type, target_id)) bdb.set(BDB_ISSUE_DESCRIPTION_KEY % issue_id, description) issue = cls(issue_id, title, creator, assignee, closer, time, time) issue.add_participant(creator) return issue
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 update(self, title='', description=''): store.execute( "update codedouban_ticket set title=%s, description=%s " "where id=%s", (title, description, self.id)) store.commit() mc.delete(MCKEY_TICKET % self.id) bdb.set(BDB_TICKET_DESCRIPTION_KEY % self.id, description)
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 add(cls, ticket_id, content, path, position, old, new, from_ref, author, new_path=None): # FIXME: mysql里的content是废的啊,是历史原因么? line_mark = str(old) + '|' + str(new) id = store.execute("insert into codedouban_ticket_codereview " "(ticket_id, content, path, position, line_mark, " "from_ref, author, new_path) " "values (%s, %s, %s, %s, %s, %s, %s, %s)", (ticket_id, content, path, position, line_mark, from_ref, author, new_path)) if not id: store.rollback() raise Exception("Unable to add") store.commit() bdb.set(BDB_TICKET_LINECOMMENT_CONTENT_KEY % id, content) comment = cls.get(id) ticket = Ticket.get(ticket_id) # TODO: 重构feed之后取消signal发送 codereview_signal.send(comment, content=content, ticket=Ticket.get(ticket_id), author=author, comment=comment) dispatch('codereview', data={ 'comment': comment, 'ticket': ticket, 'sender': author, }) return comment
def delete(self): store.execute('delete from issues where id=%s', (self.id,)) store.commit() mc.delete(MC_KEY_ISSUE % self.id) mc.delete(MC_KEY_ISSUES_IDS_BY_CREATOR_ID % self.creator_id) mc.delete(MC_KEY_ISSUES_IDS_BY_ASSIGNEE_ID % self.assignee_id) mc.delete(MC_KEY_ISSUES_DATA_BY_TARGET % (type, self.target_id)) bdb.set(BDB_ISSUE_DESCRIPTION_KEY % self.id, '')
def update(self, title, description): store.execute("update issues " "set title=%s, updated_at=null " "where id=%s", (title, self.issue_id)) store.commit() bdb.set(BDB_ISSUE_DESCRIPTION_KEY % self.issue_id, description) self.clear_cache() mc.delete(MC_KEY_ISSUES_DATA_BY_TARGET % (self.type, self.target_id))
def delete(self): store.execute('delete from issues where id=%s', (self.id, )) store.commit() mc.delete(MC_KEY_ISSUE % self.id) mc.delete(MC_KEY_ISSUES_IDS_BY_CREATOR_ID % self.creator_id) mc.delete(MC_KEY_ISSUES_IDS_BY_ASSIGNEE_ID % self.assignee_id) mc.delete(MC_KEY_ISSUES_DATA_BY_TARGET % (type, self.target_id)) bdb.set(BDB_ISSUE_DESCRIPTION_KEY % self.id, '')
def update(self, title, description): store.execute( "update issues " "set title=%s, updated_at=null " "where id=%s", (title, self.issue_id)) store.commit() bdb.set(BDB_ISSUE_DESCRIPTION_KEY % self.issue_id, description) self.clear_cache() mc.delete(MC_KEY_ISSUES_DATA_BY_TARGET % (self.type, self.target_id))
def add(cls, issue_id, content, author_id, number=None): number = ICCounter.incr(issue_id, number) time = datetime.now() comment_id = store.execute( 'insert into issue_comments (issue_id, author_id, number, ' 'created_at, updated_at) values (%s, %s, %s, NULL, NULL)', (issue_id, author_id, number)) store.commit() bdb.set(BDB_ISSUE_COMMENT_CONTENT_KEY % comment_id, content) mc.delete(MC_KEY_ISSUE_COMMENTS_COUNT % issue_id) return cls(comment_id, issue_id, author_id, number, time, time)
def add(cls, project_id, ref, path, position, author, content): comment_id = store.execute( "insert into codedouban_linecomments " "(project_id, ref, path, position, author, content) " "values (%s, %s, %s, %s, %s, %s)", (project_id, ref, path, position, author, content)) if not comment_id: store.rollback() raise Exception("Unable to insert new comment") store.commit() bdb.set(BDB_COMMIT_LINECOMMENT_CONTENT_KEY % comment_id, content) return cls.get(comment_id)
def update_by_date(cls, username, given_date, limit=500, start=0): commented_tickets = cls.get_commented_ticket_ids_in_others_merged_PR_by_date( # noqa username, given_date, limit=limit, start=start ) result = { "owned_tickets": cls._get_author_merged_PR_ids_by_date(username, given_date, limit=limit, start=start), "commented_tickets": commented_tickets, } bdb.set(cls.KEY_USER_DATE_CONTRIB % (given_date.strftime("%Y-%m-%d"), username), result) return result
def update_by_date(cls, username, given_date, limit=500, start=0): commented_tickets = cls.get_commented_ticket_ids_in_others_merged_PR_by_date( # noqa username, given_date, limit=limit, start=start) result = { "owned_tickets": cls._get_author_merged_PR_ids_by_date( username, given_date, limit=limit, start=start), "commented_tickets": commented_tickets, } bdb.set(cls.KEY_USER_DATE_CONTRIB % ( given_date.strftime("%Y-%m-%d"), username), result) return result
def add(cls, target_id, from_sha, to_sha, old_path, new_path, from_oid, to_oid, old_linenum, new_linenum, author, content): id = store.execute( "insert into codedouban_linecomments_v2 " "(target_type, target_id, from_sha, to_sha, " "old_path, new_path, from_oid, to_oid, old_linenum, new_linenum, " "author, content, created_at, updated_at) " "values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, NULL, NULL)", # noqa (cls._target_type, target_id, from_sha, to_sha, old_path, new_path, from_oid, to_oid, old_linenum, new_linenum, author, content)) if not id: store.rollback() raise Exception("Unable to add new linecomment") store.commit() bdb.set(BDB_LINECOMMENT_CONTENT_KEY % id, content) return cls.get(id)
def add(cls, project_id, title, description, author, ticket_number=None): ticket_number = PRCounter.incr(project_id, ticket_number) id = store.execute( "insert into codedouban_ticket " "(ticket_number, project_id, title, description, author) " "values (%s, %s, %s, %s, %s)", (ticket_number, project_id, title, description, author)) if not id: store.rollback() raise Exception("Unable to add") store.commit() mc.delete(MCKEY_TICKET % id) bdb.set(BDB_TICKET_DESCRIPTION_KEY % id, description) ticket = cls.get(id) ticket.add_participant(author) return ticket
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 add_raw(cls, target_id, from_sha, to_sha, old_path, new_path, from_oid, to_oid, old_linenum, new_linenum, author, content, position, created_at, updated_at): id = store.execute( "insert into codedouban_linecomments_v2 " "(target_type, target_id, from_sha, to_sha, " "old_path, new_path, from_oid, to_oid, old_linenum, new_linenum, " "author, content, position, created_at, updated_at) " "values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", # noqa (cls._target_type, target_id, from_sha, to_sha, old_path, new_path, from_oid, to_oid, old_linenum, new_linenum, author, content, position, created_at, updated_at)) if not id: store.rollback() raise Exception("Unable to add new linecomment") store.commit() bdb.set(BDB_LINECOMMENT_CONTENT_KEY % id, content) return cls.get(id)
def after_create(self, extra_args): from models.ticket import Ticket comment = self TicketNode.add_comment(comment) content = extra_args bdb.set(BDB_TICKET_COMMENT_CONTENT_KEY % self.id, content) ticket = Ticket.get(self.ticket_id) # TODO: 将Feed全部迁移到新的系统后,取消signal发送 codereview_signal.send(comment, content=content, ticket=ticket, author=self.author, comment=comment) dispatch('codereview', data={ 'comment': comment, 'ticket': ticket, 'sender': self.author, })
def after_create(self, extra_args): from vilya.models.ticket import Ticket comment = self TicketNode.add_comment(comment) content = extra_args bdb.set(BDB_TICKET_COMMENT_CONTENT_KEY % self.id, content) ticket = Ticket.get(self.ticket_id) # TODO: 将Feed全部迁移到新的系统后,取消signal发送 codereview_signal.send(comment, content=content, ticket=ticket, author=self.author, comment=comment) dispatch('codereview', data={ 'comment': comment, 'ticket': ticket, 'sender': self.author, })
def add(cls, ticket_id, content, path, position, old, new, from_ref, author, new_path=None): # FIXME: mysql里的content是废的啊,是历史原因么? line_mark = str(old) + '|' + str(new) id = store.execute( "insert into codedouban_ticket_codereview " "(ticket_id, content, path, position, line_mark, " "from_ref, author, new_path) " "values (%s, %s, %s, %s, %s, %s, %s, %s)", (ticket_id, content, path, position, line_mark, from_ref, author, new_path)) if not id: store.rollback() raise Exception("Unable to add") store.commit() bdb.set(BDB_TICKET_LINECOMMENT_CONTENT_KEY % id, content) comment = cls.get(id) ticket = Ticket.get(ticket_id) # TODO: 重构feed之后取消signal发送 codereview_signal.send(comment, content=content, ticket=Ticket.get(ticket_id), author=author, comment=comment) dispatch('codereview', data={ 'comment': comment, 'ticket': ticket, 'sender': author, }) return comment
def update(self, content): store.execute("update issue_comments " "set updated_at=CURRENT_TIMESTAMP " "where id=%s", (self.id)) store.commit() bdb.set(BDB_ISSUE_COMMENT_CONTENT_KEY % self.id, content)
def update(self, content): bdb.set(BDB_TICKET_COMMENT_CONTENT_KEY % self.id, content) self.time = datetime.now() self.save()
def update(self, title='', description=''): store.execute("update codedouban_ticket set title=%s, description=%s " "where id=%s", (title, description, self.id)) store.commit() mc.delete(MCKEY_TICKET % self.id) bdb.set(BDB_TICKET_DESCRIPTION_KEY % self.id, description)
def set(self, white_list): bdb.set(self.dbkey, white_list) return bdb.get(self.dbkey, [])
def update(self, content): store.execute( "update codedouban_linecomments_v2 " "set updated_at=now() where id=%s", (self.id, )) store.commit() bdb.set(BDB_LINECOMMENT_CONTENT_KEY % self.id, content)
def update(self, content): store.execute("update codedouban_linecomments_v2 " "set updated_at=now() where id=%s", (self.id,)) store.commit() bdb.set(BDB_LINECOMMENT_CONTENT_KEY % self.id, content)
def update(self, content): store.execute("update codedouban_ticket_codereview " "set time=now() where id=%s", (self.id,)) store.commit() bdb.set(BDB_TICKET_LINECOMMENT_CONTENT_KEY % self.id, content)
def update(self, content): store.execute( "update codedouban_ticket_codereview " "set time=now() where id=%s", (self.id, )) store.commit() bdb.set(BDB_TICKET_LINECOMMENT_CONTENT_KEY % self.id, content)