Skip to content

Commit

Permalink
Serve a static list of labels instead of requesting them from GitHub, f…
Browse files Browse the repository at this point in the history
…ixes #781
  • Loading branch information
Hallvord R. M. Steen committed Oct 27, 2015
1 parent 92991bf commit 344b277
Show file tree
Hide file tree
Showing 2 changed files with 185 additions and 8 deletions.
11 changes: 3 additions & 8 deletions webcompat/api/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from webcompat.helpers import get_headers
from webcompat.helpers import get_request_headers
from webcompat.helpers import normalize_api_params
from webcompat.helpers import STATIC_PATH
from webcompat.issues import filter_new
from webcompat.issues import proxy_request

Expand Down Expand Up @@ -264,14 +265,8 @@ def modify_labels(number):
def get_repo_labels():
'''XHR endpoint to get all possible labels in a repo.
'''
request_headers = get_request_headers(g.request_headers)
if g.user:
path = 'repos/{0}/labels'.format(REPO_PATH)
labels = github.raw_request('GET', path, headers=request_headers)
else:
path = 'https://api.github.com/repos/{0}/labels'.format(REPO_PATH)
labels = proxy_request('get', uri=path, headers=request_headers)
return (labels.content, labels.status_code, get_headers(labels))
with open( STATIC_PATH + '/config_data/labels.json') as f:
return (f.read(), 200, {'content-type': 'application/json'})


@api.route('/rate_limit')
Expand Down
182 changes: 182 additions & 0 deletions webcompat/static/config_data/labels.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
[
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/status-duplicate",
"name": "status-duplicate",
"color": "cccccc"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/status-invalid",
"name": "status-invalid",
"color": "e6e6e6"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/status-wontfix",
"name": "status-wontfix",
"color": "000000"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/status-needsinfo",
"name": "status-needsinfo",
"color": "fbca04"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/browser-chrome",
"name": "browser-chrome",
"color": "F16A5A"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/browser-firefox",
"name": "browser-firefox",
"color": "FF4E00"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/browser-ie",
"name": "browser-ie",
"color": "00B9EC"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/browser-opera",
"name": "browser-opera",
"color": "AC090A"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/browser-safari",
"name": "browser-safari",
"color": "1B9BF6"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/browser-android",
"name": "browser-android",
"color": "28ACBB"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/mobile",
"name": "mobile",
"color": "009800"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/status-contactready",
"name": "status-contactready",
"color": "A1EBBF"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/status-sitewait",
"name": "status-sitewait",
"color": "006b75"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/ios",
"name": "ios",
"color": "0bd318"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/browser-iceweasel",
"name": "browser-iceweasel",
"color": "0052cc"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/browser-ucweb",
"name": "browser-ucweb",
"color": "f7c6c7"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/status-fixed",
"name": "status-fixed",
"color": "009800"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/status-imported",
"name": "status-imported",
"color": "5319e7"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/status-worksforme",
"name": "status-worksforme",
"color": "d4c5f9"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/status-needsdiagnosis",
"name": "status-needsdiagnosis",
"color": "FF8364"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/browser-ie11",
"name": "browser-ie11",
"color": "ededed"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/browser-chromium",
"name": "browser-chromium",
"color": "ededed"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/status-needscontact",
"name": "status-needscontact",
"color": "e11d21"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/browser-all",
"name": "browser-all",
"color": "ededed"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/browser-vivaldi",
"name": "browser-vivaldi",
"color": "ededed"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/browser-midori",
"name": "browser-midori",
"color": "ededed"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/windows",
"name": "windows",
"color": "ededed"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/browser-seamonkey",
"name": "browser-seamonkey",
"color": "ededed"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/browser-lynx",
"name": "browser-lynx",
"color": "ededed"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/browser-blackberry",
"name": "browser-blackberry",
"color": "ededed"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/browser-firefox-mobile",
"name": "browser-firefox-mobile",
"color": "fbca04"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/os-android",
"name": "os-android",
"color": "ededed"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/browser-edge",
"name": "browser-edge",
"color": "fef2c0"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/status-ie-bugbar",
"name": "status-ie-bugbar",
"color": "bfdadc"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/browser-chrome-mobile",
"name": "browser-chrome-mobile",
"color": "ededed"
},
{
"url": "https://api.github.com/repos/webcompat/web-bugs/labels/browser-uc-browser",
"name": "browser-uc-browser",
"color": "ededed"
}
]

0 comments on commit 344b277

Please sign in to comment.