Exemplo n.º 1
0
 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
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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
Exemplo n.º 5
0
 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
Exemplo n.º 6
0
 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, '')
Exemplo n.º 7
0
 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))
Exemplo n.º 8
0
 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, '')
Exemplo n.º 9
0
 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))
Exemplo n.º 10
0
 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)
Exemplo n.º 11
0
 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)
Exemplo n.º 12
0
 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)
Exemplo n.º 13
0
 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)
Exemplo n.º 14
0
    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
Exemplo n.º 15
0
    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
Exemplo n.º 16
0
 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)
Exemplo n.º 17
0
 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
Exemplo n.º 18
0
 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
Exemplo n.º 19
0
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)
Exemplo n.º 20
0
 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)
Exemplo n.º 21
0
 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
Exemplo n.º 22
0
 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,
     })
Exemplo n.º 23
0
 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,
              })
Exemplo n.º 24
0
 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
Exemplo n.º 25
0
 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)
Exemplo n.º 26
0
 def update(self, content):
     bdb.set(BDB_TICKET_COMMENT_CONTENT_KEY % self.id, content)
     self.time = datetime.now()
     self.save()
Exemplo n.º 27
0
 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)
Exemplo n.º 28
0
 def set(self, white_list):
     bdb.set(self.dbkey, white_list)
     return bdb.get(self.dbkey, [])
Exemplo n.º 29
0
 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)
Exemplo n.º 30
0
 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)
Exemplo n.º 31
0
 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)
Exemplo n.º 32
0
 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)
Exemplo n.º 33
0
 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)
Exemplo n.º 34
0
 def update(self, content):
     bdb.set(BDB_TICKET_COMMENT_CONTENT_KEY % self.id, content)
     self.time = datetime.now()
     self.save()