internetarchive / openlibrary

One webpage for every book ever published!

Home Page:https://openlibrary.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Team Page: Show current project on cards

mekarpeles opened this issue · comments

commented

Problem

On https://openlibrary.org/about/team

Powered by
https://github.com/internetarchive/openlibrary/blob/master/openlibrary/plugins/openlibrary/js/team.js

We want to be able to see what primary / main project each contributor is working on.

Thus, we need to develop a cached python backend endpoint for something like e.g. /api/team/now.json which will use python to query github API for Open Library for all issues that have a Primary Focus label set https://github.com/internetarchive/openlibrary/issues?q=is%3Aopen+is%3Aissue+label%3A%22Primary+Focus%22 and then cache the result by assignee for 1 day.

e.g.

[{'@mekarpeles': {'issue': '1234', 'title': '...'}, ...}]

On our team page, each person should have a github id set, so when the team page loads, we should be able to fetch this data and then update the team page so that when it loads, this data is used to augment and enhance each card with a link to the projects contributors are working on.

This code has been prototyped here:
https://colab.research.google.com/drive/1tPO-4ZU8Vfq2CrnuhUscF5724SsrxDLr?authuser=1#scrollTo=ekU0AzueBZtj

import json
import requests

def get_primary_focuses():
  params = {
    "state": "open",
    "labels": "Primary Focus"
  }
  url = f"https://api.github.com/repos/internetarchive/openlibrary/issues"
  response = requests.get(url, params=params, headers={"Accept": "application/vnd.github.v3+json"})
  return [{
      "assignee": issue['assignee']['login'] if issue['assignee'] else None,
      "title": issue['title'],
      "issue_number": issue['number']
    } for issue in response.json()] if response.status_code == 200 else []

print(json.dumps(get_primary_focuses(), indent=4))

Additional Context

Proposal & Constraints

What is the proposed solution / implementation?

Is there a precedent of this approach succeeding elsewhere?

Which suggestions or requirements should be considered for how feature needs to appear or be implemented?

Leads

Related files

Stakeholders

Note: Before making a new branch or updating an existing one, please ensure your branch is up to date.