From ac9bb1db106585f6220918681e7851df1ae119d0 Mon Sep 17 00:00:00 2001 From: Brian Redd Date: Fri, 30 Sep 2016 21:00:31 -0700 Subject: [PATCH] Rename and refactor Twitter History screen to Interface History screen. Add Github queue wait times to Interface History screen --- src/api/github-api.js | 32 +++- src/api/twitter-api.js | 28 ++- src/interface/github-interface.js | 2 +- ...tter-history.css => interface-history.css} | 164 +++++------------- src/public/css/main.css | 2 +- src/public/html/interface-history.html | 131 ++++++++++++++ src/public/html/layout.html | 2 +- src/public/html/twitter-history.html | 87 ---------- src/public/image/github/logo-black-large.png | Bin 0 -> 7157 bytes src/public/image/twitter/mention.png | Bin 0 -> 21214 bytes src/public/javascript/config/route-manager.js | 8 +- .../javascript/controller/app-controller.js | 6 +- src/public/javascript/controller/index.js | 6 +- ...ler.js => interface-history-controller.js} | 44 ++--- .../javascript/controller/login-controller.js | 2 +- src/public/javascript/service/index.js | 3 +- ...service.js => interface-client-service.js} | 37 ++-- src/queue-task/github/github-event-task.js | 19 +- src/queue/base-queue.js | 18 +- src/queue/github-event-queue.js | 4 + test/hub.js | 3 +- .../api/github-api/get-queue-wait-times.js | 58 +++++-- test/test-case/api/twitter-api/callback.js | 2 +- ...y-page-data.js => get-queue-wait-times.js} | 18 +- 24 files changed, 365 insertions(+), 311 deletions(-) rename src/public/css/{twitter-history.css => interface-history.css} (57%) create mode 100755 src/public/html/interface-history.html delete mode 100755 src/public/html/twitter-history.html create mode 100644 src/public/image/github/logo-black-large.png create mode 100644 src/public/image/twitter/mention.png rename src/public/javascript/controller/{twitter-history-controller.js => interface-history-controller.js} (62%) rename src/public/javascript/service/{twitter-client-service.js => interface-client-service.js} (73%) mode change 100755 => 100644 rename src/public/javascript/service/github-client-service.js => test/test-case/api/github-api/get-queue-wait-times.js (51%) rename test/test-case/api/twitter-api/{get-twitter-history-page-data.js => get-queue-wait-times.js} (82%) diff --git a/src/api/github-api.js b/src/api/github-api.js index ce790f9..ea1dd04 100644 --- a/src/api/github-api.js +++ b/src/api/github-api.js @@ -39,6 +39,7 @@ var API = 'github-api'; var CALLBACK = '/callback'; var GET_AUTHENTICATION_DATA = '/getAuthenticationData'; + var GET_QUEUE_WAIT_TIMES = '/getQueueWaitTimes'; var INVALID_SESSION = 'Invalid session'; // Global variables @@ -108,10 +109,10 @@ if (request.session.user.profileImg == 'image/avatar-medium.png') { UserService.setProfileImage('Github', request.session.user, logData, function (updatedUser) { request.session.user = updatedUser; - response.redirect(process.env.AUGEO_HOME + '/twitterHistory'); + response.redirect(process.env.AUGEO_HOME + '/interfaceHistory'); }); } else { - response.redirect(process.env.AUGEO_HOME + '/twitterHistory'); + response.redirect(process.env.AUGEO_HOME + '/interfaceHistory'); } }); }); @@ -162,5 +163,32 @@ } }); + GithubRouter.get(GET_QUEUE_WAIT_TIMES, function(request, response) { + var username = AugeoValidator.isSessionValid(request) ? request.session.user.username : null; + + var rollback = function(message) { + log.functionError(API, GET_QUEUE_WAIT_TIMES, username, message); + response.sendStatus(401); + }; + + if(username) { + log.functionCall(API, GET_QUEUE_WAIT_TIMES, null, username); + var logData = AugeoUtility.formatLogData(API+GET_QUEUE_WAIT_TIMES, username); + + var userId = request.session.user._id; + + var waitTimes = new Array(); + if(request.session.user.github) { + waitTimes.push(QueueService.githubEventQueue.getUserWaitTime(userId, logData)); + } else { + waitTimes.push(QueueService.githubEventQueue.getWaitTime(logData)); + } + + response.status(200).json({waitTimes:waitTimes}); + } else { // If the user doesn't exist in session respond with "Unauthorized" HTTP code + rollback(INVALID_SESSION); + } + }); + module.exports = GithubRouter; diff --git a/src/api/twitter-api.js b/src/api/twitter-api.js index 46d06bb..7582b9f 100755 --- a/src/api/twitter-api.js +++ b/src/api/twitter-api.js @@ -40,7 +40,7 @@ var API = 'twitter-api'; var CALLBACK = '/callback'; var GET_AUTHENTICATION_DATA = '/getAuthenticationData'; - var GET_TWITTER_HISTORY_PAGE_DATA = '/getTwitterHistoryPageData'; + var GET_QUEUE_WAIT_TIMES = '/getQueueWaitTimes'; var INVALID_SESSION = 'Invalid session'; // Global variables @@ -111,7 +111,7 @@ screenName: screenName }; - response.redirect(process.env.AUGEO_HOME + '/twitterHistory'); + response.redirect(process.env.AUGEO_HOME + '/interfaceHistory'); }, rollback); // End updateTwitterInfo }, rollback); // End getTwitterUser @@ -154,35 +154,31 @@ } }); - TwitterRouter.get(GET_TWITTER_HISTORY_PAGE_DATA, function(request, response) { + TwitterRouter.get(GET_QUEUE_WAIT_TIMES, function(request, response) { var username = AugeoValidator.isSessionValid(request) ? request.session.user.username : null; var rollback = function(message) { - log.functionError(API, GET_TWITTER_HISTORY_PAGE_DATA, username, message); + log.functionError(API, GET_QUEUE_WAIT_TIMES, username, message); response.sendStatus(401); }; // If user exists in session get profile data if(username) { - log.functionCall(API, GET_TWITTER_HISTORY_PAGE_DATA, null, username); - var logData = AugeoUtility.formatLogData(API+GET_TWITTER_HISTORY_PAGE_DATA, username); + log.functionCall(API, GET_QUEUE_WAIT_TIMES, null, username); + var logData = AugeoUtility.formatLogData(API+GET_QUEUE_WAIT_TIMES, username); var userId = request.session.user._id; - var pageData = { - mentionWaitTime: '', - tweetWaitTime: '' - }; - + var waitTimes = new Array(); if(request.session.user.twitter) { - pageData.mentionWaitTime = QueueService.mentionEventQueue.getUserWaitTime(userId, logData); - pageData.tweetWaitTime = QueueService.tweetEventQueue.getUserWaitTime(userId, logData); + waitTimes.push(QueueService.tweetEventQueue.getUserWaitTime(userId, logData)); + waitTimes.push(QueueService.mentionEventQueue.getUserWaitTime(userId, logData)); } else { - pageData.mentionWaitTime = QueueService.mentionEventQueue.getWaitTime(logData); - pageData.tweetWaitTime = QueueService.tweetEventQueue.getWaitTime(logData); + waitTimes.push(QueueService.tweetEventQueue.getWaitTime(logData)); + waitTimes.push(QueueService.mentionEventQueue.getWaitTime(logData)); } - response.status(200).json(pageData); + response.status(200).json({waitTimes:waitTimes}); } else { // If the user doesn't exist in session respond with "Unauthorized" HTTP code rollback(INVALID_SESSION); } diff --git a/src/interface/github-interface.js b/src/interface/github-interface.js index eb0718d..12cc0e2 100644 --- a/src/interface/github-interface.js +++ b/src/interface/github-interface.js @@ -112,7 +112,7 @@ if (error) { dnsCheckCount++; if(dnsCheckCount < 2) { - resolveDNS(dnsCheckCount, options, requestToSubmit, errorCallback); + resolveDNS(dnsCheckCount, options, requestToSubmit, callback, errorCallback); } else { errorCallback(error); } diff --git a/src/public/css/twitter-history.css b/src/public/css/interface-history.css similarity index 57% rename from src/public/css/twitter-history.css rename to src/public/css/interface-history.css index 27598ab..0757f8c 100755 --- a/src/public/css/twitter-history.css +++ b/src/public/css/interface-history.css @@ -19,10 +19,10 @@ /***************************************************************************/ /***************************************************************************/ - /* Description: css for twitter-history.html */ + /* Description: css for interface-history.html */ /***************************************************************************/ - #th-auth-container { + #ih-auth-container { height:100%; display:flex; justify-content:center; @@ -30,52 +30,62 @@ margin-bottom:15px; } - #th-auth-inner-container { - height:100%; - border-style:solid; - border-color: #333; - padding:15px; + #ih-head-container { + height:250px; } - .status-container { - margin-top:2%; + .ih-activity { + display:flex; + padding-top:15px; + padding-bottom:15px; } - .text-icon-container { - text-align:center; - margin-top:-3%; + .ih-description { + margin-bottom: 30px; + margin-top:30px; } - .twitter-history-glyphicon { + .ih-glyphicon { display:inline-block; } - .twitter-history-icon { - text-align:center; + .ih-icon { + width:100%; + max-height:200px; + max-width:200px; + } + + .ih-icon-container { + height:100%; + margin:auto; } - .twitter-history-spacer { + .ih-icon-right { + text-align: right; + } + + .ih-spacer { height:inherit; } + .status-container { + margin-top:2%; + } + + .text-icon-container { + text-align:center; + margin-top:-3%; + } + + /***************************************************************************/ /* Screen Size: less than custom small */ /***************************************************************************/ @media(max-width:599px) { - #th-head-container { - height:250px; - margin-left:0px; - } - - #header-description { - font-size:1em; - margin-left:5%; - margin-right:0%; - } - - #th-title { + #ih-title { + margin-bottom:15px; font-size:3em; } @@ -89,19 +99,9 @@ margin-top:0px; } - .tweet-description { - margin-left:80px; - } - - .twitter-history-icon { - text-align:center; - font-size: 9em; - margin-top: 30px; - } - .type-description { text-align:center; - margin-top:43px; + margin:auto; line-height: 1.4; } } @@ -112,14 +112,8 @@ @media(min-width:600px) { - #th-head-container { - height:250px; - margin-left:0px; - } - - #header-description { - margin-left:5%; - margin-right:0%; + #ih-title { + margin-bottom:15px; } .text-icon { @@ -128,93 +122,21 @@ margin-top:0px; } - .tweet-description { - margin-left:80px; - } - - .twitter-history-icon { - text-align:center; - font-size: 12em; - margin-top: 30px; - } - .type-description { text-align:center; - margin-top:43px; + margin:auto; line-height: 1.4; } } - /***************************************************************************/ - /* Screen Size: small */ - /***************************************************************************/ - - @media(min-width:767px) { - - #header-description { - margin-left:5%; - margin-right:0%; - } - - .tweet-description { - margin-left:80px; - } - } - /***************************************************************************/ /* Screen Size: custom medium */ /***************************************************************************/ @media(min-width:850px) { - #header-description { - margin-left:5%; - margin-right:0%; - } - - .tweet-description { - margin-left:55px; - } - - .twitter-history-jumbotron { + .ih-jumbotron { padding-left:0px; padding-right:0px; } } - - /***************************************************************************/ - /* Screen Size: medium */ - /***************************************************************************/ - - @media(min-width:992px) { - - #header-description { - margin-left:5%; - margin-right:0%; - } - - .tweet-description { - margin-left:50px; - } - } - - /***************************************************************************/ - /* Screen Size: large */ - /***************************************************************************/ - - @media(min-width:1200px) { - - #th-head-container { - height:250px; - margin-left:125px; - } - - #header-description { - margin-left:5%; - margin-right:15%; - } - - .tweet-description { - margin-left:0px; - } - } diff --git a/src/public/css/main.css b/src/public/css/main.css index 3318af4..33b17f7 100644 --- a/src/public/css/main.css +++ b/src/public/css/main.css @@ -42,7 +42,7 @@ @import url('./dashboard.css'); @import url('./leaderboard.css'); @import url('./login.css'); - @import url('./twitter-history.css'); + @import url('./interface-history.css'); @import url('./view-activity.css'); /* Directives */ diff --git a/src/public/html/interface-history.html b/src/public/html/interface-history.html new file mode 100755 index 0000000..a83b7b6 --- /dev/null +++ b/src/public/html/interface-history.html @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
Interface History
+
Due to API restrictions, requests can only be made periodically. + When you authenticate with an interface you are placed onto a queue that will gather your past activity. Below + you can see the estimated wait times. +
+
+
+
+
+ + + +
+
+

Authenticate with an interface to start tracking your experience!

+
+ +
+
+
+ +
+
+
+
+ Github +
+
+ Github only records your last 90 days of commits. Therefore, it is possible that we may not retrieve all your Github + activity if you have surpassed this limit. After authentication, Augeo establishes a polling system to retrieve future + commits. Since Augeo can only poll Github once per minute, the time to retrieve future commits will increase proportionally + to the amount of Augeo users that have authenticated with Github. +
+
+
+
+ +
+
+
+ +
+
+
Commits
+
+ A commit is a snapshot of a project. Committing is the process of making a set of tentative changes permanent. +
+
+

All Commits Received

+

{{commitDTO.waitTime}}

+
+
+
+
+ +
+
+
+
+ Twitter +
+
+ Twitter only records your last 3,200 tweets and 800 tweets that you were mentioned in. Therefore, it is possible that + we may not retrieve all your Twitter activity if you have surpassed these limits. After authentication, Augeo establishes + a stream with Twitter that retrieves all future activity in real time. +
+
+
+
+ +
+
+
+
Tweets
+
+ A Tweet is any message posted to Twitter which may contain photos, videos, links and up to 140 characters of text. +
+
+

All Tweets Received

+

{{tweetDTO.waitTime}}

+
+
+
+ +
+
+
+ +
+
+
+ +
+
+
Mentions
+
+ A Mention is any Twitter update that contains "@username" anywhere in the body of the Tweet. +
+
+

All Mentions Received

+

{{mentionDTO.waitTime}}

+
+
+
+
+ diff --git a/src/public/html/layout.html b/src/public/html/layout.html index 9f693f6..8309ac0 100755 --- a/src/public/html/layout.html +++ b/src/public/html/layout.html @@ -54,7 +54,7 @@