{"action":"opened","number":31,"pull_request":{"url":"https://api.github.com/repos/nusmodifications/nusmods-api/pulls/31","id":137715869,"html_url":"https://github.com/nusmodifications/nusmods-api/pull/31","diff_url":"https://github.com/nusmodifications/nusmods-api/pull/31.diff","patch_url":"https://github.com/nusmodifications/nusmods-api/pull/31.patch","issue_url":"https://api.github.com/repos/nusmodifications/nusmods-api/issues/31","number":31,"state":"open","locked":false,"title":"Database support","user":{"login":"li-kai","id":14850387,"avatar_url":"https://avatars2.githubusercontent.com/u/14850387?v=4","gravatar_id":"","url":"https://api.github.com/users/li-kai","html_url":"https://github.com/li-kai","followers_url":"https://api.github.com/users/li-kai/followers","following_url":"https://api.github.com/users/li-kai/following{/other_user}","gists_url":"https://api.github.com/users/li-kai/gists{/gist_id}","starred_url":"https://api.github.com/users/li-kai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/li-kai/subscriptions","organizations_url":"https://api.github.com/users/li-kai/orgs","repos_url":"https://api.github.com/users/li-kai/repos","events_url":"https://api.github.com/users/li-kai/events{/privacy}","received_events_url":"https://api.github.com/users/li-kai/received_events","type":"User","site_admin":false},"body":"This is the beginning process of moving from filesystem based data to a database.\r\n\r\n## Why database\r\n\r\nAs our data grows, having a filesystem becomes increasingly hard to backup. Furthermore, it is hard to manipulate if we want to do more interesting things, such as only sending down subsets of present data.\r\n\r\nGraphql solves this problem but it is not rest, and we currently we're reading entire data into memory; our server is already running low on that.\r\n\r\n## Rational for choosing sqlite3\r\n\r\nOur data is incredibly small (>100mb) which means performance wise there is not much to be gained from a full scale db. Backing up sqlite databases are also incredibly easy as it is just a single file. Additionally, we can allow others to download and play with our data almost immediately.\r\n\r\n## Architecture\r\n\r\nScrapers would inherit from `BaseScraper`, which would all contain the methods `scrape`, `process` and probably `save` in the future. An example is included in this PR.\r\n\r\nI don't intend on having these classes support legacy and write json, I will relegate these to a `LegacyApi` file that reads from db.\r\n\r\nFeel free to suggest a better class or method names.\r\n\r\nNo models yet, because I haven't seen the need to. Objection.js looks nice, but having to learn knex and objection...\r\n\r\n### Notes\r\n\r\nRight now it's fine since we only have 3 folders, but knex migration and seed files make source code a little hard to hunt. So I moved them to `/src/`, which may be clearer for people looking at our code.\r\n\r\nHttpService now uses axios instead of got. Reason is because we're using axios on client side, and axios's api is more flexible and nicer. Not sure if I should have just composed it though.\r\n\r\n`getCacheFilePath` is now using the new api, `url.parse` is deprecated in node 8.","created_at":"2017-08-25T16:56:36Z","updated_at":"2017-08-25T16:56:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/nusmodifications/nusmods-api/pulls/31/commits","review_comments_url":"https://api.github.com/repos/nusmodifications/nusmods-api/pulls/31/comments","review_comment_url":"https://api.github.com/repos/nusmodifications/nusmods-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nusmodifications/nusmods-api/issues/31/comments","statuses_url":"https://api.github.com/repos/nusmodifications/nusmods-api/statuses/405bb739c00dc4258e9ac80577b62a31c3487c5d","head":{"label":"nusmodifications:database","ref":"database","sha":"405bb739c00dc4258e9ac80577b62a31c3487c5d","user":{"login":"nusmodifications","id":7428865,"avatar_url":"https://avatars3.githubusercontent.com/u/7428865?v=4","gravatar_id":"","url":"https://api.github.com/users/nusmodifications","html_url":"https://github.com/nusmodifications","followers_url":"https://api.github.com/users/nusmodifications/followers","following_url":"https://api.github.com/users/nusmodifications/following{/other_user}","gists_url":"https://api.github.com/users/nusmodifications/gists{/gist_id}","starred_url":"https://api.github.com/users/nusmodifications/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nusmodifications/subscriptions","organizations_url":"https://api.github.com/users/nusmodifications/orgs","repos_url":"https://api.github.com/users/nusmodifications/repos","events_url":"https://api.github.com/users/nusmodifications/events{/privacy}","received_events_url":"https://api.github.com/users/nusmodifications/received_events","type":"Organization","site_admin":false},"repo":{"id":11611800,"name":"nusmods-api","full_name":"nusmodifications/nusmods-api","owner":{"login":"nusmodifications","id":7428865,"avatar_url":"https://avatars3.githubusercontent.com/u/7428865?v=4","gravatar_id":"","url":"https://api.github.com/users/nusmodifications","html_url":"https://github.com/nusmodifications","followers_url":"https://api.github.com/users/nusmodifications/followers","following_url":"https://api.github.com/users/nusmodifications/following{/other_user}","gists_url":"https://api.github.com/users/nusmodifications/gists{/gist_id}","starred_url":"https://api.github.com/users/nusmodifications/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nusmodifications/subscriptions","organizations_url":"https://api.github.com/users/nusmodifications/orgs","repos_url":"https://api.github.com/users/nusmodifications/repos","events_url":"https://api.github.com/users/nusmodifications/events{/privacy}","received_events_url":"https://api.github.com/users/nusmodifications/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nusmodifications/nusmods-api","description":"National University of Singapore Modules API (Unofficial)","fork":false,"url":"https://api.github.com/repos/nusmodifications/nusmods-api","forks_url":"https://api.github.com/repos/nusmodifications/nusmods-api/forks","keys_url":"https://api.github.com/repos/nusmodifications/nusmods-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nusmodifications/nusmods-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nusmodifications/nusmods-api/teams","hooks_url":"https://api.github.com/repos/nusmodifications/nusmods-api/hooks","issue_events_url":"https://api.github.com/repos/nusmodifications/nusmods-api/issues/events{/number}","events_url":"https://api.github.com/repos/nusmodifications/nusmods-api/events","assignees_url":"https://api.github.com/repos/nusmodifications/nusmods-api/assignees{/user}","branches_url":"https://api.github.com/repos/nusmodifications/nusmods-api/branches{/branch}","tags_url":"https://api.github.com/repos/nusmodifications/nusmods-api/tags","blobs_url":"https://api.github.com/repos/nusmodifications/nusmods-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nusmodifications/nusmods-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nusmodifications/nusmods-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/nusmodifications/nusmods-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nusmodifications/nusmods-api/statuses/{sha}","languages_url":"https://api.github.com/repos/nusmodifications/nusmods-api/languages","stargazers_url":"https://api.github.com/repos/nusmodifications/nusmods-api/stargazers","contributors_url":"https://api.github.com/repos/nusmodifications/nusmods-api/contributors","subscribers_url":"https://api.github.com/repos/nusmodifications/nusmods-api/subscribers","subscription_url":"https://api.github.com/repos/nusmodifications/nusmods-api/subscription","commits_url":"https://api.github.com/repos/nusmodifications/nusmods-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/nusmodifications/nusmods-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/nusmodifications/nusmods-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/nusmodifications/nusmods-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/nusmodifications/nusmods-api/contents/{+path}","compare_url":"https://api.github.com/repos/nusmodifications/nusmods-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nusmodifications/nusmods-api/merges","archive_url":"https://api.github.com/repos/nusmodifications/nusmods-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nusmodifications/nusmods-api/downloads","issues_url":"https://api.github.com/repos/nusmodifications/nusmods-api/issues{/number}","pulls_url":"https://api.github.com/repos/nusmodifications/nusmods-api/pulls{/number}","milestones_url":"https://api.github.com/repos/nusmodifications/nusmods-api/milestones{/number}","notifications_url":"https://api.github.com/repos/nusmodifications/nusmods-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nusmodifications/nusmods-api/labels{/name}","releases_url":"https://api.github.com/repos/nusmodifications/nusmods-api/releases{/id}","deployments_url":"https://api.github.com/repos/nusmodifications/nusmods-api/deployments","created_at":"2013-07-23T15:25:43Z","updated_at":"2017-08-11T02:36:05Z","pushed_at":"2017-08-25T16:17:59Z","git_url":"git://github.com/nusmodifications/nusmods-api.git","ssh_url":"git@github.com:nusmodifications/nusmods-api.git","clone_url":"https://github.com/nusmodifications/nusmods-api.git","svn_url":"https://github.com/nusmodifications/nusmods-api","homepage":"http://api.nusmods.com","size":771,"stargazers_count":30,"watchers_count":30,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":6,"forks":7,"open_issues":6,"watchers":30,"default_branch":"master"}},"base":{"label":"nusmodifications:master","ref":"master","sha":"969f525c65c7ba8763000a371bce71d7bbaf894b","user":{"login":"nusmodifications","id":7428865,"avatar_url":"https://avatars3.githubusercontent.com/u/7428865?v=4","gravatar_id":"","url":"https://api.github.com/users/nusmodifications","html_url":"https://github.com/nusmodifications","followers_url":"https://api.github.com/users/nusmodifications/followers","following_url":"https://api.github.com/users/nusmodifications/following{/other_user}","gists_url":"https://api.github.com/users/nusmodifications/gists{/gist_id}","starred_url":"https://api.github.com/users/nusmodifications/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nusmodifications/subscriptions","organizations_url":"https://api.github.com/users/nusmodifications/orgs","repos_url":"https://api.github.com/users/nusmodifications/repos","events_url":"https://api.github.com/users/nusmodifications/events{/privacy}","received_events_url":"https://api.github.com/users/nusmodifications/received_events","type":"Organization","site_admin":false},"repo":{"id":11611800,"name":"nusmods-api","full_name":"nusmodifications/nusmods-api","owner":{"login":"nusmodifications","id":7428865,"avatar_url":"https://avatars3.githubusercontent.com/u/7428865?v=4","gravatar_id":"","url":"https://api.github.com/users/nusmodifications","html_url":"https://github.com/nusmodifications","followers_url":"https://api.github.com/users/nusmodifications/followers","following_url":"https://api.github.com/users/nusmodifications/following{/other_user}","gists_url":"https://api.github.com/users/nusmodifications/gists{/gist_id}","starred_url":"https://api.github.com/users/nusmodifications/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nusmodifications/subscriptions","organizations_url":"https://api.github.com/users/nusmodifications/orgs","repos_url":"https://api.github.com/users/nusmodifications/repos","events_url":"https://api.github.com/users/nusmodifications/events{/privacy}","received_events_url":"https://api.github.com/users/nusmodifications/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nusmodifications/nusmods-api","description":"National University of Singapore Modules API (Unofficial)","fork":false,"url":"https://api.github.com/repos/nusmodifications/nusmods-api","forks_url":"https://api.github.com/repos/nusmodifications/nusmods-api/forks","keys_url":"https://api.github.com/repos/nusmodifications/nusmods-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nusmodifications/nusmods-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nusmodifications/nusmods-api/teams","hooks_url":"https://api.github.com/repos/nusmodifications/nusmods-api/hooks","issue_events_url":"https://api.github.com/repos/nusmodifications/nusmods-api/issues/events{/number}","events_url":"https://api.github.com/repos/nusmodifications/nusmods-api/events","assignees_url":"https://api.github.com/repos/nusmodifications/nusmods-api/assignees{/user}","branches_url":"https://api.github.com/repos/nusmodifications/nusmods-api/branches{/branch}","tags_url":"https://api.github.com/repos/nusmodifications/nusmods-api/tags","blobs_url":"https://api.github.com/repos/nusmodifications/nusmods-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nusmodifications/nusmods-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nusmodifications/nusmods-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/nusmodifications/nusmods-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nusmodifications/nusmods-api/statuses/{sha}","languages_url":"https://api.github.com/repos/nusmodifications/nusmods-api/languages","stargazers_url":"https://api.github.com/repos/nusmodifications/nusmods-api/stargazers","contributors_url":"https://api.github.com/repos/nusmodifications/nusmods-api/contributors","subscribers_url":"https://api.github.com/repos/nusmodifications/nusmods-api/subscribers","subscription_url":"https://api.github.com/repos/nusmodifications/nusmods-api/subscription","commits_url":"https://api.github.com/repos/nusmodifications/nusmods-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/nusmodifications/nusmods-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/nusmodifications/nusmods-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/nusmodifications/nusmods-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/nusmodifications/nusmods-api/contents/{+path}","compare_url":"https://api.github.com/repos/nusmodifications/nusmods-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nusmodifications/nusmods-api/merges","archive_url":"https://api.github.com/repos/nusmodifications/nusmods-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nusmodifications/nusmods-api/downloads","issues_url":"https://api.github.com/repos/nusmodifications/nusmods-api/issues{/number}","pulls_url":"https://api.github.com/repos/nusmodifications/nusmods-api/pulls{/number}","milestones_url":"https://api.github.com/repos/nusmodifications/nusmods-api/milestones{/number}","notifications_url":"https://api.github.com/repos/nusmodifications/nusmods-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nusmodifications/nusmods-api/labels{/name}","releases_url":"https://api.github.com/repos/nusmodifications/nusmods-api/releases{/id}","deployments_url":"https://api.github.com/repos/nusmodifications/nusmods-api/deployments","created_at":"2013-07-23T15:25:43Z","updated_at":"2017-08-11T02:36:05Z","pushed_at":"2017-08-25T16:17:59Z","git_url":"git://github.com/nusmodifications/nusmods-api.git","ssh_url":"git@github.com:nusmodifications/nusmods-api.git","clone_url":"https://github.com/nusmodifications/nusmods-api.git","svn_url":"https://github.com/nusmodifications/nusmods-api","homepage":"http://api.nusmods.com","size":771,"stargazers_count":30,"watchers_count":30,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":6,"forks":7,"open_issues":6,"watchers":30,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nusmodifications/nusmods-api/pulls/31"},"html":{"href":"https://github.com/nusmodifications/nusmods-api/pull/31"},"issue":{"href":"https://api.github.com/repos/nusmodifications/nusmods-api/issues/31"},"comments":{"href":"https://api.github.com/repos/nusmodifications/nusmods-api/issues/31/comments"},"review_comments":{"href":"https://api.github.com/repos/nusmodifications/nusmods-api/pulls/31/comments"},"review_comment":{"href":"https://api.github.com/repos/nusmodifications/nusmods-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nusmodifications/nusmods-api/pulls/31/commits"},"statuses":{"href":"https://api.github.com/repos/nusmodifications/nusmods-api/statuses/405bb739c00dc4258e9ac80577b62a31c3487c5d"}},"merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":false,"commits":10,"additions":997,"deletions":23,"changed_files":22}}
{"actor":{"display_login":"li-kai"}}