コード例 #1
0
ファイル: review.py プロジェクト: Tigge/critic
 def fromArgument(db, argument):
     try:
         return Review.fromId(db, int(argument))
     except:
         from dbutils import Branch
         branch = Branch.fromName(db, str(argument))
         if not branch: return None
         return Review.fromBranch(db, branch)
コード例 #2
0
 def fromArgument(db, argument):
     try:
         return Review.fromId(db, int(argument))
     except:
         from dbutils import Branch
         branch = Branch.fromName(db, str(argument))
         if not branch: return None
         return Review.fromBranch(db, branch)
コード例 #3
0
    def fromId(db, review_id, branch=None, profiler=None):
        from dbutils import User

        cursor = db.cursor()
        cursor.execute(
            "SELECT type, branch, state, serial, summary, description, applyfilters, applyparentfilters FROM reviews WHERE id=%s",
            [review_id])
        row = cursor.fetchone()
        if not row: raise NoSuchReview(review_id)

        type, branch_id, state, serial, summary, description, applyfilters, applyparentfilters = row

        if profiler: profiler.check("Review.fromId: basic")

        if branch is None:
            from dbutils import Branch
            branch = Branch.fromId(db,
                                   branch_id,
                                   load_review=False,
                                   profiler=profiler)

        cursor.execute("SELECT uid FROM reviewusers WHERE review=%s AND owner",
                       (review_id, ))

        owners = User.fromIds(db, [user_id for (user_id, ) in cursor])

        if profiler: profiler.check("Review.fromId: owners")

        review = Review(review_id, owners, type, branch, state, serial,
                        summary, description, applyfilters, applyparentfilters)
        branch.review = review

        # Reviewers: all users that have at least one review file assigned to them.
        cursor.execute(
            """SELECT DISTINCT uid, assignee IS NOT NULL, type
                            FROM reviewusers
                 LEFT OUTER JOIN fullreviewuserfiles ON (fullreviewuserfiles.review=reviewusers.review AND assignee=uid)
                           WHERE reviewusers.review=%s""", (review_id, ))

        reviewers = []
        watchers = []
        watcher_types = {}

        for user_id, is_reviewer, user_type in cursor.fetchall():
            if is_reviewer:
                reviewers.append(user_id)
            elif user_id not in review.owners:
                watchers.append(user_id)
                watcher_types[user_id] = user_type

        review.reviewers = User.fromIds(db, reviewers)

        for watcher in User.fromIds(db, watchers):
            review.watchers[watcher] = watcher_types[watcher]

        if profiler: profiler.check("Review.fromId: users")

        return review
コード例 #4
0
ファイル: review.py プロジェクト: Aessy/critic
    def fromId(db, review_id, branch=None, profiler=None):
        from dbutils import User

        cursor = db.cursor()
        cursor.execute("SELECT type, branch, state, serial, summary, description, applyfilters, applyparentfilters FROM reviews WHERE id=%s", [review_id])
        row = cursor.fetchone()
        if not row: raise NoSuchReview(review_id)

        type, branch_id, state, serial, summary, description, applyfilters, applyparentfilters = row

        if profiler: profiler.check("Review.fromId: basic")

        if branch is None:
            from dbutils import Branch
            branch = Branch.fromId(db, branch_id, load_review=False, profiler=profiler)

        cursor.execute("SELECT uid FROM reviewusers WHERE review=%s AND owner", (review_id,))

        owners = User.fromIds(db, [user_id for (user_id,) in cursor])

        if profiler: profiler.check("Review.fromId: owners")

        review = Review(review_id, owners, type, branch, state, serial, summary, description, applyfilters, applyparentfilters)
        branch.review = review

        # Reviewers: all users that have at least one review file assigned to them.
        cursor.execute("""SELECT DISTINCT uid, assignee IS NOT NULL, type
                            FROM reviewusers
                 LEFT OUTER JOIN fullreviewuserfiles ON (fullreviewuserfiles.review=reviewusers.review AND assignee=uid)
                           WHERE reviewusers.review=%s""",
                       (review_id,))

        reviewers = []
        watchers = []
        watcher_types = {}

        for user_id, is_reviewer, user_type in cursor.fetchall():
            if is_reviewer:
                reviewers.append(user_id)
            elif user_id not in review.owners:
                watchers.append(user_id)
                watcher_types[user_id] = user_type

        review.reviewers = User.fromIds(db, reviewers)

        for watcher in User.fromIds(db, watchers):
            review.watchers[watcher] = watcher_types[watcher]

        if profiler: profiler.check("Review.fromId: users")

        return review
コード例 #5
0
ファイル: review.py プロジェクト: Tigge/critic
 def fromName(db, repository, name):
     from dbutils import Branch
     return Review.fromBranch(db, Branch.fromName(db, repository, name))
コード例 #6
0
 def fromName(db, repository, name):
     from dbutils import Branch
     return Review.fromBranch(db, Branch.fromName(db, repository, name))