Skip to content

Add available GithubAppInstallations to a user #853

@joshsmith

Description

@joshsmith
Contributor

Problem

We need to find a way to add available GithubAppInstallations for a User that the user has access to for the GitHub App.

We'll have to refresh this data by hitting GitHub's API endpoint for listing a user's installations.

We may want an endpoint for this at our own /user/github-app-installations. We could also consider having this simply be available to a User on the UserView, but this may confuse things with an existing GithubAppInstallations relationship. We could perhaps rename the key to something like available-github-app-installations but keep the type github-app-installation.

Alternatively, we could also rename the user relationship in GithubAppInstallation to sender, which is more in-line with GitHub's own API and can reduce some confusion there.

Activity

added this to the GitHub integration milestone on Jul 19, 2017
joshsmith

joshsmith commented on Jul 19, 2017

@joshsmith
ContributorAuthor

This could definitely use some thoughts @begedin.

begedin

begedin commented on Jul 20, 2017

@begedin
Contributor

We'll have to refresh this data by hitting GitHub's API endpoint for listing a user's installations.

The way I see it, this goes two ways

If this is a relationship we want to store locally, then we need to add it to the user, rename the existing user relationship on the GithubAppInstallation to sender or installer. Add an owner or something as a second user relationship. The user can then have accessible_github_app_installations and installed_github_app_installations.

Then we can deal with it through ember-data and models

If it's something we fetch at one point and simply pass on as JSON to the user, then I see the benefit of having a special endpoint for it. In that case, we should probably be circumventing ember-data as well and simply have a computed filter the data directly.

Either way, I'm leaning against scheduled/periodic refreshes just to store the records locally. If we want to store them, we should identify the cases where they change and store them.

  • installation webhook
  • upon connecting a user with github
  • etc.

Automatic refreshes sound like we're almost bruteforcing it and I don't like doing that until we've exhausted our options.

self-assigned this
on Jul 25, 2017
modified the milestone: GitHub integration MVP on Sep 28, 2017
begedin

begedin commented on Oct 2, 2017

@begedin
Contributor

I was sure I already updated this, but apparently not.

Our agreed upon approach is the following

  • Index route takes current user
  • If not github connected, returns []
  • If github connected, we hit the github API to retrieve the user's installations
  • From the results, we get the ids, these are github_id fields in our local database.
  • We return the installation records matching those ids

With implementation and tests, I don't think we would need to go over 4 hours for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

    Participants

    @joshsmith@begedin

    Issue actions

      Add available GithubAppInstallations to a user · Issue #853 · code-corps/code-corps-api