From 344b2774cec25a438403075b09187c32a476b65f Mon Sep 17 00:00:00 2001 From: "Hallvord R. M. Steen" Date: Tue, 27 Oct 2015 22:32:51 +0100 Subject: [PATCH] Serve a static list of labels instead of requesting them from GitHub, fixes #781 --- webcompat/api/endpoints.py | 11 +- webcompat/static/config_data/labels.json | 182 +++++++++++++++++++++++ 2 files changed, 185 insertions(+), 8 deletions(-) create mode 100644 webcompat/static/config_data/labels.json diff --git a/webcompat/api/endpoints.py b/webcompat/api/endpoints.py index c92b6b037..62291f6f4 100644 --- a/webcompat/api/endpoints.py +++ b/webcompat/api/endpoints.py @@ -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 @@ -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') diff --git a/webcompat/static/config_data/labels.json b/webcompat/static/config_data/labels.json new file mode 100644 index 000000000..c1059f153 --- /dev/null +++ b/webcompat/static/config_data/labels.json @@ -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" + } +]