Skip to content

Added efficiency improvement to get_installation #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions blurb_it/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import jwt
from aiohttp_session import get_session
from gidgethub import BadRequest

from blurb_it import error

Expand Down Expand Up @@ -66,18 +67,13 @@


async def get_installation(gh, jwt, username):

async for installation in gh.getiter(
"/app/installations",
jwt=jwt,
accept="application/vnd.github.machine-man-preview+json",
):
if installation["account"]["login"] == username:
return installation

raise error.InstallationNotFound(
f"Can't find installation by that user: {username}"
)
try:
return await gh.getitem(f"/users/{username}/installation", jwt=jwt)
except BadRequest:

Check warning on line 72 in blurb_it/util.py

View check run for this annotation

Codecov / codecov/patch

blurb_it/util.py#L70-L72

Added lines #L70 - L72 were not covered by tests
# will raise a 401 if no installation for this user
raise error.InstallationNotFound(

Check warning on line 74 in blurb_it/util.py

View check run for this annotation

Codecov / codecov/patch

blurb_it/util.py#L74

Added line #L74 was not covered by tests
f"Can't find installation by that user: {username}"
)


async def get_installation_access_token(gh, jwt, installation_id):
Expand Down