def salon(github_username, override_username=None): if override_username: github_username = override_username.lower() to_review_query = ( PullRequest.query .options(db.subqueryload(PullRequest.states)) .filter(PullRequest.state == "open") .filter(db.func.lower(PullRequest.author) != github_username) .join(ReviewState) .filter(db.func.lower(ReviewState.user) == github_username) .order_by(db.desc(PullRequest.created)) ) to_review = collections.defaultdict(list) for pull_request in to_review_query: state = pull_request.current_states()[github_username] to_review[state].append(pull_request) my_pulls_query = ( PullRequest.query .options(db.subqueryload(PullRequest.states)) .filter(PullRequest.state == "open") .filter(db.func.lower(PullRequest.author) == github_username) .order_by(db.desc(PullRequest.created)) ) my_pulls = _categorize_by_states(my_pulls_query) return render_template( "home.html", github_username=github_username, my_pulls=my_pulls, to_review=to_review, )
def salon(): github_username = internal_to_github(g.username).lower() to_review_query = ( PullRequest.query .options(db.subqueryload(PullRequest.states)) .filter(PullRequest.state == "open") .filter(db.func.lower(PullRequest.author) != github_username) .join(ReviewState) .filter(db.func.lower(ReviewState.user) == github_username) .order_by(db.desc(PullRequest.created)) ) to_review = collections.defaultdict(list) for pull_request in to_review_query: state = pull_request.current_states()[github_username] to_review[state].append(pull_request) my_pulls_query = ( PullRequest.query .options(db.subqueryload(PullRequest.states)) .filter(PullRequest.state == "open") .filter(db.func.lower(PullRequest.author) == github_username) .order_by(db.desc(PullRequest.created)) ) my_pulls = _categorize_by_states(my_pulls_query) return render_template( "home.html", github_username=github_username, internal_username=g.username, my_pulls=my_pulls, to_review=to_review, )
def salon(): github_username = internal_to_github(g.username).lower() to_review_query = ( PullRequest.query .options(db.subqueryload(PullRequest.states)) .filter(PullRequest.state == "open") .filter(db.func.lower(PullRequest.author) != github_username) .join(ReviewState) .filter(db.func.lower(ReviewState.user) == github_username) .order_by(db.desc(PullRequest.created)) ) to_review = collections.defaultdict(list) for pull_request in to_review_query: state = pull_request.current_states()[github_username] to_review[state].append(pull_request) my_pulls_query = ( PullRequest.query .options(db.subqueryload(PullRequest.states)) .filter(PullRequest.state == "open") .filter(db.func.lower(PullRequest.author) == github_username) .order_by(db.desc(PullRequest.created)) ) my_pulls = collections.defaultdict(list) for pull_request in my_pulls_query: states = pull_request.current_states().values() # no states at all is a completely separate issue if not states: my_pulls["eyeglasses"].append(pull_request) continue # now, take away the "haven't looked yet" people and see what's up states = [state for state in states if state != "unreviewed"] if not states: verdict = "unreviewed" elif all(state == "fish" for state in states): verdict = "fish" elif any(state == "nail_care" for state in states): verdict = "nail_care" else: verdict = "haircut" my_pulls[verdict].append(pull_request) return render_template( "home.html", github_username=github_username, internal_username=g.username, my_pulls=my_pulls, to_review=to_review, )
def log(): before = request.args.get("before") if before: try: before = datetime.datetime.strptime(before, "%Y-%m-%dT%H:%M:%S") except (TypeError, ValueError): before = None try: count = int(request.args.get("count")) except (TypeError, ValueError): count = 25 count = min(count, 100) event_types = request.args.getlist("event_type") users = request.args.getlist("user") query = Event.query.order_by(db.desc(Event.timestamp)) if before: query = query.filter(Event.timestamp <= before) if event_types: query = query.filter(Event.event.in_(event_types)) if users: query = query.filter(Event.actor.in_(users)) query = query.limit(count) return render_template( "log.html", events=list(query), before=before, count=count, event_types=event_types, )
def overview(): query = ( PullRequest.query .options(db.subqueryload(PullRequest.states)) .filter(PullRequest.state == "open") .order_by(db.desc(PullRequest.created)) ) pull_requests = _categorize_by_states(query) return render_template( "overview.html", pull_requests=pull_requests, )
def overview(github_username): query = ( PullRequest.query .options(db.subqueryload(PullRequest.states)) .filter(PullRequest.state == "open") .order_by(db.desc(PullRequest.created)) ) pull_requests = _categorize_by_states(query) return render_template( "overview.html", pull_requests=pull_requests, github_username=github_username, )
def overview(): query = (PullRequest.query.options(db.subqueryload( PullRequest.states)).filter(PullRequest.state == "open").order_by( db.desc(PullRequest.created))) pull_requests = collections.defaultdict(list) for pull_request in query: stage = pull_request.review_stage() pull_requests[stage].append(pull_request) return render_template( "overview.html", pull_requests=pull_requests, )
def overview(): query = ( PullRequest.query .options(db.subqueryload(PullRequest.states)) .filter(PullRequest.state == "open") .order_by(db.desc(PullRequest.created)) ) pull_requests = collections.defaultdict(list) for pull_request in query: stage = pull_request.review_stage() pull_requests[stage].append(pull_request) return render_template( "overview.html", pull_requests=pull_requests, )