{"action":"created","comment":{"url":"https://api.github.com/repos/MUSIT-Norway/musit/pulls/comments/90755759","pull_request_review_id":11275786,"id":90755759,"diff_hunk":"@@ -119,20 +131,72 @@ trait AuthTables extends HasDatabaseConfigProvider[JdbcProfile] {\n \n   }\n \n-  type UserGroupTableType = ((String, GroupId)) //, Option[CollectionUUID]))\n-\n   class UserGroupTable(\n       val tag: Tag\n-  ) extends Table[UserGroupTableType](tag, Some(schema), \"USER_AUTH_GROUP\") {\n+  ) extends Table[UserGroupMembership](tag, Some(schema), \"USER_AUTH_GROUP\") {\n+\n+    val tableId = column[Option[Int]](\"UAG_ID\", O.PrimaryKey, O.AutoInc)\n+    val feideEmail = column[String](\"USER_FEIDE_EMAIL\")\n+    val groupId = column[GroupId](\"GROUP_UUID\")\n+    val collectionId = column[Option[CollectionUUID]](\"COLLECTION_UUID\")\n+\n+    val create = (\n+      id: Option[Int],\n+      feideEmail: String,\n+      groupId: GroupId,\n+      collection: Option[CollectionUUID]\n+    ) => UserGroupMembership(id, feideEmail, groupId, collection)\n+\n+    val destroy = (ugm: UserGroupMembership) =>\n+      Some((ugm.id, ugm.feideEmail, ugm.groupId, ugm.collection))\n+\n+    override def * = (tableId, feideEmail, groupId, collectionId) <> (create.tupled, destroy) // scalastyle:ignore\n+  }\n \n-    val feideEmail = column[String](\"USER_FEIDE_EMAIL\", O.PrimaryKey)\n-    val groupId = column[GroupId](\"GROUP_UUID\", O.PrimaryKey)\n-    //    val collectionId = column[CollectionUUID](\"COLLECTION_UUID\")\n+  type GrpColTuples = Seq[(GroupTableType, CollectionTableType)]\n \n-    def pk = primaryKey(\"PK_USER_GROUP\", (feideEmail, groupId))\n+  def findGroupInfoBy(\n+    q: Query[UserGroupTable, UserGroupMembership, Seq]\n+  )(implicit ec: ExecutionContext): Future[MusitResult[Seq[GroupInfo]]] = {\n+    val query = for {\n+      (ug, g) <- q join grpTable on (_.groupId === _.id)\n+      (_, c) <- q join musColTable on (_.collectionId === _.uuid)\n+    } yield (g, c)\n \n-    override def * = (feideEmail, groupId) // scalastyle:ignore\n+    db.run(query.result).map(gc => MusitSuccess(foldGroupCol(gc)))\n+  }\n+\n+  def convertColGrpTuples(tuples: GrpColTuples): Seq[(GroupInfo, MuseumCollection)] = {\n+    tuples.map(convertColGrpTuple)\n+  }\n+\n+  def convertColGrpTuple(\n+    tuple: (GroupTableType, CollectionTableType)\n+  ): (GroupInfo, MuseumCollection) = {\n+    (GroupInfo.fromTuple(tuple._1), MuseumCollection.fromTuple(tuple._2))\n+  }\n \n+  /**\n+   * Function that helps to reduce rows of GroupInfo and MuseumCollections into\n+   * one GroupInfo (per unique group) containing all its MuseumCollection.\n+   *\n+   * @param tuples A Sequence of tuples of GroupTableType and CollectionTableType\n+   * @return A List of GroupInfo data\n+   */\n+  def foldGroupCol(tuples: GrpColTuples): List[GroupInfo] = {\n+    convertColGrpTuples(tuples).foldLeft(List.empty[GroupInfo]) { (grpInfos, tuple) =>\n+      val currGrp = tuple._1\n+      val currCol = tuple._2\n+\n+      if (grpInfos.exists(_.id == currGrp.id)) {\n+        grpInfos.map { gi =>\n+          if (gi.id == currGrp.id) gi.copy(collections = gi.collections :+ currCol)","path":"musit-service/src/main/scala/no/uio/musit/security/AuthTables.scala","position":163,"original_position":163,"commit_id":"67e45e1ffe199bfd6b7d50dc9df8a533d748e41e","original_commit_id":"67e45e1ffe199bfd6b7d50dc9df8a533d748e41e","user":{"login":"codacy-bot","id":19940114,"avatar_url":"https://avatars.githubusercontent.com/u/19940114?v=3","gravatar_id":"","url":"https://api.github.com/users/codacy-bot","html_url":"https://github.com/codacy-bot","followers_url":"https://api.github.com/users/codacy-bot/followers","following_url":"https://api.github.com/users/codacy-bot/following{/other_user}","gists_url":"https://api.github.com/users/codacy-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/codacy-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codacy-bot/subscriptions","organizations_url":"https://api.github.com/users/codacy-bot/orgs","repos_url":"https://api.github.com/users/codacy-bot/repos","events_url":"https://api.github.com/users/codacy-bot/events{/privacy}","received_events_url":"https://api.github.com/users/codacy-bot/received_events","type":"User","site_admin":false},"body":"![Codacy](https://www.codacy.com/assets/images/favicon.png) Issue found: [If block needs braces](https://www.codacy.com/app/MUSIT-Norway/musit/file/4635327100/issues/source?bid=3312778&fileBranchId=3951819#l193)","created_at":"2016-12-03T11:39:59Z","updated_at":"2016-12-03T11:39:59Z","html_url":"https://github.com/MUSIT-Norway/musit/pull/217#discussion_r90755759","pull_request_url":"https://api.github.com/repos/MUSIT-Norway/musit/pulls/217","_links":{"self":{"href":"https://api.github.com/repos/MUSIT-Norway/musit/pulls/comments/90755759"},"html":{"href":"https://github.com/MUSIT-Norway/musit/pull/217#discussion_r90755759"},"pull_request":{"href":"https://api.github.com/repos/MUSIT-Norway/musit/pulls/217"}}},"pull_request":{"url":"https://api.github.com/repos/MUSIT-Norway/musit/pulls/217","id":95848627,"html_url":"https://github.com/MUSIT-Norway/musit/pull/217","diff_url":"https://github.com/MUSIT-Norway/musit/pull/217.diff","patch_url":"https://github.com/MUSIT-Norway/musit/pull/217.patch","issue_url":"https://api.github.com/repos/MUSIT-Norway/musit/issues/217","number":217,"state":"open","locked":false,"title":"MUSARK-585","user":{"login":"kpmeen","id":3736963,"avatar_url":"https://avatars.githubusercontent.com/u/3736963?v=3","gravatar_id":"","url":"https://api.github.com/users/kpmeen","html_url":"https://github.com/kpmeen","followers_url":"https://api.github.com/users/kpmeen/followers","following_url":"https://api.github.com/users/kpmeen/following{/other_user}","gists_url":"https://api.github.com/users/kpmeen/gists{/gist_id}","starred_url":"https://api.github.com/users/kpmeen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kpmeen/subscriptions","organizations_url":"https://api.github.com/users/kpmeen/orgs","repos_url":"https://api.github.com/users/kpmeen/repos","events_url":"https://api.github.com/users/kpmeen/events{/privacy}","received_events_url":"https://api.github.com/users/kpmeen/received_events","type":"User","site_admin":false},"body":"Implementation for handling museum collections. (Actually more like field of expertise within the museum domain).","created_at":"2016-11-30T08:41:04Z","updated_at":"2016-12-03T11:40:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9fc9686cda28ea459ad5d3a591692b7603cb8b9b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/MUSIT-Norway/musit/pulls/217/commits","review_comments_url":"https://api.github.com/repos/MUSIT-Norway/musit/pulls/217/comments","review_comment_url":"https://api.github.com/repos/MUSIT-Norway/musit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/MUSIT-Norway/musit/issues/217/comments","statuses_url":"https://api.github.com/repos/MUSIT-Norway/musit/statuses/67e45e1ffe199bfd6b7d50dc9df8a533d748e41e","head":{"label":"kpmeen:MUSARK-585","ref":"MUSARK-585","sha":"67e45e1ffe199bfd6b7d50dc9df8a533d748e41e","user":{"login":"kpmeen","id":3736963,"avatar_url":"https://avatars.githubusercontent.com/u/3736963?v=3","gravatar_id":"","url":"https://api.github.com/users/kpmeen","html_url":"https://github.com/kpmeen","followers_url":"https://api.github.com/users/kpmeen/followers","following_url":"https://api.github.com/users/kpmeen/following{/other_user}","gists_url":"https://api.github.com/users/kpmeen/gists{/gist_id}","starred_url":"https://api.github.com/users/kpmeen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kpmeen/subscriptions","organizations_url":"https://api.github.com/users/kpmeen/orgs","repos_url":"https://api.github.com/users/kpmeen/repos","events_url":"https://api.github.com/users/kpmeen/events{/privacy}","received_events_url":"https://api.github.com/users/kpmeen/received_events","type":"User","site_admin":false},"repo":{"id":64735433,"name":"musit","full_name":"kpmeen/musit","owner":{"login":"kpmeen","id":3736963,"avatar_url":"https://avatars.githubusercontent.com/u/3736963?v=3","gravatar_id":"","url":"https://api.github.com/users/kpmeen","html_url":"https://github.com/kpmeen","followers_url":"https://api.github.com/users/kpmeen/followers","following_url":"https://api.github.com/users/kpmeen/following{/other_user}","gists_url":"https://api.github.com/users/kpmeen/gists{/gist_id}","starred_url":"https://api.github.com/users/kpmeen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kpmeen/subscriptions","organizations_url":"https://api.github.com/users/kpmeen/orgs","repos_url":"https://api.github.com/users/kpmeen/repos","events_url":"https://api.github.com/users/kpmeen/events{/privacy}","received_events_url":"https://api.github.com/users/kpmeen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kpmeen/musit","description":"Norwegian university museums IT organization (MUSIT); cultural history and natural history database with store integration","fork":true,"url":"https://api.github.com/repos/kpmeen/musit","forks_url":"https://api.github.com/repos/kpmeen/musit/forks","keys_url":"https://api.github.com/repos/kpmeen/musit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kpmeen/musit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kpmeen/musit/teams","hooks_url":"https://api.github.com/repos/kpmeen/musit/hooks","issue_events_url":"https://api.github.com/repos/kpmeen/musit/issues/events{/number}","events_url":"https://api.github.com/repos/kpmeen/musit/events","assignees_url":"https://api.github.com/repos/kpmeen/musit/assignees{/user}","branches_url":"https://api.github.com/repos/kpmeen/musit/branches{/branch}","tags_url":"https://api.github.com/repos/kpmeen/musit/tags","blobs_url":"https://api.github.com/repos/kpmeen/musit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kpmeen/musit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kpmeen/musit/git/refs{/sha}","trees_url":"https://api.github.com/repos/kpmeen/musit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kpmeen/musit/statuses/{sha}","languages_url":"https://api.github.com/repos/kpmeen/musit/languages","stargazers_url":"https://api.github.com/repos/kpmeen/musit/stargazers","contributors_url":"https://api.github.com/repos/kpmeen/musit/contributors","subscribers_url":"https://api.github.com/repos/kpmeen/musit/subscribers","subscription_url":"https://api.github.com/repos/kpmeen/musit/subscription","commits_url":"https://api.github.com/repos/kpmeen/musit/commits{/sha}","git_commits_url":"https://api.github.com/repos/kpmeen/musit/git/commits{/sha}","comments_url":"https://api.github.com/repos/kpmeen/musit/comments{/number}","issue_comment_url":"https://api.github.com/repos/kpmeen/musit/issues/comments{/number}","contents_url":"https://api.github.com/repos/kpmeen/musit/contents/{+path}","compare_url":"https://api.github.com/repos/kpmeen/musit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kpmeen/musit/merges","archive_url":"https://api.github.com/repos/kpmeen/musit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kpmeen/musit/downloads","issues_url":"https://api.github.com/repos/kpmeen/musit/issues{/number}","pulls_url":"https://api.github.com/repos/kpmeen/musit/pulls{/number}","milestones_url":"https://api.github.com/repos/kpmeen/musit/milestones{/number}","notifications_url":"https://api.github.com/repos/kpmeen/musit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kpmeen/musit/labels{/name}","releases_url":"https://api.github.com/repos/kpmeen/musit/releases{/id}","deployments_url":"https://api.github.com/repos/kpmeen/musit/deployments","created_at":"2016-08-02T07:39:07Z","updated_at":"2016-08-02T07:39:09Z","pushed_at":"2016-12-03T11:21:58Z","git_url":"git://github.com/kpmeen/musit.git","ssh_url":"git@github.com:kpmeen/musit.git","clone_url":"https://github.com/kpmeen/musit.git","svn_url":"https://github.com/kpmeen/musit","homepage":"","size":17024,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"MUSIT-Norway:master","ref":"master","sha":"61a57efff9acb9e8e1478a3996906190896eb56b","user":{"login":"MUSIT-Norway","id":17343809,"avatar_url":"https://avatars.githubusercontent.com/u/17343809?v=3","gravatar_id":"","url":"https://api.github.com/users/MUSIT-Norway","html_url":"https://github.com/MUSIT-Norway","followers_url":"https://api.github.com/users/MUSIT-Norway/followers","following_url":"https://api.github.com/users/MUSIT-Norway/following{/other_user}","gists_url":"https://api.github.com/users/MUSIT-Norway/gists{/gist_id}","starred_url":"https://api.github.com/users/MUSIT-Norway/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MUSIT-Norway/subscriptions","organizations_url":"https://api.github.com/users/MUSIT-Norway/orgs","repos_url":"https://api.github.com/users/MUSIT-Norway/repos","events_url":"https://api.github.com/users/MUSIT-Norway/events{/privacy}","received_events_url":"https://api.github.com/users/MUSIT-Norway/received_events","type":"Organization","site_admin":false},"repo":{"id":52344845,"name":"musit","full_name":"MUSIT-Norway/musit","owner":{"login":"MUSIT-Norway","id":17343809,"avatar_url":"https://avatars.githubusercontent.com/u/17343809?v=3","gravatar_id":"","url":"https://api.github.com/users/MUSIT-Norway","html_url":"https://github.com/MUSIT-Norway","followers_url":"https://api.github.com/users/MUSIT-Norway/followers","following_url":"https://api.github.com/users/MUSIT-Norway/following{/other_user}","gists_url":"https://api.github.com/users/MUSIT-Norway/gists{/gist_id}","starred_url":"https://api.github.com/users/MUSIT-Norway/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MUSIT-Norway/subscriptions","organizations_url":"https://api.github.com/users/MUSIT-Norway/orgs","repos_url":"https://api.github.com/users/MUSIT-Norway/repos","events_url":"https://api.github.com/users/MUSIT-Norway/events{/privacy}","received_events_url":"https://api.github.com/users/MUSIT-Norway/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MUSIT-Norway/musit","description":"Norwegian university museums IT organization (MUSIT); cultural history and natural history database with store integration","fork":false,"url":"https://api.github.com/repos/MUSIT-Norway/musit","forks_url":"https://api.github.com/repos/MUSIT-Norway/musit/forks","keys_url":"https://api.github.com/repos/MUSIT-Norway/musit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MUSIT-Norway/musit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MUSIT-Norway/musit/teams","hooks_url":"https://api.github.com/repos/MUSIT-Norway/musit/hooks","issue_events_url":"https://api.github.com/repos/MUSIT-Norway/musit/issues/events{/number}","events_url":"https://api.github.com/repos/MUSIT-Norway/musit/events","assignees_url":"https://api.github.com/repos/MUSIT-Norway/musit/assignees{/user}","branches_url":"https://api.github.com/repos/MUSIT-Norway/musit/branches{/branch}","tags_url":"https://api.github.com/repos/MUSIT-Norway/musit/tags","blobs_url":"https://api.github.com/repos/MUSIT-Norway/musit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MUSIT-Norway/musit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MUSIT-Norway/musit/git/refs{/sha}","trees_url":"https://api.github.com/repos/MUSIT-Norway/musit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MUSIT-Norway/musit/statuses/{sha}","languages_url":"https://api.github.com/repos/MUSIT-Norway/musit/languages","stargazers_url":"https://api.github.com/repos/MUSIT-Norway/musit/stargazers","contributors_url":"https://api.github.com/repos/MUSIT-Norway/musit/contributors","subscribers_url":"https://api.github.com/repos/MUSIT-Norway/musit/subscribers","subscription_url":"https://api.github.com/repos/MUSIT-Norway/musit/subscription","commits_url":"https://api.github.com/repos/MUSIT-Norway/musit/commits{/sha}","git_commits_url":"https://api.github.com/repos/MUSIT-Norway/musit/git/commits{/sha}","comments_url":"https://api.github.com/repos/MUSIT-Norway/musit/comments{/number}","issue_comment_url":"https://api.github.com/repos/MUSIT-Norway/musit/issues/comments{/number}","contents_url":"https://api.github.com/repos/MUSIT-Norway/musit/contents/{+path}","compare_url":"https://api.github.com/repos/MUSIT-Norway/musit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MUSIT-Norway/musit/merges","archive_url":"https://api.github.com/repos/MUSIT-Norway/musit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MUSIT-Norway/musit/downloads","issues_url":"https://api.github.com/repos/MUSIT-Norway/musit/issues{/number}","pulls_url":"https://api.github.com/repos/MUSIT-Norway/musit/pulls{/number}","milestones_url":"https://api.github.com/repos/MUSIT-Norway/musit/milestones{/number}","notifications_url":"https://api.github.com/repos/MUSIT-Norway/musit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MUSIT-Norway/musit/labels{/name}","releases_url":"https://api.github.com/repos/MUSIT-Norway/musit/releases{/id}","deployments_url":"https://api.github.com/repos/MUSIT-Norway/musit/deployments","created_at":"2016-02-23T08:53:04Z","updated_at":"2016-11-04T11:15:43Z","pushed_at":"2016-12-03T11:21:59Z","git_url":"git://github.com/MUSIT-Norway/musit.git","ssh_url":"git@github.com:MUSIT-Norway/musit.git","clone_url":"https://github.com/MUSIT-Norway/musit.git","svn_url":"https://github.com/MUSIT-Norway/musit","homepage":"","size":19516,"stargazers_count":7,"watchers_count":7,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":3,"forks":6,"open_issues":3,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/MUSIT-Norway/musit/pulls/217"},"html":{"href":"https://github.com/MUSIT-Norway/musit/pull/217"},"issue":{"href":"https://api.github.com/repos/MUSIT-Norway/musit/issues/217"},"comments":{"href":"https://api.github.com/repos/MUSIT-Norway/musit/issues/217/comments"},"review_comments":{"href":"https://api.github.com/repos/MUSIT-Norway/musit/pulls/217/comments"},"review_comment":{"href":"https://api.github.com/repos/MUSIT-Norway/musit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/MUSIT-Norway/musit/pulls/217/commits"},"statuses":{"href":"https://api.github.com/repos/MUSIT-Norway/musit/statuses/67e45e1ffe199bfd6b7d50dc9df8a533d748e41e"}}}}
{"actor":{"display_login":"codacy-bot"}}