{"action":"created","comment":{"url":"https://api.github.com/repos/TEAMMATES/repo/pulls/comments/44623326","id":44623326,"diff_hunk":"@@ -70,31 +75,138 @@ protected ActionResult execute() throws EntityDoesNotExistException{\n //      unless the the page is reloaded with \"?testdata=false\"  or simply reloaded with this parameter omitted.       \n         boolean ifShowTestData = getRequestParamAsBoolean(\"testdata\");\n         \n-        \n-        if (pageChange != null && pageChange.equals(\"true\")) {\n-            //Reset the offset because we are performing a new search, so we start from the beginning of the logs\n-            offset = null;\n-        }\n         if (filterQuery == null) {\n             filterQuery = \"\";\n         }\n         //This is used to parse the filterQuery. If the query is not parsed, the filter function would ignore the query\n         data.generateQueryParameters(filterQuery);\n         \n-        LogQuery query = buildQuery(offset, data);\n-        \n-        List<ActivityLogEntry> logs = getAppLogs(query, data);\n-        \n-        data.init(offset, filterQuery, ifShowAll, ifShowTestData, logs);\n+        List<ActivityLogEntry> logs = null;\n+        if (data.isFromDateSpecifiedInQuery()) {\n+            logs = searchLogsWithExactTimePeriod(data);\n+        } else {\n+            if (!searchTimeOffset.isEmpty()) {\n+                data.setToDate(Long.parseLong(searchTimeOffset));\n+            }\n+            logs = searchLogsWithTimeIncrement(data);\n+        }\n+        generateStatusMessage(data, logs);\n+        data.init(ifShowAll, ifShowTestData, logs);\n         \n-        if (offset == null) {\n+        if (searchTimeOffset.isEmpty()) {\n             return createShowPageResult(Const.ViewURIs.ADMIN_ACTIVITY_LOG, data);\n         }\n         \n         return createAjaxResult(data);\n     }\n     \n-    private LogQuery buildQuery(String offset, AdminActivityLogPageData data) {\n+    private void generateStatusMessage(AdminActivityLogPageData data, List<ActivityLogEntry> logs) {\n+        String status = \"Total Logs gone through in last search: \" + totalLogsSearched + \"<br>\";\n+        status += \"Total Relevant Logs found in last search: \" + logs.size() + \"<br>\";\n+        \n+        long earliestSearchTime = data.getFromDate();\n+        ActivityLogEntry earliestLogChecked = null;\n+        if (!logs.isEmpty()) {\n+            earliestLogChecked = logs.get(logs.size() - 1);\n+        }\n+        //  if the search space is limited to a certain log\n+        if ((logs.size() >= RELEVANT_LOGS_PER_PAGE) && (earliestLogChecked != null)) {\n+            earliestSearchTime = earliestLogChecked.getTime();\n+        }\n+        \n+        double targetTimeZone = Const.DOUBLE_UNINITIALIZED;\n+        if (data.isPersonSpecified()) {\n+            String targetUserGoogleId = data.getPersonSpecified();\n+            targetTimeZone = getLocalTimeZoneForRequest(targetUserGoogleId, \"\");\n+        }\n+        \n+        if (targetTimeZone == Const.DOUBLE_UNINITIALIZED) { // if no person is specified or the person doesn't really exist\n+            if ((logs.size() >= RELEVANT_LOGS_PER_PAGE) && (earliestLogChecked != null)) {\n+                String userGoogleId = earliestLogChecked.getGoogleId();\n+                String userRole = earliestLogChecked.getRole();\n+                targetTimeZone = this.getLocalTimeZoneInfo(userGoogleId, userRole);\n+            } else {\n+                targetTimeZone = Const.SystemParams.ADMIN_TIMZE_ZONE_DOUBLE;\n+            }\n+        }\n+        \n+        double adminTimeZone = Const.SystemParams.ADMIN_TIMZE_ZONE_DOUBLE;\n+        String timeInAdminTimeZone = computeLocalTime(adminTimeZone, String.valueOf(earliestSearchTime));\n+        String timeInUserTimeZone =  computeLocalTime(targetTimeZone, String.valueOf(earliestSearchTime));\n+        status += \"The earliest log entry checked on <b>\" + timeInAdminTimeZone + \"</b> in Admin Time Zone (\" \n+                  + adminTimeZone + \") and \";\n+        if (targetTimeZone != Const.DOUBLE_UNINITIALIZED) {\n+            status += \"on <b>\" + timeInUserTimeZone + \"</b> in Local Time Zone (\" + targetTimeZone + \").<br>\";\n+        } else {\n+            status += timeInUserTimeZone;\n+        }\n+        \n+        // the \"Search More\" button to continue searching from the previous fromDate \n+        status += \"<button class=\\\"btn-link\\\" id=\\\"button_older\\\" onclick=\\\"submitFormAjax(\" + data.getFromDate() + \");\\\">Search More</button>\";\n+        \n+        status += \"<input id=\\\"ifShowAll\\\" type=\\\"hidden\\\" value=\\\"\"+ data.getIfShowAll() +\"\\\"/>\";\n+        status += \"<input id=\\\"ifShowTestData\\\" type=\\\"hidden\\\" value=\\\"\"+ data.getIfShowTestData() +\"\\\"/>\";\n+        \n+        data.setStatusForAjax(status);\n+        statusToUser.add(new StatusMessage(status, StatusMessageColor.INFO));\n+    }\n+\n+    private List<ActivityLogEntry> searchLogsWithTimeIncrement(AdminActivityLogPageData data) {\n+        List<ActivityLogEntry> appLogs = new LinkedList<ActivityLogEntry>();\n+        \n+        int numberOfSearchTimes = 0;\n+        totalLogsSearched = 0;\n+        while ((numberOfSearchTimes < MAX_SEARCH_TIMES) && (appLogs.size() < RELEVANT_LOGS_PER_PAGE)) {\n+            // set fromDate is two-hour away from toDate\n+            long nextTwoHour = data.getToDate() - SEARCH_TIME_INCREMENT;\n+            data.setFromDate(nextTwoHour);\n+            numberOfSearchTimes++;\n+            \n+            LogQuery query = buildQuery(data);\n+            List<ActivityLogEntry> searchResult = searchLogsByQuery(query, data);\n+            if (!searchResult.isEmpty()) {\n+                appLogs.addAll(searchResult);\n+            }\n+            data.setToDate(data.getFromDate());","path":"src/main/java/teammates/ui/controller/AdminActivityLogPageAction.java","position":136,"original_position":136,"commit_id":"5f7f317ac3f459d5fbcbbcc9ec50eed143bdb9e0","original_commit_id":"5f7f317ac3f459d5fbcbbcc9ec50eed143bdb9e0","user":{"login":"thyageshm","id":5160137,"avatar_url":"https://avatars.githubusercontent.com/u/5160137?v=3","gravatar_id":"","url":"https://api.github.com/users/thyageshm","html_url":"https://github.com/thyageshm","followers_url":"https://api.github.com/users/thyageshm/followers","following_url":"https://api.github.com/users/thyageshm/following{/other_user}","gists_url":"https://api.github.com/users/thyageshm/gists{/gist_id}","starred_url":"https://api.github.com/users/thyageshm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thyageshm/subscriptions","organizations_url":"https://api.github.com/users/thyageshm/orgs","repos_url":"https://api.github.com/users/thyageshm/repos","events_url":"https://api.github.com/users/thyageshm/events{/privacy}","received_events_url":"https://api.github.com/users/thyageshm/received_events","type":"User","site_admin":false},"body":"yup :-)","created_at":"2015-11-12T05:45:14Z","updated_at":"2015-11-12T05:45:14Z","html_url":"https://github.com/TEAMMATES/repo/pull/4548#discussion_r44623326","pull_request_url":"https://api.github.com/repos/TEAMMATES/repo/pulls/4548","_links":{"self":{"href":"https://api.github.com/repos/TEAMMATES/repo/pulls/comments/44623326"},"html":{"href":"https://github.com/TEAMMATES/repo/pull/4548#discussion_r44623326"},"pull_request":{"href":"https://api.github.com/repos/TEAMMATES/repo/pulls/4548"}}},"pull_request":{"url":"https://api.github.com/repos/TEAMMATES/repo/pulls/4548","id":49384017,"html_url":"https://github.com/TEAMMATES/repo/pull/4548","diff_url":"https://github.com/TEAMMATES/repo/pull/4548.diff","patch_url":"https://github.com/TEAMMATES/repo/pull/4548.patch","issue_url":"https://api.github.com/repos/TEAMMATES/repo/issues/4548","number":4548,"state":"open","locked":false,"title":"admin activity log: Give a way to search more logs when searching for activities of a user #4511","user":{"login":"bamboo3250","id":8078323,"avatar_url":"https://avatars.githubusercontent.com/u/8078323?v=3","gravatar_id":"","url":"https://api.github.com/users/bamboo3250","html_url":"https://github.com/bamboo3250","followers_url":"https://api.github.com/users/bamboo3250/followers","following_url":"https://api.github.com/users/bamboo3250/following{/other_user}","gists_url":"https://api.github.com/users/bamboo3250/gists{/gist_id}","starred_url":"https://api.github.com/users/bamboo3250/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bamboo3250/subscriptions","organizations_url":"https://api.github.com/users/bamboo3250/orgs","repos_url":"https://api.github.com/users/bamboo3250/repos","events_url":"https://api.github.com/users/bamboo3250/events{/privacy}","received_events_url":"https://api.github.com/users/bamboo3250/received_events","type":"User","site_admin":false},"body":"Fix #4511\r\n\r\nI added one more parameter to the submit form in jsp and javascript to help us keep track the start searching time extended. The start time generated by this function will overwrite the start time in query and it will only be extended by clicking on \"Search More\" but not \"Older Logs\".","created_at":"2015-11-01T23:15:01Z","updated_at":"2015-11-12T05:45:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fe566c833c6a78039952a2d1ff90920d12866d33","assignee":{"login":"thyageshm","id":5160137,"avatar_url":"https://avatars.githubusercontent.com/u/5160137?v=3","gravatar_id":"","url":"https://api.github.com/users/thyageshm","html_url":"https://github.com/thyageshm","followers_url":"https://api.github.com/users/thyageshm/followers","following_url":"https://api.github.com/users/thyageshm/following{/other_user}","gists_url":"https://api.github.com/users/thyageshm/gists{/gist_id}","starred_url":"https://api.github.com/users/thyageshm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thyageshm/subscriptions","organizations_url":"https://api.github.com/users/thyageshm/orgs","repos_url":"https://api.github.com/users/thyageshm/repos","events_url":"https://api.github.com/users/thyageshm/events{/privacy}","received_events_url":"https://api.github.com/users/thyageshm/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/TEAMMATES/repo/pulls/4548/commits","review_comments_url":"https://api.github.com/repos/TEAMMATES/repo/pulls/4548/comments","review_comment_url":"https://api.github.com/repos/TEAMMATES/repo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/TEAMMATES/repo/issues/4548/comments","statuses_url":"https://api.github.com/repos/TEAMMATES/repo/statuses/5f7f317ac3f459d5fbcbbcc9ec50eed143bdb9e0","head":{"label":"TEAMMATES:4511-admin-activity-log-search-more-logs-when-searching-activities-of-user","ref":"4511-admin-activity-log-search-more-logs-when-searching-activities-of-user","sha":"5f7f317ac3f459d5fbcbbcc9ec50eed143bdb9e0","user":{"login":"TEAMMATES","id":7374810,"avatar_url":"https://avatars.githubusercontent.com/u/7374810?v=3","gravatar_id":"","url":"https://api.github.com/users/TEAMMATES","html_url":"https://github.com/TEAMMATES","followers_url":"https://api.github.com/users/TEAMMATES/followers","following_url":"https://api.github.com/users/TEAMMATES/following{/other_user}","gists_url":"https://api.github.com/users/TEAMMATES/gists{/gist_id}","starred_url":"https://api.github.com/users/TEAMMATES/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TEAMMATES/subscriptions","organizations_url":"https://api.github.com/users/TEAMMATES/orgs","repos_url":"https://api.github.com/users/TEAMMATES/repos","events_url":"https://api.github.com/users/TEAMMATES/events{/privacy}","received_events_url":"https://api.github.com/users/TEAMMATES/received_events","type":"Organization","site_admin":false},"repo":{"id":19369035,"name":"repo","full_name":"TEAMMATES/repo","owner":{"login":"TEAMMATES","id":7374810,"avatar_url":"https://avatars.githubusercontent.com/u/7374810?v=3","gravatar_id":"","url":"https://api.github.com/users/TEAMMATES","html_url":"https://github.com/TEAMMATES","followers_url":"https://api.github.com/users/TEAMMATES/followers","following_url":"https://api.github.com/users/TEAMMATES/following{/other_user}","gists_url":"https://api.github.com/users/TEAMMATES/gists{/gist_id}","starred_url":"https://api.github.com/users/TEAMMATES/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TEAMMATES/subscriptions","organizations_url":"https://api.github.com/users/TEAMMATES/orgs","repos_url":"https://api.github.com/users/TEAMMATES/repos","events_url":"https://api.github.com/users/TEAMMATES/events{/privacy}","received_events_url":"https://api.github.com/users/TEAMMATES/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TEAMMATES/repo","description":"This is the project website for the TEAMMATES feedback management tool for education","fork":false,"url":"https://api.github.com/repos/TEAMMATES/repo","forks_url":"https://api.github.com/repos/TEAMMATES/repo/forks","keys_url":"https://api.github.com/repos/TEAMMATES/repo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TEAMMATES/repo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TEAMMATES/repo/teams","hooks_url":"https://api.github.com/repos/TEAMMATES/repo/hooks","issue_events_url":"https://api.github.com/repos/TEAMMATES/repo/issues/events{/number}","events_url":"https://api.github.com/repos/TEAMMATES/repo/events","assignees_url":"https://api.github.com/repos/TEAMMATES/repo/assignees{/user}","branches_url":"https://api.github.com/repos/TEAMMATES/repo/branches{/branch}","tags_url":"https://api.github.com/repos/TEAMMATES/repo/tags","blobs_url":"https://api.github.com/repos/TEAMMATES/repo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TEAMMATES/repo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TEAMMATES/repo/git/refs{/sha}","trees_url":"https://api.github.com/repos/TEAMMATES/repo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TEAMMATES/repo/statuses/{sha}","languages_url":"https://api.github.com/repos/TEAMMATES/repo/languages","stargazers_url":"https://api.github.com/repos/TEAMMATES/repo/stargazers","contributors_url":"https://api.github.com/repos/TEAMMATES/repo/contributors","subscribers_url":"https://api.github.com/repos/TEAMMATES/repo/subscribers","subscription_url":"https://api.github.com/repos/TEAMMATES/repo/subscription","commits_url":"https://api.github.com/repos/TEAMMATES/repo/commits{/sha}","git_commits_url":"https://api.github.com/repos/TEAMMATES/repo/git/commits{/sha}","comments_url":"https://api.github.com/repos/TEAMMATES/repo/comments{/number}","issue_comment_url":"https://api.github.com/repos/TEAMMATES/repo/issues/comments{/number}","contents_url":"https://api.github.com/repos/TEAMMATES/repo/contents/{+path}","compare_url":"https://api.github.com/repos/TEAMMATES/repo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TEAMMATES/repo/merges","archive_url":"https://api.github.com/repos/TEAMMATES/repo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TEAMMATES/repo/downloads","issues_url":"https://api.github.com/repos/TEAMMATES/repo/issues{/number}","pulls_url":"https://api.github.com/repos/TEAMMATES/repo/pulls{/number}","milestones_url":"https://api.github.com/repos/TEAMMATES/repo/milestones{/number}","notifications_url":"https://api.github.com/repos/TEAMMATES/repo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TEAMMATES/repo/labels{/name}","releases_url":"https://api.github.com/repos/TEAMMATES/repo/releases{/id}","created_at":"2014-05-02T07:43:00Z","updated_at":"2015-11-11T20:50:06Z","pushed_at":"2015-11-11T06:00:36Z","git_url":"git://github.com/TEAMMATES/repo.git","ssh_url":"git@github.com:TEAMMATES/repo.git","clone_url":"https://github.com/TEAMMATES/repo.git","svn_url":"https://github.com/TEAMMATES/repo","homepage":"http://teammatesv4.appspot.com/","size":164693,"stargazers_count":55,"watchers_count":55,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":132,"mirror_url":null,"open_issues_count":522,"forks":132,"open_issues":522,"watchers":55,"default_branch":"master"}},"base":{"label":"TEAMMATES:master","ref":"master","sha":"eacd984e88dcbae6559206e2a92970eddd8e4fc1","user":{"login":"TEAMMATES","id":7374810,"avatar_url":"https://avatars.githubusercontent.com/u/7374810?v=3","gravatar_id":"","url":"https://api.github.com/users/TEAMMATES","html_url":"https://github.com/TEAMMATES","followers_url":"https://api.github.com/users/TEAMMATES/followers","following_url":"https://api.github.com/users/TEAMMATES/following{/other_user}","gists_url":"https://api.github.com/users/TEAMMATES/gists{/gist_id}","starred_url":"https://api.github.com/users/TEAMMATES/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TEAMMATES/subscriptions","organizations_url":"https://api.github.com/users/TEAMMATES/orgs","repos_url":"https://api.github.com/users/TEAMMATES/repos","events_url":"https://api.github.com/users/TEAMMATES/events{/privacy}","received_events_url":"https://api.github.com/users/TEAMMATES/received_events","type":"Organization","site_admin":false},"repo":{"id":19369035,"name":"repo","full_name":"TEAMMATES/repo","owner":{"login":"TEAMMATES","id":7374810,"avatar_url":"https://avatars.githubusercontent.com/u/7374810?v=3","gravatar_id":"","url":"https://api.github.com/users/TEAMMATES","html_url":"https://github.com/TEAMMATES","followers_url":"https://api.github.com/users/TEAMMATES/followers","following_url":"https://api.github.com/users/TEAMMATES/following{/other_user}","gists_url":"https://api.github.com/users/TEAMMATES/gists{/gist_id}","starred_url":"https://api.github.com/users/TEAMMATES/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TEAMMATES/subscriptions","organizations_url":"https://api.github.com/users/TEAMMATES/orgs","repos_url":"https://api.github.com/users/TEAMMATES/repos","events_url":"https://api.github.com/users/TEAMMATES/events{/privacy}","received_events_url":"https://api.github.com/users/TEAMMATES/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TEAMMATES/repo","description":"This is the project website for the TEAMMATES feedback management tool for education","fork":false,"url":"https://api.github.com/repos/TEAMMATES/repo","forks_url":"https://api.github.com/repos/TEAMMATES/repo/forks","keys_url":"https://api.github.com/repos/TEAMMATES/repo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TEAMMATES/repo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TEAMMATES/repo/teams","hooks_url":"https://api.github.com/repos/TEAMMATES/repo/hooks","issue_events_url":"https://api.github.com/repos/TEAMMATES/repo/issues/events{/number}","events_url":"https://api.github.com/repos/TEAMMATES/repo/events","assignees_url":"https://api.github.com/repos/TEAMMATES/repo/assignees{/user}","branches_url":"https://api.github.com/repos/TEAMMATES/repo/branches{/branch}","tags_url":"https://api.github.com/repos/TEAMMATES/repo/tags","blobs_url":"https://api.github.com/repos/TEAMMATES/repo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TEAMMATES/repo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TEAMMATES/repo/git/refs{/sha}","trees_url":"https://api.github.com/repos/TEAMMATES/repo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TEAMMATES/repo/statuses/{sha}","languages_url":"https://api.github.com/repos/TEAMMATES/repo/languages","stargazers_url":"https://api.github.com/repos/TEAMMATES/repo/stargazers","contributors_url":"https://api.github.com/repos/TEAMMATES/repo/contributors","subscribers_url":"https://api.github.com/repos/TEAMMATES/repo/subscribers","subscription_url":"https://api.github.com/repos/TEAMMATES/repo/subscription","commits_url":"https://api.github.com/repos/TEAMMATES/repo/commits{/sha}","git_commits_url":"https://api.github.com/repos/TEAMMATES/repo/git/commits{/sha}","comments_url":"https://api.github.com/repos/TEAMMATES/repo/comments{/number}","issue_comment_url":"https://api.github.com/repos/TEAMMATES/repo/issues/comments{/number}","contents_url":"https://api.github.com/repos/TEAMMATES/repo/contents/{+path}","compare_url":"https://api.github.com/repos/TEAMMATES/repo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TEAMMATES/repo/merges","archive_url":"https://api.github.com/repos/TEAMMATES/repo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TEAMMATES/repo/downloads","issues_url":"https://api.github.com/repos/TEAMMATES/repo/issues{/number}","pulls_url":"https://api.github.com/repos/TEAMMATES/repo/pulls{/number}","milestones_url":"https://api.github.com/repos/TEAMMATES/repo/milestones{/number}","notifications_url":"https://api.github.com/repos/TEAMMATES/repo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TEAMMATES/repo/labels{/name}","releases_url":"https://api.github.com/repos/TEAMMATES/repo/releases{/id}","created_at":"2014-05-02T07:43:00Z","updated_at":"2015-11-11T20:50:06Z","pushed_at":"2015-11-11T06:00:36Z","git_url":"git://github.com/TEAMMATES/repo.git","ssh_url":"git@github.com:TEAMMATES/repo.git","clone_url":"https://github.com/TEAMMATES/repo.git","svn_url":"https://github.com/TEAMMATES/repo","homepage":"http://teammatesv4.appspot.com/","size":164693,"stargazers_count":55,"watchers_count":55,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":132,"mirror_url":null,"open_issues_count":522,"forks":132,"open_issues":522,"watchers":55,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/TEAMMATES/repo/pulls/4548"},"html":{"href":"https://github.com/TEAMMATES/repo/pull/4548"},"issue":{"href":"https://api.github.com/repos/TEAMMATES/repo/issues/4548"},"comments":{"href":"https://api.github.com/repos/TEAMMATES/repo/issues/4548/comments"},"review_comments":{"href":"https://api.github.com/repos/TEAMMATES/repo/pulls/4548/comments"},"review_comment":{"href":"https://api.github.com/repos/TEAMMATES/repo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/TEAMMATES/repo/pulls/4548/commits"},"statuses":{"href":"https://api.github.com/repos/TEAMMATES/repo/statuses/5f7f317ac3f459d5fbcbbcc9ec50eed143bdb9e0"}}}}