{"action":"created","issue":{"url":"https://api.github.com/repos/e-mission/e-mission-phone/issues/21","labels_url":"https://api.github.com/repos/e-mission/e-mission-phone/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/e-mission/e-mission-phone/issues/21/comments","events_url":"https://api.github.com/repos/e-mission/e-mission-phone/issues/21/events","html_url":"https://github.com/e-mission/e-mission-phone/issues/21","id":56849799,"number":21,"title":"HIGH IMPACT: Cache the results on the phone (both platforms)","user":{"login":"shankari","id":2423263,"avatar_url":"https://avatars.githubusercontent.com/u/2423263?v=3","gravatar_id":"","url":"https://api.github.com/users/shankari","html_url":"https://github.com/shankari","followers_url":"https://api.github.com/users/shankari/followers","following_url":"https://api.github.com/users/shankari/following{/other_user}","gists_url":"https://api.github.com/users/shankari/gists{/gist_id}","starred_url":"https://api.github.com/users/shankari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shankari/subscriptions","organizations_url":"https://api.github.com/users/shankari/orgs","repos_url":"https://api.github.com/users/shankari/repos","events_url":"https://api.github.com/users/shankari/events{/privacy}","received_events_url":"https://api.github.com/users/shankari/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/e-mission/e-mission-phone/labels/cs194","name":"cs194","color":"e11d21"},{"url":"https://api.github.com/repos/e-mission/e-mission-phone/labels/medium","name":"medium","color":"d4c5f9"},{"url":"https://api.github.com/repos/e-mission/e-mission-phone/labels/phone","name":"phone","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":24,"created_at":"2015-02-06T18:37:34Z","updated_at":"2015-02-20T05:33:51Z","closed_at":null,"body":"Our results are currently computed on the server side and sent over to the client at the following times:\r\n- when there are no trip left to confirm\r\n- when the user clicks on the \"RESULTS\" option in the menu bar\r\n\r\nIn both these cases, the phone makes a HTTP POST call to the \"/compare\" endpoint, which returns a HTML page. The page is then displayed in a webview on the appropriate platform.\r\n\r\nThis was an early attempt by me to work cross-platform, and to:\r\n- make it easier to update the app without having to release a new version every time, and\r\n- to customize the result view for the type of user\r\n\r\nThis works great, but is very slow, so slow that a lot of times, people just don't wait for it to finish loading. Part of the slowness was due to the time taken to compute the results, so I checked in a fix to pre-compute the results daily on the server side.\r\nissue: https://github.com/e-mission/e-mission-server/issues/23\r\nfix: https://github.com/e-mission/e-mission-server/pull/25\r\n\r\nHowever, even after that fix, the result view load is slow. I suspect that this is due to the time required to retrieve the associated .css and .js files. I had hoped that these would be cached on the phone, so the retrieve time would be negligible, but it looks like even the version check required to determine whether a new version is available takes time, specially since there are multiple of these checks (see snippet below).\r\n\r\nPre-fetching the results to the phone should move this delay to the background and result in a more responsive UI for the user.\r\n\r\nThe idea is that you would add this additional POST call to the existing remote sync mechanism\r\n- android: https://github.com/e-mission/e-mission-phone/blob/master/android/app/src/main/java/edu/berkeley/eecs/e_mission/data_sync/ConfirmTripsAdapter.java#L80\r\n- ios: https://github.com/e-mission/e-mission-phone/blob/master/iOS/CFC_Tracker/CFC_Tracker/AppDelegate.m#L163\r\nstore the result on the local disk, and then change the display code load from local disk instead.\r\n\r\nOne thing to watch out for: the returned HTML document currently has relative references to javascript code, i.e.\r\n    <script src=\"clients/choice/front/ionic.bundle.js\" charset=\"utf-8\"></script>\r\nso you would need to parse the returned HTML, issue the appropriate GET calls as well and store those in the appropriate locations on the local disk as well."},"comment":{"url":"https://api.github.com/repos/e-mission/e-mission-phone/issues/comments/75192073","html_url":"https://github.com/e-mission/e-mission-phone/issues/21#issuecomment-75192073","issue_url":"https://api.github.com/repos/e-mission/e-mission-phone/issues/21","id":75192073,"user":{"login":"shankari","id":2423263,"avatar_url":"https://avatars.githubusercontent.com/u/2423263?v=3","gravatar_id":"","url":"https://api.github.com/users/shankari","html_url":"https://github.com/shankari","followers_url":"https://api.github.com/users/shankari/followers","following_url":"https://api.github.com/users/shankari/following{/other_user}","gists_url":"https://api.github.com/users/shankari/gists{/gist_id}","starred_url":"https://api.github.com/users/shankari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shankari/subscriptions","organizations_url":"https://api.github.com/users/shankari/orgs","repos_url":"https://api.github.com/users/shankari/repos","events_url":"https://api.github.com/users/shankari/events{/privacy}","received_events_url":"https://api.github.com/users/shankari/received_events","type":"User","site_admin":false},"created_at":"2015-02-20T05:33:50Z","updated_at":"2015-02-20T05:33:50Z","body":"Let's see what the outcome of the email thread around my email to the security grads group is.\r\nAlso, by data, you actually mean data + html/scripts, right?\r\n\r\nBecause that was what confused Prof. Culler today morning - he thought we were trying to cache only the data, and was suggesting that we could send a script to the client as well. Although it looked like he didn't like javascript as the script very much..."}}