Skip to content

Commit

Permalink
style: alphabetize some methods
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Mar 17, 2022
1 parent f697f29 commit 4802876
Showing 1 changed file with 65 additions and 65 deletions.
130 changes: 65 additions & 65 deletions src/dinghy/digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,6 @@ def __init__(self, since, options):
self.gql = GraphqlHelper("https://api.github.com/graphql", token)
self.ignore_users = options.get("ignore_users", [])

async def get_repo_issues(self, owner, name):
"""
Get issues from a repo updated since a date, with comments since that date.
Args:
owner (str): the owner of the repo.
name (str): the name of the repo.
"""
repo, issues = await self.gql.nodes(
query=build_query("repo_issues.graphql"),
variables=dict(owner=owner, name=name, since=self.since),
)
issues = await self._process_entries(issues)
repo = glom(repo, "data.repository")
container = {
"url": repo["url"],
"container_kind": "repo",
"title": repo["nameWithOwner"],
"kind": "issues",
"entries": issues,
}
return container

async def get_org_project_entries(self, org, number, home_repo=""):
"""
Get entries from a organization project.
Expand Down Expand Up @@ -86,6 +63,71 @@ async def get_org_project_entries(self, org, number, home_repo=""):
}
return container

async def get_org_pull_requests(self, org):
"""
Get pull requests across an organization. Uses GitHub search.
"""
search_terms = {
"org": org,
"is": "pr",
"updated": f">{self.since}",
}
search_query = " ".join(f"{k}:{v}" for k, v in search_terms.items())
_, pulls = await self.gql.nodes(
query=build_query("search_entries.graphql"),
variables=dict(query=search_query),
)
pulls = await self._process_entries(pulls)
url_q = urllib.parse.quote_plus(search_query)
container = {
"url": f"https://github.com/search?q={url_q}&type=issues",
"container_kind": "search",
"title": search_query,
"kind": "pull requests",
"entries": pulls,
}
return container

async def get_repo_entries(self, owner, name):
"""
Get issues and pull requests from a repo.
"""
issue_container, pr_container = await asyncio.gather(
self.get_repo_issues(owner, name),
self.get_repo_pull_requests(owner, name),
)
entries = issue_container["entries"] + pr_container["entries"]
entries = self._trim_unwanted(entries)
container = {
**issue_container,
"kind": "issues and pull requests",
"entries": entries,
}
return container

async def get_repo_issues(self, owner, name):
"""
Get issues from a repo updated since a date, with comments since that date.
Args:
owner (str): the owner of the repo.
name (str): the name of the repo.
"""
repo, issues = await self.gql.nodes(
query=build_query("repo_issues.graphql"),
variables=dict(owner=owner, name=name, since=self.since),
)
issues = await self._process_entries(issues)
repo = glom(repo, "data.repository")
container = {
"url": repo["url"],
"container_kind": "repo",
"title": repo["nameWithOwner"],
"kind": "issues",
"entries": issues,
}
return container

async def get_repo_project_entries(self, owner, name, number):
"""
Get entries from a repo project.
Expand Down Expand Up @@ -141,48 +183,6 @@ async def get_repo_pull_requests(self, owner, name):
}
return container

async def get_repo_entries(self, owner, name):
"""
Get issues and pull requests from a repo.
"""
issue_container, pr_container = await asyncio.gather(
self.get_repo_issues(owner, name),
self.get_repo_pull_requests(owner, name),
)
entries = issue_container["entries"] + pr_container["entries"]
entries = self._trim_unwanted(entries)
container = {
**issue_container,
"kind": "issues and pull requests",
"entries": entries,
}
return container

async def get_org_pull_requests(self, org):
"""
Get pull requests across an organization. Uses GitHub search.
"""
search_terms = {
"org": org,
"is": "pr",
"updated": f">{self.since}",
}
search_query = " ".join(f"{k}:{v}" for k, v in search_terms.items())
_, pulls = await self.gql.nodes(
query=build_query("search_entries.graphql"),
variables=dict(query=search_query),
)
pulls = await self._process_entries(pulls)
url_q = urllib.parse.quote_plus(search_query)
container = {
"url": f"https://github.com/search?q={url_q}&type=issues",
"container_kind": "search",
"title": search_query,
"kind": "pull requests",
"entries": pulls,
}
return container

def method_from_url(self, url):
"""
Dispatch to a get_* method from a GitHub URL.
Expand Down

0 comments on commit 4802876

Please sign in to comment.