{"action":"created","comment":{"url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/pulls/comments/37098720","id":37098720,"diff_hunk":"@@ -74,32 +84,121 @@ protected void doGet(HttpServletRequest request,HttpServletResponse response){\n \t\t}\n \t\t\n \t}\n+\n+\tprivate void checkIfACourseReportThreadIsDone(HttpServletRequest request,HttpServletResponse response) {\n+\t\tM_log.debug(\"Starting polling... Thread size: \"+courseReportReqThreads.size());\n+\t\ttry {\n+\t\t\tString thrdId = request.getParameter(THREAD_ID);\n+\t\t\tlong threadId = Long.parseLong(thrdId);\n+\t\t\tKeySetView<Thread, CourseReportTask> keySet = courseReportReqThreads.keySet();\n+\t\t\tfor (Thread aCourseReportThread : keySet) {\n+\t\t\t\tif(aCourseReportThread.getId()==threadId) {\n+\t\t\t\t\tcheckIfThreadAlive(response, aCourseReportThread);\n+\t\t\t\t\tbreak;\n+\t\t\t\t}\n+\n+\t\t\t}\n+\t\t} catch (IOException e) {\n+\t\t\tM_log.debug(\"IOException occoured in checkIfACourseReportThreadIsDone()\"+e);\n+\t\t\tresponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);\n+\t\t\ttry {\n+\t\t\t\tresponse.getWriter().print(props.getString(\"report.generation.err.msg\"));\n+\t\t\t} catch (IOException e1) {\n+\t\t\t\tM_log.error(\"IOException occurred while writing the response out\",e1);\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\n+\tprivate void checkIfThreadAlive(HttpServletResponse response, Thread aCourseReportThread)\n+\t\t\tthrows IOException {\n+\t\tOutputStream outputStream = response.getOutputStream();\n+\t\tif(aCourseReportThread.isAlive()) {\n+\t\t\toutputStream.write(WORKING.getBytes());\n+\t\t\toutputStream.flush();\n+\t\t\toutputStream.close();\n+\t\t}else {\n+\t\t\tafterActionThreadIsDone(response, aCourseReportThread, outputStream);\n+\t\t}\n+\t}\n+\n+\n+\tprivate void afterActionThreadIsDone(HttpServletResponse response, Thread aCourseReportThread,\n+\t\t\tOutputStream outputStream)\n+\t\t\t\t\tthrows IOException {\n+\t\tCourseReportTask courseReportTask = courseReportReqThreads.get(aCourseReportThread);\n+\t\tCoursesForSubaccounts cfs = courseReportTask.cfs;\n+\t\tif(cfs.subaccountCallHasErr || cfs.courseCallHasErr ) {\n+\t\t\tcourseReportReqThreads.remove(aCourseReportThread);\n+\t\t\tresponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);\n+\t\t\toutputStream.write(props.getString(\"report.generation.err.msg\").getBytes());\n+\t\t\tM_log.debug(\"Ending polling... Thread size: \"+courseReportReqThreads.size());\n+\t\t}else {\n+\t\t\tresponse.setContentType(\"text/csv\");\n+\t\t\tresponse.setHeader(\"Content-Disposition\",\"attachment;filename=PublishedCanvasCoursesWithInstructorsFor\"+courseReportTask.termName+\".csv\");\n+\t\t\tString outputResult = generateCSVFile(cfs).toString();\n+\t\t\tcourseReportReqThreads.remove(aCourseReportThread);\n+\t\t\toutputStream.write(outputResult.getBytes());\n+\t\t\toutputStream.flush();\n+\t\t\toutputStream.close();\n+\t\t\tM_log.debug(\"Ending polling... Thread size: \"+courseReportReqThreads.size());","path":"src/main/java/edu/umich/tl/analytics/CanvasCourseReportServlet.java","position":119,"original_position":119,"commit_id":"26edae34b0d42db09e9fd4fd116aff62d81e4622","original_commit_id":"26edae34b0d42db09e9fd4fd116aff62d81e4622","user":{"login":"pushyamig","id":8579775,"avatar_url":"https://avatars.githubusercontent.com/u/8579775?v=3","gravatar_id":"","url":"https://api.github.com/users/pushyamig","html_url":"https://github.com/pushyamig","followers_url":"https://api.github.com/users/pushyamig/followers","following_url":"https://api.github.com/users/pushyamig/following{/other_user}","gists_url":"https://api.github.com/users/pushyamig/gists{/gist_id}","starred_url":"https://api.github.com/users/pushyamig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pushyamig/subscriptions","organizations_url":"https://api.github.com/users/pushyamig/orgs","repos_url":"https://api.github.com/users/pushyamig/repos","events_url":"https://api.github.com/users/pushyamig/events{/privacy}","received_events_url":"https://api.github.com/users/pushyamig/received_events","type":"User","site_admin":false},"body":"Done","created_at":"2015-08-14T17:29:31Z","updated_at":"2015-08-14T17:29:31Z","html_url":"https://github.com/tl-its-umich-edu/canvas_courses_report/pull/6#discussion_r37098720","pull_request_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/pulls/comments/37098720"},"html":{"href":"https://github.com/tl-its-umich-edu/canvas_courses_report/pull/6#discussion_r37098720"},"pull_request":{"href":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/pulls/6","id":42452661,"html_url":"https://github.com/tl-its-umich-edu/canvas_courses_report/pull/6","diff_url":"https://github.com/tl-its-umich-edu/canvas_courses_report/pull/6.diff","patch_url":"https://github.com/tl-its-umich-edu/canvas_courses_report/pull/6.patch","issue_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/issues/6","number":6,"state":"open","locked":false,"title":"TLUNIZIN-661 fixing the browser time out issue with large reports","user":{"login":"pushyamig","id":8579775,"avatar_url":"https://avatars.githubusercontent.com/u/8579775?v=3","gravatar_id":"","url":"https://api.github.com/users/pushyamig","html_url":"https://github.com/pushyamig","followers_url":"https://api.github.com/users/pushyamig/followers","following_url":"https://api.github.com/users/pushyamig/following{/other_user}","gists_url":"https://api.github.com/users/pushyamig/gists{/gist_id}","starred_url":"https://api.github.com/users/pushyamig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pushyamig/subscriptions","organizations_url":"https://api.github.com/users/pushyamig/orgs","repos_url":"https://api.github.com/users/pushyamig/repos","events_url":"https://api.github.com/users/pushyamig/events{/privacy}","received_events_url":"https://api.github.com/users/pushyamig/received_events","type":"User","site_admin":false},"body":"The Application flow is the user select a term and the expected out come is a report in .csv format that has list of courses for that particular time. The issue is with large course list browser times out when the server is working hard to generate the report. The idea implemented here is putting the report generating call on a separate thread and let the through javascript polling checking if the issue job is done. If done will present the user with a downloadable file from the browser","created_at":"2015-08-14T12:53:48Z","updated_at":"2015-08-14T17:29:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f53aed7bd53a4ed333b23a5b1a4d43aaa90ffa38","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/pulls/6/commits","review_comments_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/pulls/6/comments","review_comment_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/issues/6/comments","statuses_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/statuses/26edae34b0d42db09e9fd4fd116aff62d81e4622","head":{"label":"tl-its-umich-edu:TLUNIZIN-661","ref":"TLUNIZIN-661","sha":"26edae34b0d42db09e9fd4fd116aff62d81e4622","user":{"login":"tl-its-umich-edu","id":8292960,"avatar_url":"https://avatars.githubusercontent.com/u/8292960?v=3","gravatar_id":"","url":"https://api.github.com/users/tl-its-umich-edu","html_url":"https://github.com/tl-its-umich-edu","followers_url":"https://api.github.com/users/tl-its-umich-edu/followers","following_url":"https://api.github.com/users/tl-its-umich-edu/following{/other_user}","gists_url":"https://api.github.com/users/tl-its-umich-edu/gists{/gist_id}","starred_url":"https://api.github.com/users/tl-its-umich-edu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tl-its-umich-edu/subscriptions","organizations_url":"https://api.github.com/users/tl-its-umich-edu/orgs","repos_url":"https://api.github.com/users/tl-its-umich-edu/repos","events_url":"https://api.github.com/users/tl-its-umich-edu/events{/privacy}","received_events_url":"https://api.github.com/users/tl-its-umich-edu/received_events","type":"Organization","site_admin":false},"repo":{"id":39967587,"name":"canvas_courses_report","full_name":"tl-its-umich-edu/canvas_courses_report","owner":{"login":"tl-its-umich-edu","id":8292960,"avatar_url":"https://avatars.githubusercontent.com/u/8292960?v=3","gravatar_id":"","url":"https://api.github.com/users/tl-its-umich-edu","html_url":"https://github.com/tl-its-umich-edu","followers_url":"https://api.github.com/users/tl-its-umich-edu/followers","following_url":"https://api.github.com/users/tl-its-umich-edu/following{/other_user}","gists_url":"https://api.github.com/users/tl-its-umich-edu/gists{/gist_id}","starred_url":"https://api.github.com/users/tl-its-umich-edu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tl-its-umich-edu/subscriptions","organizations_url":"https://api.github.com/users/tl-its-umich-edu/orgs","repos_url":"https://api.github.com/users/tl-its-umich-edu/repos","events_url":"https://api.github.com/users/tl-its-umich-edu/events{/privacy}","received_events_url":"https://api.github.com/users/tl-its-umich-edu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tl-its-umich-edu/canvas_courses_report","description":"","fork":false,"url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report","forks_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/forks","keys_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/teams","hooks_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/hooks","issue_events_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/issues/events{/number}","events_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/events","assignees_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/assignees{/user}","branches_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/branches{/branch}","tags_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/tags","blobs_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/git/refs{/sha}","trees_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/statuses/{sha}","languages_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/languages","stargazers_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/stargazers","contributors_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/contributors","subscribers_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/subscribers","subscription_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/subscription","commits_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/commits{/sha}","git_commits_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/git/commits{/sha}","comments_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/comments{/number}","issue_comment_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/issues/comments{/number}","contents_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/contents/{+path}","compare_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/merges","archive_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/downloads","issues_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/issues{/number}","pulls_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/pulls{/number}","milestones_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/milestones{/number}","notifications_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/labels{/name}","releases_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/releases{/id}","created_at":"2015-07-30T19:04:11Z","updated_at":"2015-08-11T12:26:36Z","pushed_at":"2015-08-14T17:02:46Z","git_url":"git://github.com/tl-its-umich-edu/canvas_courses_report.git","ssh_url":"git@github.com:tl-its-umich-edu/canvas_courses_report.git","clone_url":"https://github.com/tl-its-umich-edu/canvas_courses_report.git","svn_url":"https://github.com/tl-its-umich-edu/canvas_courses_report","homepage":null,"size":312,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"tl-its-umich-edu:master","ref":"master","sha":"044cd189b90c6b290fd5535bfc77a2753e561af5","user":{"login":"tl-its-umich-edu","id":8292960,"avatar_url":"https://avatars.githubusercontent.com/u/8292960?v=3","gravatar_id":"","url":"https://api.github.com/users/tl-its-umich-edu","html_url":"https://github.com/tl-its-umich-edu","followers_url":"https://api.github.com/users/tl-its-umich-edu/followers","following_url":"https://api.github.com/users/tl-its-umich-edu/following{/other_user}","gists_url":"https://api.github.com/users/tl-its-umich-edu/gists{/gist_id}","starred_url":"https://api.github.com/users/tl-its-umich-edu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tl-its-umich-edu/subscriptions","organizations_url":"https://api.github.com/users/tl-its-umich-edu/orgs","repos_url":"https://api.github.com/users/tl-its-umich-edu/repos","events_url":"https://api.github.com/users/tl-its-umich-edu/events{/privacy}","received_events_url":"https://api.github.com/users/tl-its-umich-edu/received_events","type":"Organization","site_admin":false},"repo":{"id":39967587,"name":"canvas_courses_report","full_name":"tl-its-umich-edu/canvas_courses_report","owner":{"login":"tl-its-umich-edu","id":8292960,"avatar_url":"https://avatars.githubusercontent.com/u/8292960?v=3","gravatar_id":"","url":"https://api.github.com/users/tl-its-umich-edu","html_url":"https://github.com/tl-its-umich-edu","followers_url":"https://api.github.com/users/tl-its-umich-edu/followers","following_url":"https://api.github.com/users/tl-its-umich-edu/following{/other_user}","gists_url":"https://api.github.com/users/tl-its-umich-edu/gists{/gist_id}","starred_url":"https://api.github.com/users/tl-its-umich-edu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tl-its-umich-edu/subscriptions","organizations_url":"https://api.github.com/users/tl-its-umich-edu/orgs","repos_url":"https://api.github.com/users/tl-its-umich-edu/repos","events_url":"https://api.github.com/users/tl-its-umich-edu/events{/privacy}","received_events_url":"https://api.github.com/users/tl-its-umich-edu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tl-its-umich-edu/canvas_courses_report","description":"","fork":false,"url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report","forks_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/forks","keys_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/teams","hooks_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/hooks","issue_events_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/issues/events{/number}","events_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/events","assignees_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/assignees{/user}","branches_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/branches{/branch}","tags_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/tags","blobs_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/git/refs{/sha}","trees_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/statuses/{sha}","languages_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/languages","stargazers_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/stargazers","contributors_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/contributors","subscribers_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/subscribers","subscription_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/subscription","commits_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/commits{/sha}","git_commits_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/git/commits{/sha}","comments_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/comments{/number}","issue_comment_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/issues/comments{/number}","contents_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/contents/{+path}","compare_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/merges","archive_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/downloads","issues_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/issues{/number}","pulls_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/pulls{/number}","milestones_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/milestones{/number}","notifications_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/labels{/name}","releases_url":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/releases{/id}","created_at":"2015-07-30T19:04:11Z","updated_at":"2015-08-11T12:26:36Z","pushed_at":"2015-08-14T17:02:46Z","git_url":"git://github.com/tl-its-umich-edu/canvas_courses_report.git","ssh_url":"git@github.com:tl-its-umich-edu/canvas_courses_report.git","clone_url":"https://github.com/tl-its-umich-edu/canvas_courses_report.git","svn_url":"https://github.com/tl-its-umich-edu/canvas_courses_report","homepage":null,"size":312,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/pulls/6"},"html":{"href":"https://github.com/tl-its-umich-edu/canvas_courses_report/pull/6"},"issue":{"href":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/issues/6"},"comments":{"href":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/tl-its-umich-edu/canvas_courses_report/statuses/26edae34b0d42db09e9fd4fd116aff62d81e4622"}}}}