{"action":"created","comment":{"url":"https://api.github.com/repos/shuttleql/session-service/pulls/comments/87333825","pull_request_review_id":7949920,"id":87333825,"diff_hunk":"@@ -0,0 +1,76 @@\n+package com.shuttleql.services.session\n+\n+import com.shuttleql.services.session.tables.{UserToSession, UserToSessions}\n+import slick.lifted.TableQuery\n+import slick.driver.PostgresDriver.api._\n+import scala.concurrent.duration.Duration\n+import scala.concurrent._\n+import scala.concurrent.ExecutionContext.Implicits.global\n+import scala.language.postfixOps\n+\n+object UserToSessionsDAO extends TableQuery(new UserToSessions(_)) {\n+  def initDb() = {\n+    Database.forConfig(\"db\")\n+  }\n+\n+  def setupTables(): Option[Unit] = {\n+    val db = initDb\n+\n+    try {\n+      Option(Await.result(db.run(this.schema.create), Duration.Inf))\n+    } catch {\n+      case e: Exception => None\n+    } finally {\n+      db.close\n+    }\n+  }\n+\n+  def create(userId: Long, sessionId: Long): Option[UserToSession] = {\n+    val db = initDb\n+    val now = new java.sql.Timestamp(System.currentTimeMillis())\n+    val newUserToSession = UserToSession(userId, sessionId, now, Some(now))\n+\n+    try {\n+      val result: UserToSession = Await.result(db.run(this returning this += newUserToSession), Duration.Inf)\n+      Option(result)\n+    } catch {\n+      case e: Exception => None\n+    } finally {\n+      db.close\n+    }\n+  }\n+\n+  def update(userId: Long, sessionId: Long): Option[UserToSession] = {\n+    val db = initDb\n+    val now = new java.sql.Timestamp(System.currentTimeMillis())\n+\n+    try {\n+      val userToSession = Await.result(db.run(this.filter(_.sessionId === sessionId)\n+            .filter(_.userId === userId).result).map(_.headOption), Duration.Inf)","path":"src/main/scala/com/shuttleql/services/session/UserToSessionsDAO.scala","position":49,"original_position":49,"commit_id":"2bedd769841f35110164f3beba6450d90b6354ac","original_commit_id":"2bedd769841f35110164f3beba6450d90b6354ac","user":{"login":"tlulu","id":5805570,"avatar_url":"https://avatars.githubusercontent.com/u/5805570?v=3","gravatar_id":"","url":"https://api.github.com/users/tlulu","html_url":"https://github.com/tlulu","followers_url":"https://api.github.com/users/tlulu/followers","following_url":"https://api.github.com/users/tlulu/following{/other_user}","gists_url":"https://api.github.com/users/tlulu/gists{/gist_id}","starred_url":"https://api.github.com/users/tlulu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tlulu/subscriptions","organizations_url":"https://api.github.com/users/tlulu/orgs","repos_url":"https://api.github.com/users/tlulu/repos","events_url":"https://api.github.com/users/tlulu/events{/privacy}","received_events_url":"https://api.github.com/users/tlulu/received_events","type":"User","site_admin":false},"body":"no","created_at":"2016-11-10T06:09:57Z","updated_at":"2016-11-10T06:09:57Z","html_url":"https://github.com/shuttleql/session-service/pull/1#discussion_r87333825","pull_request_url":"https://api.github.com/repos/shuttleql/session-service/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/shuttleql/session-service/pulls/comments/87333825"},"html":{"href":"https://github.com/shuttleql/session-service/pull/1#discussion_r87333825"},"pull_request":{"href":"https://api.github.com/repos/shuttleql/session-service/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/shuttleql/session-service/pulls/1","id":93087978,"html_url":"https://github.com/shuttleql/session-service/pull/1","diff_url":"https://github.com/shuttleql/session-service/pull/1.diff","patch_url":"https://github.com/shuttleql/session-service/pull/1.patch","issue_url":"https://api.github.com/repos/shuttleql/session-service/issues/1","number":1,"state":"open","locked":false,"title":"Created datamodels and CRUD operations for all session endpoints","user":{"login":"tlulu","id":5805570,"avatar_url":"https://avatars.githubusercontent.com/u/5805570?v=3","gravatar_id":"","url":"https://api.github.com/users/tlulu","html_url":"https://github.com/tlulu","followers_url":"https://api.github.com/users/tlulu/followers","following_url":"https://api.github.com/users/tlulu/following{/other_user}","gists_url":"https://api.github.com/users/tlulu/gists{/gist_id}","starred_url":"https://api.github.com/users/tlulu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tlulu/subscriptions","organizations_url":"https://api.github.com/users/tlulu/orgs","repos_url":"https://api.github.com/users/tlulu/repos","events_url":"https://api.github.com/users/tlulu/events{/privacy}","received_events_url":"https://api.github.com/users/tlulu/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-10T05:08:19Z","updated_at":"2016-11-10T06:09:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f9165cabc1e6d2fd0077fef24ad2356ccf1ce44f","assignee":{"login":"jasonf7","id":1820087,"avatar_url":"https://avatars.githubusercontent.com/u/1820087?v=3","gravatar_id":"","url":"https://api.github.com/users/jasonf7","html_url":"https://github.com/jasonf7","followers_url":"https://api.github.com/users/jasonf7/followers","following_url":"https://api.github.com/users/jasonf7/following{/other_user}","gists_url":"https://api.github.com/users/jasonf7/gists{/gist_id}","starred_url":"https://api.github.com/users/jasonf7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasonf7/subscriptions","organizations_url":"https://api.github.com/users/jasonf7/orgs","repos_url":"https://api.github.com/users/jasonf7/repos","events_url":"https://api.github.com/users/jasonf7/events{/privacy}","received_events_url":"https://api.github.com/users/jasonf7/received_events","type":"User","site_admin":false},"assignees":[{"login":"jasonf7","id":1820087,"avatar_url":"https://avatars.githubusercontent.com/u/1820087?v=3","gravatar_id":"","url":"https://api.github.com/users/jasonf7","html_url":"https://github.com/jasonf7","followers_url":"https://api.github.com/users/jasonf7/followers","following_url":"https://api.github.com/users/jasonf7/following{/other_user}","gists_url":"https://api.github.com/users/jasonf7/gists{/gist_id}","starred_url":"https://api.github.com/users/jasonf7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasonf7/subscriptions","organizations_url":"https://api.github.com/users/jasonf7/orgs","repos_url":"https://api.github.com/users/jasonf7/repos","events_url":"https://api.github.com/users/jasonf7/events{/privacy}","received_events_url":"https://api.github.com/users/jasonf7/received_events","type":"User","site_admin":false},{"login":"clemmy","id":3696934,"avatar_url":"https://avatars.githubusercontent.com/u/3696934?v=3","gravatar_id":"","url":"https://api.github.com/users/clemmy","html_url":"https://github.com/clemmy","followers_url":"https://api.github.com/users/clemmy/followers","following_url":"https://api.github.com/users/clemmy/following{/other_user}","gists_url":"https://api.github.com/users/clemmy/gists{/gist_id}","starred_url":"https://api.github.com/users/clemmy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clemmy/subscriptions","organizations_url":"https://api.github.com/users/clemmy/orgs","repos_url":"https://api.github.com/users/clemmy/repos","events_url":"https://api.github.com/users/clemmy/events{/privacy}","received_events_url":"https://api.github.com/users/clemmy/received_events","type":"User","site_admin":false},{"login":"c9dong","id":5816374,"avatar_url":"https://avatars.githubusercontent.com/u/5816374?v=3","gravatar_id":"","url":"https://api.github.com/users/c9dong","html_url":"https://github.com/c9dong","followers_url":"https://api.github.com/users/c9dong/followers","following_url":"https://api.github.com/users/c9dong/following{/other_user}","gists_url":"https://api.github.com/users/c9dong/gists{/gist_id}","starred_url":"https://api.github.com/users/c9dong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c9dong/subscriptions","organizations_url":"https://api.github.com/users/c9dong/orgs","repos_url":"https://api.github.com/users/c9dong/repos","events_url":"https://api.github.com/users/c9dong/events{/privacy}","received_events_url":"https://api.github.com/users/c9dong/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/shuttleql/session-service/pulls/1/commits","review_comments_url":"https://api.github.com/repos/shuttleql/session-service/pulls/1/comments","review_comment_url":"https://api.github.com/repos/shuttleql/session-service/pulls/comments{/number}","comments_url":"https://api.github.com/repos/shuttleql/session-service/issues/1/comments","statuses_url":"https://api.github.com/repos/shuttleql/session-service/statuses/2bedd769841f35110164f3beba6450d90b6354ac","head":{"label":"shuttleql:tlu/session","ref":"tlu/session","sha":"2bedd769841f35110164f3beba6450d90b6354ac","user":{"login":"shuttleql","id":22848640,"avatar_url":"https://avatars.githubusercontent.com/u/22848640?v=3","gravatar_id":"","url":"https://api.github.com/users/shuttleql","html_url":"https://github.com/shuttleql","followers_url":"https://api.github.com/users/shuttleql/followers","following_url":"https://api.github.com/users/shuttleql/following{/other_user}","gists_url":"https://api.github.com/users/shuttleql/gists{/gist_id}","starred_url":"https://api.github.com/users/shuttleql/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shuttleql/subscriptions","organizations_url":"https://api.github.com/users/shuttleql/orgs","repos_url":"https://api.github.com/users/shuttleql/repos","events_url":"https://api.github.com/users/shuttleql/events{/privacy}","received_events_url":"https://api.github.com/users/shuttleql/received_events","type":"Organization","site_admin":false},"repo":{"id":70972443,"name":"session-service","full_name":"shuttleql/session-service","owner":{"login":"shuttleql","id":22848640,"avatar_url":"https://avatars.githubusercontent.com/u/22848640?v=3","gravatar_id":"","url":"https://api.github.com/users/shuttleql","html_url":"https://github.com/shuttleql","followers_url":"https://api.github.com/users/shuttleql/followers","following_url":"https://api.github.com/users/shuttleql/following{/other_user}","gists_url":"https://api.github.com/users/shuttleql/gists{/gist_id}","starred_url":"https://api.github.com/users/shuttleql/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shuttleql/subscriptions","organizations_url":"https://api.github.com/users/shuttleql/orgs","repos_url":"https://api.github.com/users/shuttleql/repos","events_url":"https://api.github.com/users/shuttleql/events{/privacy}","received_events_url":"https://api.github.com/users/shuttleql/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/shuttleql/session-service","description":null,"fork":false,"url":"https://api.github.com/repos/shuttleql/session-service","forks_url":"https://api.github.com/repos/shuttleql/session-service/forks","keys_url":"https://api.github.com/repos/shuttleql/session-service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shuttleql/session-service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shuttleql/session-service/teams","hooks_url":"https://api.github.com/repos/shuttleql/session-service/hooks","issue_events_url":"https://api.github.com/repos/shuttleql/session-service/issues/events{/number}","events_url":"https://api.github.com/repos/shuttleql/session-service/events","assignees_url":"https://api.github.com/repos/shuttleql/session-service/assignees{/user}","branches_url":"https://api.github.com/repos/shuttleql/session-service/branches{/branch}","tags_url":"https://api.github.com/repos/shuttleql/session-service/tags","blobs_url":"https://api.github.com/repos/shuttleql/session-service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shuttleql/session-service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shuttleql/session-service/git/refs{/sha}","trees_url":"https://api.github.com/repos/shuttleql/session-service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shuttleql/session-service/statuses/{sha}","languages_url":"https://api.github.com/repos/shuttleql/session-service/languages","stargazers_url":"https://api.github.com/repos/shuttleql/session-service/stargazers","contributors_url":"https://api.github.com/repos/shuttleql/session-service/contributors","subscribers_url":"https://api.github.com/repos/shuttleql/session-service/subscribers","subscription_url":"https://api.github.com/repos/shuttleql/session-service/subscription","commits_url":"https://api.github.com/repos/shuttleql/session-service/commits{/sha}","git_commits_url":"https://api.github.com/repos/shuttleql/session-service/git/commits{/sha}","comments_url":"https://api.github.com/repos/shuttleql/session-service/comments{/number}","issue_comment_url":"https://api.github.com/repos/shuttleql/session-service/issues/comments{/number}","contents_url":"https://api.github.com/repos/shuttleql/session-service/contents/{+path}","compare_url":"https://api.github.com/repos/shuttleql/session-service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shuttleql/session-service/merges","archive_url":"https://api.github.com/repos/shuttleql/session-service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shuttleql/session-service/downloads","issues_url":"https://api.github.com/repos/shuttleql/session-service/issues{/number}","pulls_url":"https://api.github.com/repos/shuttleql/session-service/pulls{/number}","milestones_url":"https://api.github.com/repos/shuttleql/session-service/milestones{/number}","notifications_url":"https://api.github.com/repos/shuttleql/session-service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shuttleql/session-service/labels{/name}","releases_url":"https://api.github.com/repos/shuttleql/session-service/releases{/id}","deployments_url":"https://api.github.com/repos/shuttleql/session-service/deployments","created_at":"2016-10-15T07:05:03Z","updated_at":"2016-10-24T20:28:36Z","pushed_at":"2016-11-10T05:08:20Z","git_url":"git://github.com/shuttleql/session-service.git","ssh_url":"git@github.com:shuttleql/session-service.git","clone_url":"https://github.com/shuttleql/session-service.git","svn_url":"https://github.com/shuttleql/session-service","homepage":null,"size":20,"stargazers_count":0,"watchers_count":0,"language":"Shell","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":"shuttleql:master","ref":"master","sha":"4c17340441da97809182a5f7793574ce69b55fd8","user":{"login":"shuttleql","id":22848640,"avatar_url":"https://avatars.githubusercontent.com/u/22848640?v=3","gravatar_id":"","url":"https://api.github.com/users/shuttleql","html_url":"https://github.com/shuttleql","followers_url":"https://api.github.com/users/shuttleql/followers","following_url":"https://api.github.com/users/shuttleql/following{/other_user}","gists_url":"https://api.github.com/users/shuttleql/gists{/gist_id}","starred_url":"https://api.github.com/users/shuttleql/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shuttleql/subscriptions","organizations_url":"https://api.github.com/users/shuttleql/orgs","repos_url":"https://api.github.com/users/shuttleql/repos","events_url":"https://api.github.com/users/shuttleql/events{/privacy}","received_events_url":"https://api.github.com/users/shuttleql/received_events","type":"Organization","site_admin":false},"repo":{"id":70972443,"name":"session-service","full_name":"shuttleql/session-service","owner":{"login":"shuttleql","id":22848640,"avatar_url":"https://avatars.githubusercontent.com/u/22848640?v=3","gravatar_id":"","url":"https://api.github.com/users/shuttleql","html_url":"https://github.com/shuttleql","followers_url":"https://api.github.com/users/shuttleql/followers","following_url":"https://api.github.com/users/shuttleql/following{/other_user}","gists_url":"https://api.github.com/users/shuttleql/gists{/gist_id}","starred_url":"https://api.github.com/users/shuttleql/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shuttleql/subscriptions","organizations_url":"https://api.github.com/users/shuttleql/orgs","repos_url":"https://api.github.com/users/shuttleql/repos","events_url":"https://api.github.com/users/shuttleql/events{/privacy}","received_events_url":"https://api.github.com/users/shuttleql/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/shuttleql/session-service","description":null,"fork":false,"url":"https://api.github.com/repos/shuttleql/session-service","forks_url":"https://api.github.com/repos/shuttleql/session-service/forks","keys_url":"https://api.github.com/repos/shuttleql/session-service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shuttleql/session-service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shuttleql/session-service/teams","hooks_url":"https://api.github.com/repos/shuttleql/session-service/hooks","issue_events_url":"https://api.github.com/repos/shuttleql/session-service/issues/events{/number}","events_url":"https://api.github.com/repos/shuttleql/session-service/events","assignees_url":"https://api.github.com/repos/shuttleql/session-service/assignees{/user}","branches_url":"https://api.github.com/repos/shuttleql/session-service/branches{/branch}","tags_url":"https://api.github.com/repos/shuttleql/session-service/tags","blobs_url":"https://api.github.com/repos/shuttleql/session-service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shuttleql/session-service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shuttleql/session-service/git/refs{/sha}","trees_url":"https://api.github.com/repos/shuttleql/session-service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shuttleql/session-service/statuses/{sha}","languages_url":"https://api.github.com/repos/shuttleql/session-service/languages","stargazers_url":"https://api.github.com/repos/shuttleql/session-service/stargazers","contributors_url":"https://api.github.com/repos/shuttleql/session-service/contributors","subscribers_url":"https://api.github.com/repos/shuttleql/session-service/subscribers","subscription_url":"https://api.github.com/repos/shuttleql/session-service/subscription","commits_url":"https://api.github.com/repos/shuttleql/session-service/commits{/sha}","git_commits_url":"https://api.github.com/repos/shuttleql/session-service/git/commits{/sha}","comments_url":"https://api.github.com/repos/shuttleql/session-service/comments{/number}","issue_comment_url":"https://api.github.com/repos/shuttleql/session-service/issues/comments{/number}","contents_url":"https://api.github.com/repos/shuttleql/session-service/contents/{+path}","compare_url":"https://api.github.com/repos/shuttleql/session-service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shuttleql/session-service/merges","archive_url":"https://api.github.com/repos/shuttleql/session-service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shuttleql/session-service/downloads","issues_url":"https://api.github.com/repos/shuttleql/session-service/issues{/number}","pulls_url":"https://api.github.com/repos/shuttleql/session-service/pulls{/number}","milestones_url":"https://api.github.com/repos/shuttleql/session-service/milestones{/number}","notifications_url":"https://api.github.com/repos/shuttleql/session-service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shuttleql/session-service/labels{/name}","releases_url":"https://api.github.com/repos/shuttleql/session-service/releases{/id}","deployments_url":"https://api.github.com/repos/shuttleql/session-service/deployments","created_at":"2016-10-15T07:05:03Z","updated_at":"2016-10-24T20:28:36Z","pushed_at":"2016-11-10T05:08:20Z","git_url":"git://github.com/shuttleql/session-service.git","ssh_url":"git@github.com:shuttleql/session-service.git","clone_url":"https://github.com/shuttleql/session-service.git","svn_url":"https://github.com/shuttleql/session-service","homepage":null,"size":20,"stargazers_count":0,"watchers_count":0,"language":"Shell","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/shuttleql/session-service/pulls/1"},"html":{"href":"https://github.com/shuttleql/session-service/pull/1"},"issue":{"href":"https://api.github.com/repos/shuttleql/session-service/issues/1"},"comments":{"href":"https://api.github.com/repos/shuttleql/session-service/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/shuttleql/session-service/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/shuttleql/session-service/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/shuttleql/session-service/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/shuttleql/session-service/statuses/2bedd769841f35110164f3beba6450d90b6354ac"}}}}
{"actor":{"display_login":"tlulu"}}