def main(): homepage = memcache.get("homepage") if IS_DEV_APPSERVER or homepage is None: issues = Issue.query(Issue.state == "open").order(-Issue.updated_at).iter() homepage = render_template('index.html', session=session, issues=issues) memcache.set("homepage", value=homepage, time=60) return homepage
def main(): issues = Issue.query(Issue.state == "open").order(-Issue.updated_at).fetch() issues_by_component = defaultdict(list) for issue in issues: for component in issue.components: issues_by_component[component].append(issue) # Display the groups in the order listed in Issues._components grouped_issues = [(c[0], issues_by_component[c[0]]) for c in Issue._components] return build_response('index.html', grouped_issues=grouped_issues)
def update_all_jiras_for_open_prs(): """ Used to bulk-load information from JIRAs for all open PRs. Useful when upgrading from an earlier version of spark-prs. """ prs = Issue.query(Issue.state == "open").order(-Issue.updated_at).fetch() jira_issues = set(itertools.chain.from_iterable(pr.parsed_title['jiras'] for pr in prs)) for issue in jira_issues: taskqueue.add(url="/tasks/update-jira-issue/SPARK-%i" % issue, queue_name='jira-issues') return "Queued JIRA issues for update: " + str(jira_issues)
def users(username): prs = Issue.query(Issue.state == "open").order(-Issue.updated_at).fetch() prs_authored = [p for p in prs if p.user == username] prs_commented_on = [ p for p in prs if username in dict(p.commenters) and p.user != username ] return build_response('user.html', username=username, prs_authored=prs_authored, prs_commented_on=prs_commented_on)
def update_all_jiras_for_open_prs(): """ Used to bulk-load information from JIRAs for all open PRs. Useful when upgrading from an earlier version of spark-prs. """ prs = Issue.query(Issue.state == "open").order(-Issue.updated_at).fetch() jira_issues = set(itertools.chain.from_iterable(pr.parsed_title["jiras"] for pr in prs)) for issue in jira_issues: taskqueue.add(url="/tasks/update-jira-issue/SPARK-%i" % issue, queue_name="jira-issues") return "Queued JIRA issues for update: " + str(jira_issues)
def main(): issues = Issue.query( Issue.state == "open").order(-Issue.updated_at).fetch() issues_by_component = defaultdict(list) for issue in issues: for component in issue.components: issues_by_component[component].append(issue) # Display the groups in the order listed in Issues._components grouped_issues = [(c[0], issues_by_component[c[0]]) for c in Issue._components] return build_response('index.html', grouped_issues=grouped_issues)
def search_open_prs(): prs = Issue.query(Issue.state == "open").order(-Issue.updated_at).fetch() json_dicts = [] for pr in prs: try: last_jenkins_comment_dict = None if pr.last_jenkins_comment: last_jenkins_comment_dict = { 'body': pr.last_jenkins_comment['body'], 'user': {'login': pr.last_jenkins_comment['user']['login']}, 'html_url': pr.last_jenkins_comment['html_url'], 'date': [pr.last_jenkins_comment['created_at']], } d = { 'parsed_title': pr.parsed_title, 'number': pr.number, 'updated_at': str(pr.updated_at), 'user': pr.user, 'state': pr.state, 'components': pr.components, 'lines_added': pr.lines_added, 'lines_deleted': pr.lines_deleted, 'lines_changed': pr.lines_changed, 'is_mergeable': pr.is_mergeable, 'commenters': [{'username': u, 'data': d} for (u, d) in pr.commenters], 'last_jenkins_outcome': pr.last_jenkins_outcome, 'last_jenkins_comment': last_jenkins_comment_dict, } # Use the first JIRA's information to populate the "Priority" and "Issue Type" columns: jiras = pr.parsed_title["jiras"] if jiras: first_jira = JIRAIssue.get_by_id("%s-%i" % (app.config['JIRA_PROJECT'], jiras[0])) if first_jira: d['jira_priority_name'] = first_jira.priority_name d['jira_priority_icon_url'] = first_jira.priority_icon_url d['jira_issuetype_name'] = first_jira.issuetype_name d['jira_issuetype_icon_url'] = first_jira.issuetype_icon_url d['jira_shepherd_display_name'] = first_jira.shepherd_display_name # If a pull request is linked against multiple JIRA issues, then the target # versions should be union of the individual issues' target versions: target_versions = set() for jira_number in jiras: jira = JIRAIssue.get_by_id("%s-%i" % (app.config['JIRA_PROJECT'], jira_number)) if jira: target_versions.update(jira.target_versions) if target_versions: d['jira_target_versions'] = natsorted(target_versions) json_dicts.append(d) except: logging.error("Exception while processing PR #%i", pr.number) raise response = Response(json.dumps(json_dicts), mimetype='application/json') return response
def build_response(template, max_age=60, **kwargs): navigation_bar = [ # (href, id, label, badge_value) ('/', 'index', 'Open PRs', int(Issue.query(Issue.state == "open").count())), ] if g.user and "admin" in g.user.roles: navigation_bar.append(('/admin', 'admin', 'Admin', None)) default_context = { 'profiler_includes': profiler_includes(), 'navigation_bar': navigation_bar, 'user': g.user, } rendered = render_template(template, **(dict(default_context.items() + kwargs.items()))) response = make_response(rendered) response.cache_control.max_age = max_age return response
def build_response(template, max_age=60, **kwargs): navigation_bar = [ # (href, id, label, badge_value) ('/', 'index', 'Open PRs', int(Issue.query(Issue.state == "open").count())), ] if g.user and "admin" in g.user.roles: navigation_bar.append(('/admin', 'admin', 'Admin', None)) default_context = { 'profiler_includes': profiler_includes(), 'navigation_bar': navigation_bar, 'user': g.user, } rendered = render_template( template, **(dict(default_context.items() + kwargs.items()))) response = make_response(rendered) response.cache_control.max_age = max_age return response
def search_open_prs(): prs = Issue.query(Issue.state == "open").order(-Issue.updated_at).fetch() json_dicts = [] for pr in prs: last_jenkins_comment_dict = None if pr.last_jenkins_comment: last_jenkins_comment_dict = { 'body': pr.last_jenkins_comment['body'], 'user': { 'login': pr.last_jenkins_comment['user']['login'] }, 'html_url': pr.last_jenkins_comment['html_url'], } d = { 'parsed_title': pr.parsed_title, 'number': pr.number, 'updated_at': str(pr.updated_at), 'user': pr.user, 'state': pr.state, 'components': pr.components, 'lines_added': pr.lines_added, 'lines_deleted': pr.lines_deleted, 'lines_changed': pr.lines_changed, 'is_mergeable': pr.is_mergeable, 'commenters': [{ 'username': u, 'data': d } for (u, d) in pr.commenters], 'last_jenkins_outcome': pr.last_jenkins_outcome, 'last_jenkins_comment': last_jenkins_comment_dict, } # Use the first JIRA's information to populate the "Priority" and "Issue Type" columns: jiras = pr.parsed_title["jiras"] if jiras: first_jira = JIRAIssue.get_by_id("SPARK-%i" % jiras[0]) if first_jira: d['jira_priority_name'] = first_jira.priority_name d['jira_priority_icon_url'] = first_jira.priority_icon_url d['jira_issuetype_name'] = first_jira.issuetype_name d['jira_issuetype_icon_url'] = first_jira.issuetype_icon_url json_dicts.append(d) response = Response(json.dumps(json_dicts), mimetype='application/json') return response
def search_open_prs(): prs = Issue.query(Issue.state == "open").order(-Issue.updated_at).fetch() json_dicts = [] for pr in prs: last_jenkins_comment_dict = None if pr.last_jenkins_comment: last_jenkins_comment_dict = { 'body': pr.last_jenkins_comment['body'], 'user': {'login': pr.last_jenkins_comment['user']['login']}, 'html_url': pr.last_jenkins_comment['html_url'], 'date': [pr.last_jenkins_comment['created_at']], } d = { 'parsed_title': pr.parsed_title, 'number': pr.number, 'updated_at': str(pr.updated_at), 'user': pr.user, 'state': pr.state, 'components': pr.components, 'lines_added': pr.lines_added, 'lines_deleted': pr.lines_deleted, 'lines_changed': pr.lines_changed, 'is_mergeable': pr.is_mergeable, 'commenters': [{'username': u, 'data': d} for (u, d) in pr.commenters], 'last_jenkins_outcome': pr.last_jenkins_outcome, 'last_jenkins_comment': last_jenkins_comment_dict, } # Use the first JIRA's information to populate the "Priority" and "Issue Type" columns: jiras = pr.parsed_title["jiras"] if jiras: first_jira = JIRAIssue.get_by_id("SPARK-%i" % jiras[0]) if first_jira: d['jira_priority_name'] = first_jira.priority_name d['jira_priority_icon_url'] = first_jira.priority_icon_url d['jira_issuetype_name'] = first_jira.issuetype_name d['jira_issuetype_icon_url'] = first_jira.issuetype_icon_url d['jira_shepherd_display_name'] = first_jira.shepherd_display_name json_dicts.append(d) response = Response(json.dumps(json_dicts), mimetype='application/json') return response
def search_open_prs(): prs = Issue.query(Issue.state == "open").order(-Issue.updated_at).fetch() json_dicts = [] for pr in prs: last_jenkins_comment_dict = None if pr.last_jenkins_comment: last_jenkins_comment_dict = { "body": pr.last_jenkins_comment["body"], "user": {"login": pr.last_jenkins_comment["user"]["login"]}, "html_url": pr.last_jenkins_comment["html_url"], } d = { "parsed_title": pr.parsed_title, "number": pr.number, "updated_at": str(pr.updated_at), "user": pr.user, "state": pr.state, "components": pr.components, "lines_added": pr.lines_added, "lines_deleted": pr.lines_deleted, "lines_changed": pr.lines_changed, "is_mergeable": pr.is_mergeable, "commenters": [{"username": u, "data": d} for (u, d) in pr.commenters], "last_jenkins_outcome": pr.last_jenkins_outcome, "last_jenkins_comment": last_jenkins_comment_dict, } # Use the first JIRA's information to populate the "Priority" and "Issue Type" columns: jiras = pr.parsed_title["jiras"] if jiras: first_jira = JIRAIssue.get_by_id("SPARK-%i" % jiras[0]) if first_jira: d["jira_priority_name"] = first_jira.priority_name d["jira_priority_icon_url"] = first_jira.priority_icon_url d["jira_issuetype_name"] = first_jira.issuetype_name d["jira_issuetype_icon_url"] = first_jira.issuetype_icon_url d["jira_shepherd_display_name"] = first_jira.shepherd_display_name json_dicts.append(d) response = Response(json.dumps(json_dicts), mimetype="application/json") return response
def all_prs_json(): offset = int(request.args.get('offset')) limit = 100 prs = Issue.query(Issue.number > offset).order(Issue.number).fetch(limit) return build_pr_json_response(prs)
def users(username): prs = Issue.query(Issue.state == "open").order(-Issue.updated_at).fetch() prs_authored = [p for p in prs if p.user == username] prs_commented_on = [p for p in prs if username in dict(p.commenters) and p.user != username] return build_response('user.html', username=username, prs_authored=prs_authored, prs_commented_on=prs_commented_on)
def search_open_prs(): prs = Issue.query(Issue.state == "open").order(-Issue.updated_at).fetch() json_dicts = [] for pr in prs: try: last_jenkins_comment_dict = None if pr.last_jenkins_comment: last_jenkins_comment_dict = { 'body': pr.last_jenkins_comment['body'], 'user': { 'login': pr.last_jenkins_comment['user']['login'] }, 'html_url': pr.last_jenkins_comment['html_url'], 'date': [pr.last_jenkins_comment['created_at']], } d = { 'parsed_title': pr.parsed_title, 'number': pr.number, 'updated_at': str(pr.updated_at), 'user': pr.user, 'state': pr.state, 'components': pr.components, 'lines_added': pr.lines_added, 'lines_deleted': pr.lines_deleted, 'lines_changed': pr.lines_changed, 'is_mergeable': pr.is_mergeable, 'commenters': [{ 'username': u, 'data': d } for (u, d) in pr.commenters], 'last_jenkins_outcome': pr.last_jenkins_outcome, 'last_jenkins_comment': last_jenkins_comment_dict, } # Use the first JIRA's information to populate the "Priority" and "Issue Type" columns: jiras = pr.parsed_title["jiras"] if jiras: first_jira = JIRAIssue.get_by_id( "%s-%i" % (app.config['JIRA_PROJECT'], jiras[0])) if first_jira: d['jira_priority_name'] = first_jira.priority_name d['jira_priority_icon_url'] = first_jira.priority_icon_url d['jira_issuetype_name'] = first_jira.issuetype_name d['jira_issuetype_icon_url'] = first_jira.issuetype_icon_url d['jira_shepherd_display_name'] = first_jira.shepherd_display_name # If a pull request is linked against multiple JIRA issues, then the target # versions should be union of the individual issues' target versions: target_versions = set() for jira_number in jiras: jira = JIRAIssue.get_by_id( "%s-%i" % (app.config['JIRA_PROJECT'], jira_number)) if jira: target_versions.update(jira.target_versions) if target_versions: d['jira_target_versions'] = natsorted(target_versions) json_dicts.append(d) except: logging.error("Exception while processing PR #%i", pr.number) raise response = Response(json.dumps(json_dicts), mimetype='application/json') return response
def search_open_prs(): prs = Issue.query(Issue.state == "open").order(-Issue.updated_at).fetch() return search_prs(prs)
def search_stale_prs(): issueQuery = ndb.AND(Issue.state == "open", Issue.updated_at < datetime.datetime.today() - datetime.timedelta(days=30)) stalePrs = Issue.query(issueQuery).order(-Issue.updated_at).fetch() return search_prs(stalePrs)
def search_stale_prs(): issueQuery = ndb.AND( Issue.state == "open", Issue.updated_at < datetime.datetime.today() - datetime.timedelta(days=30)) stalePrs = Issue.query(issueQuery).order(-Issue.updated_at).fetch() return search_prs(stalePrs)
def refresh_all_prs(): prs = Issue.query(Issue.state == "open") for pr in prs: taskqueue.add(url=url_for(".update_pr", pr_number=pr.number), queue_name='old-prs') return "Enqueued tasks to refresh all open PRs"