From 887b31cfaa8b20089bcd89c80646e53cf63a2d5a Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman Date: Thu, 1 Sep 2016 10:39:39 -0400 Subject: [PATCH] nocache flag --- controller/action/ContentActions.class.php | 5 +++-- model/api/Asana.class.php | 15 ++++++++------- model/api/Github.class.php | 8 ++++---- view/template/content/roadmap.php | 2 +- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/controller/action/ContentActions.class.php b/controller/action/ContentActions.class.php index 307b513c..48b865f6 100644 --- a/controller/action/ContentActions.class.php +++ b/controller/action/ContentActions.class.php @@ -116,7 +116,8 @@ class ContentActions extends Actions public static function executeRoadmap() { - $githubItems = Github::listRoadmapChangesets(); + $cache = !isset($_GET['nocache']); + $githubItems = Github::listRoadmapChangesets($cache); $projectMaxVersions = []; $closedGroups = []; @@ -133,7 +134,7 @@ class ContentActions extends Actions } } - $items = array_merge($githubItems, Asana::listRoadmapTasks()); + $items = array_merge($githubItems, Asana::listRoadmapTasks($cache)); return ['content/roadmap', [ 'projectMaxVersions' => $projectMaxVersions, 'items' => $items diff --git a/model/api/Asana.class.php b/model/api/Asana.class.php index 223b6073..cb55de93 100644 --- a/model/api/Asana.class.php +++ b/model/api/Asana.class.php @@ -4,7 +4,7 @@ class Asana { protected static $curlOptions = ['json_response' => true, 'cache' => true]; - public static function listRoadmapTasks() + public static function listRoadmapTasks($cache = true) { /* * return static::get('/projects'); @@ -54,7 +54,7 @@ class Asana // return static::get('/projects'); $projects = [ 158602294500138 => ['LBRY Browser', 'https://github.com/lbryio/lbry-web-ui'], - 158602294500137 => ['LBRYnet', 'https://github.com/lbryio/lbry'], + 158602294500137 => ['LBRY Data Network', 'https://github.com/lbryio/lbry'], 161514803479899 => ['Blockchain and Wallets', 'https://github.com/lbryio/lbrycrd'], 136290697597644 => ['Integration and Building', null], 158602294500249 => ['Documentation', null], @@ -66,7 +66,7 @@ class Asana foreach($projects as $projectId => $projectTuple) { list($projectName, $projectUrl) = $projectTuple; - $projectTasks = static::get('/tasks?' . http_build_query(['completed_since' => 'now', 'project' => $projectId])); + $projectTasks = static::get('/tasks', ['completed_since' => 'now', 'project' => $projectId], $cache); $group = null; foreach ($projectTasks as $task) { @@ -111,13 +111,14 @@ class Asana return $tasks; } - protected static function get($endpoint, array $data = []) + protected static function get($endpoint, array $data = [], $cache = true) { $apiKey = Config::get('asana_key'); - $options = static::$curlOptions + [ - 'headers' => ['Authorization: Bearer ' . $apiKey] - ]; + $options = [ + 'headers' => ['Authorization: Bearer ' . $apiKey], + 'cache' => $cache + ] + static::$curlOptions; $responseData = Curl::get('https://app.asana.com/api/1.0' . $endpoint, $data, $options); return isset($responseData['data']) ? $responseData['data'] : []; diff --git a/model/api/Github.class.php b/model/api/Github.class.php index 75179951..1ff2da84 100644 --- a/model/api/Github.class.php +++ b/model/api/Github.class.php @@ -30,12 +30,12 @@ class Github return null; } - public static function get($endpoint) + public static function get($endpoint, $cache = true) { - return Curl::get('https://api.github.com' . $endpoint, [], ['user_agent' => 'LBRY', 'json_response' => true, 'cache' => true]); + return Curl::get('https://api.github.com' . $endpoint, [], ['user_agent' => 'LBRY', 'json_response' => true, 'cache' => $cache]); } - public static function listRoadmapChangesets() + public static function listRoadmapChangesets($cache = true) { $sets = []; $allReleases = []; @@ -52,7 +52,7 @@ class Github $page = 1; do { - $releases = static::get('/repos/lbryio/' . $project . '/releases?page=' . $page); + $releases = static::get('/repos/lbryio/' . $project . '/releases?page=' . $page, $cache); $page++; $allReleases = array_merge($allReleases, array_map(function($release) use($label, $project) { return $release + ['project_label' => $label, 'project' => $project]; diff --git a/view/template/content/roadmap.php b/view/template/content/roadmap.php index f0fda136..2324502f 100644 --- a/view/template/content/roadmap.php +++ b/view/template/content/roadmap.php @@ -1,4 +1,4 @@ - + false]) ?>