Police-Data-Accessibility-Project / data-sources-app

An API and UI for using and maintaining the Data Sources database
MIT License
2 stars 5 forks source link

integrate with GitHub for Requests project management #299

Open josh-chamberlain opened 4 months ago

josh-chamberlain commented 4 months ago

Context

We'll use github to communicate about requests. This integration allows us to create issues, and read their status from the app.

Requirements

The GitHub Discussions option

maxachis commented 4 months ago
* maybe they go into a private repo at first, and get moved into a public repo when they're ready for volunteers

One option is to utilize GitHub discussions, which would enable us to review and discuss data requests before converting them to an issue (which can be easily done using Discussions functionality). GitHub discussions, as I understand it, is tied to the visibility of the repository it is connected with.

Still, having them exist as discussions allows us to refine and potentially talk more with the request provider before converting it to a distinct issue, and avoids having to maintain two separate repositories. We can set it so that users with read access can be disallowed from creating discussions.

At the very least, I think it's worth playing around with to see whether it can work for our purposes.

josh-chamberlain commented 4 months ago

@maxachis I like this idea. In particular, blocking people from creating a new discussion except through the form, which we can't do with issues. It's set up to encourage community involvement and more appropriate from an abstract terms/functions perspective. Either way, I set up discussions for the repo to give it a fighting chance.

misgivings:

maxachis commented 1 month ago

@josh-chamberlain Here is the MVP workflow as I am envisioning it (from the backend's perspective). We can expand on this, but I want to make sure I've got the core functionality down.

  1. The POST endpoint for /data-requests is called, creating the data request in the backend
  2. At some later point, the POST endpoint for /data-requests/github-issue/{ID} is called, which takes the data request as it exists in the database and creates an issue in the Data Projects repository using that data. The github_issue_url field is updated in the database, and possibly the request_status.

Does this align with what you're thinking?

josh-chamberlain commented 1 month ago

@maxachis sorry, I never responded! Yes, this is what I'm thinking. I made some changes to the issue yesterday.

maxachis commented 2 weeks ago

Github GraphQL API

Relevant Links

Other notes:

Authenticating

maxachis commented 2 weeks ago

@josh-chamberlain Alright, after doing some snurfling, here's what I've determined as far as the implementation goes.

I'll also re: @joshuagraber here, so he can sanity check my thinking on this.

Implementation

This feature, as currently designed would involve multiple components:

  1. Modifying the project automations (i.e., in https://github.com/orgs/Police-Data-Accessibility-Project/projects/26/workflows ) so that, when an issue is added to the repository, it is automatically added to the project and given a specific status
  2. Setting up a /github/data-requests/issues endpoint, whose POST functionality adds an issue to GitHub with the given information,
    1. This requires a GraphQL call
  3. Setting up a /github/data-requests/synchronize endpoint, whose POST functionality
    1. Uses a GraphQL call to get all issues (and their statuses) in the repository
    2. ~Checks to see if they don't exist in the Database, and adds them to the database if not~ ignores all issues which do not have a corresponding data request in the database (this should not occur, anyway).
    3. Checks to see if their status is the same as it is in the database, and updates the database status if not
  4. Creating an automation manager job which calls /github/data/requests/synchronize on a periodic basis

What are the unknowns?

This seems convoluted: Is there any other option?

Not as far as I can tell if we want to use GitHub projects, I'm afraid. There are no GitHub Action triggers (https://github.com/orgs/community/discussions/40848) for when a Project's status is changed, nor any Webhooks that do the same, so our only option is to repeatedly poll for updates and modify them in the database as they occur.

However, if we were instead interested in using the future Retool option to manage data requests, that would (in theory) provide us with a means for monitoring and manipulating data request statuses without having to use the clunky synchronization option. However, if we did that, we would lose the tight GitHub integration.

josh-chamberlain commented 2 weeks ago

@maxachis I don't think we should add issues from github as PDAP requests—syncing status makes sense, but creating requests from our app should be the one and only workflow (at least for now) for simplicity and clarity. We'd only be polling GitHub for status on occasion; we could do this on page view and/or periodically.

maxachis commented 2 weeks ago

@maxachis I don't think we should add issues from github as PDAP requests—syncing status makes sense, but creating requests from our app should be the one and only workflow (at least for now) for simplicity and clarity. We'd only be polling GitHub for status on occasion; we could do this on page view and/or periodically.

@josh-chamberlain Got it! I've updated the comment accordingly!