rmit-programming-club / network-vis

A tool to visualisation coding activity and collaboration within a Github Organisation
GNU General Public License v3.0
9 stars 2 forks source link

Organisation/User Scoped routes AND new models #29

Closed thundergolfer closed 7 years ago

thundergolfer commented 7 years ago

Description

Ok, this is a big pull request so I'll do a long explanation

The Routes

This work intends to improve UI of our URLs. Before we just had /graph/network and /organisation endpoints, which were hacky.

Now we have a flexible route schema /profile/<<organization_name>>/<<username>> which will allow us to present data at either the organisation level eg. /profile/my-organisation or the the organisation member level eg. /profile/my-organisation/member-one

At the moment these endpoints just return json which is better for development purposes, but eventually they should be text/html endpoints returning a view. Currently going to /profile/my-organisation/<<username>> will tell you whether that username is in the organisation or not. like this:

{
  "you entered in": "Johnny",
  "who is missing from": "rmit-programming-club"
}

The models

So far working with data in this project has been a pain because we haven't been storing the data we pull from Github's API. For complex network visualisations, we are making a number of API calls, and when I do it against the github.com/Zendesk organisation it takes fucking ages.

In this PR I've introduced models that should be able to handle all the core analytics we are interested in running. From now on when we want data, we should check our own DB first and if it's missing we then pull from the API and store it. Here are some of the important data access patterns we can now use:

org = Organization.find_by_name("Zendesk") 
org.members.all # list of User records representing the members of "Zendesk" organisation
org.repositories
org.events

user = User.find_by_username("thundergolfer")
user.repositories
user.events
user.followers
user.following
user.organizations

repo = Repository.find_by_url("https://github.com/rmit-programming-club/network-vis")
repo.contributors.all # list of people who've worked on the project
repo.events 
repo.owner # can be a user OR an organization