{"action":"created","comment":{"url":"https://api.github.com/repos/Wikia/pandora/pulls/comments/26858573","id":26858573,"diff_hunk":"@@ -0,0 +1,126 @@\n+package com.wikia.communitydata.core;\n+\n+import static com.wikia.jooq.generated.wikicities.Tables.CITY_DOMAINS;\n+import static com.wikia.jooq.generated.wikicities.Tables.CITY_LIST;\n+import static com.wikia.jooq.generated.wikicities.Tables.CITY_VARIABLES;\n+import static com.wikia.jooq.generated.wikicities.Tables.CITY_VERTICALS;\n+import static net.logstash.logback.marker.Markers.appendEntries;\n+\n+import com.wikia.jooq.generated.wikicities.tables.records.CityListRecord;\n+import com.wikia.jooq.generated.wikicities.tables.records.CityVariablesRecord;\n+import com.wikia.jooq.generated.wikicities.tables.records.CityVerticalsRecord;\n+import com.wikia.nirvana.NirvanaHelper;\n+import com.wikia.nirvana.converters.Namespace;\n+import com.wikia.nirvana.generated.ApiException;\n+import com.wikia.nirvana.generated.api.MercuryApi;\n+import com.wikia.nirvana.generated.model.NavigationItem;\n+import com.wikia.nirvana.generated.model.WikiDataContainer;\n+import com.wikia.nirvana.generated.model.WikiLanguageData;\n+\n+import com.google.common.collect.ImmutableMap;\n+import de.ailis.pherialize.Pherialize;\n+import org.jooq.DSLContext;\n+import org.jooq.Record;\n+import org.jooq.types.UShort;\n+import org.slf4j.LoggerFactory;\n+\n+import java.util.List;\n+\n+public class CommunityDataProvider {\n+  private static final UShort ARTICLE_PATH_ID = UShort.valueOf(15);\n+  private static final String DEFAULT_ARTICLE_PATH = \"/wiki/$1\";\n+\n+  public CommunityData getCommunityData(DSLContext db, String domain) {\n+    CommunityData communityData = null;\n+\n+    Record result = db\n+        .select(CITY_LIST.CITY_DBNAME,\n+                CITY_LIST.CITY_SITENAME,\n+                CITY_LIST.CITY_ADULT,\n+                CITY_LIST.CITY_TITLE,\n+                CITY_LIST.CITY_DESCRIPTION,\n+                CITY_VERTICALS.VERTICAL_NAME,\n+                CITY_VARIABLES.CV_VALUE)\n+        .from(CITY_LIST\n+                  .join(CITY_DOMAINS)\n+                  .on(CITY_DOMAINS.CITY_ID.equal(CITY_LIST.CITY_ID))\n+                  .join(CITY_VERTICALS)\n+                  .on(CITY_VERTICALS.VERTICAL_ID.equal(CITY_LIST.CITY_VERTICAL))\n+                  .leftOuterJoin(CITY_VARIABLES)\n+                  .on(CITY_VARIABLES.CV_CITY_ID.equal(CITY_LIST.CITY_ID)\n+                          .and(CITY_VARIABLES.CV_VARIABLE_ID.equal(ARTICLE_PATH_ID))))\n+        .where(CITY_DOMAINS.CITY_DOMAIN.equal(domain))\n+        .fetchOne();\n+\n+    if (result != null) {\n+      CityListRecord cityListRecord = result.into(CITY_LIST);\n+      CityVerticalsRecord cityVerticalsRecord = result.into(CITY_VERTICALS);\n+\n+      NavigationItem navigation = null;\n+      List<Namespace> namespaces = null;\n+      WikiLanguageData languageData = null;\n+\n+      try {\n+        MercuryApi mercuryApi = NirvanaHelper.getApi(domain, MercuryApi.class);\n+        WikiDataContainer wikiDataContainer = mercuryApi.getWikiData();\n+\n+        if (wikiDataContainer != null) {\n+          navigation = wikiDataContainer.getData().getNavData().getNavigation();\n+          namespaces = Namespace.fromMap(wikiDataContainer.getData().getNamespaces());\n+          languageData = wikiDataContainer.getData().getLanguage();\n+        }\n+      } catch (Exception e) {\n+        LoggerFactory.getLogger(this.getClass()).error(\n+            appendEntries(\n+                new ImmutableMap.Builder<String, String>()\n+                    .put(\"domain\", domain)\n+                    .build()\n+            ),\n+            \"error fetching nirvana data for community\",\n+            e\n+        );\n+      }\n+\n+      communityData = new CommunityData(","path":"service/community-data/src/main/java/com/wikia/communitydata/core/CommunityDataProvider.java","position":null,"original_position":84,"commit_id":"24c3be91b3387bf97221fb3f8ef902892b1fb545","original_commit_id":"0f0a40b2916596eaa48da0644cf035557c566d39","user":{"login":"nmonterroso","id":325800,"avatar_url":"https://avatars.githubusercontent.com/u/325800?v=3","gravatar_id":"","url":"https://api.github.com/users/nmonterroso","html_url":"https://github.com/nmonterroso","followers_url":"https://api.github.com/users/nmonterroso/followers","following_url":"https://api.github.com/users/nmonterroso/following{/other_user}","gists_url":"https://api.github.com/users/nmonterroso/gists{/gist_id}","starred_url":"https://api.github.com/users/nmonterroso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmonterroso/subscriptions","organizations_url":"https://api.github.com/users/nmonterroso/orgs","repos_url":"https://api.github.com/users/nmonterroso/repos","events_url":"https://api.github.com/users/nmonterroso/events{/privacy}","received_events_url":"https://api.github.com/users/nmonterroso/received_events","type":"User","site_admin":false},"body":"Good idea. Added in 24c3be9.","created_at":"2015-03-20T17:28:58Z","updated_at":"2015-03-20T17:28:58Z","html_url":"https://github.com/Wikia/pandora/pull/100#discussion_r26858573","pull_request_url":"https://api.github.com/repos/Wikia/pandora/pulls/100","_links":{"self":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/comments/26858573"},"html":{"href":"https://github.com/Wikia/pandora/pull/100#discussion_r26858573"},"pull_request":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/100"}}},"pull_request":{"url":"https://api.github.com/repos/Wikia/pandora/pulls/100","id":31566722,"html_url":"https://github.com/Wikia/pandora/pull/100","diff_url":"https://github.com/Wikia/pandora/pull/100.diff","patch_url":"https://github.com/Wikia/pandora/pull/100.patch","issue_url":"https://api.github.com/repos/Wikia/pandora/issues/100","number":100,"state":"open","locked":false,"title":"Community Data Service","user":{"login":"nmonterroso","id":325800,"avatar_url":"https://avatars.githubusercontent.com/u/325800?v=3","gravatar_id":"","url":"https://api.github.com/users/nmonterroso","html_url":"https://github.com/nmonterroso","followers_url":"https://api.github.com/users/nmonterroso/followers","following_url":"https://api.github.com/users/nmonterroso/following{/other_user}","gists_url":"https://api.github.com/users/nmonterroso/gists{/gist_id}","starred_url":"https://api.github.com/users/nmonterroso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmonterroso/subscriptions","organizations_url":"https://api.github.com/users/nmonterroso/orgs","repos_url":"https://api.github.com/users/nmonterroso/repos","events_url":"https://api.github.com/users/nmonterroso/events{/privacy}","received_events_url":"https://api.github.com/users/nmonterroso/received_events","type":"User","site_admin":false},"body":"@drsnyder @sqreek @pchojnacki \r\nhttps://wikia-inc.atlassian.net/browse/SERVICES-139\r\n\r\nProvides a service to get data about a community. Only resource is `/{domain}` ex: `/leagueoflegends.wikia.com`. Spoke with @kenkouot and this is their preferred method for fetching information for a specific wikia. Also piggybacking in some changes that were required to make this work:\r\n\r\n* [jooq](jooq.org) code generation task\r\n* udpating to latest swagger-codegen version which allows accessing the Nirvana API asynchronously, though this didn't actually end up being used","created_at":"2015-03-19T21:12:18Z","updated_at":"2015-03-20T17:28:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6fd3617a7951347df972cb38e1ca8dc2d03cbdee","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Wikia/pandora/pulls/100/commits","review_comments_url":"https://api.github.com/repos/Wikia/pandora/pulls/100/comments","review_comment_url":"https://api.github.com/repos/Wikia/pandora/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Wikia/pandora/issues/100/comments","statuses_url":"https://api.github.com/repos/Wikia/pandora/statuses/24c3be91b3387bf97221fb3f8ef902892b1fb545","head":{"label":"Wikia:SERVICES-139","ref":"SERVICES-139","sha":"24c3be91b3387bf97221fb3f8ef902892b1fb545","user":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"repo":{"id":26663749,"name":"pandora","full_name":"Wikia/pandora","owner":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Wikia/pandora","description":"API Service","fork":false,"url":"https://api.github.com/repos/Wikia/pandora","forks_url":"https://api.github.com/repos/Wikia/pandora/forks","keys_url":"https://api.github.com/repos/Wikia/pandora/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wikia/pandora/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wikia/pandora/teams","hooks_url":"https://api.github.com/repos/Wikia/pandora/hooks","issue_events_url":"https://api.github.com/repos/Wikia/pandora/issues/events{/number}","events_url":"https://api.github.com/repos/Wikia/pandora/events","assignees_url":"https://api.github.com/repos/Wikia/pandora/assignees{/user}","branches_url":"https://api.github.com/repos/Wikia/pandora/branches{/branch}","tags_url":"https://api.github.com/repos/Wikia/pandora/tags","blobs_url":"https://api.github.com/repos/Wikia/pandora/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wikia/pandora/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wikia/pandora/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wikia/pandora/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wikia/pandora/statuses/{sha}","languages_url":"https://api.github.com/repos/Wikia/pandora/languages","stargazers_url":"https://api.github.com/repos/Wikia/pandora/stargazers","contributors_url":"https://api.github.com/repos/Wikia/pandora/contributors","subscribers_url":"https://api.github.com/repos/Wikia/pandora/subscribers","subscription_url":"https://api.github.com/repos/Wikia/pandora/subscription","commits_url":"https://api.github.com/repos/Wikia/pandora/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wikia/pandora/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wikia/pandora/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wikia/pandora/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wikia/pandora/contents/{+path}","compare_url":"https://api.github.com/repos/Wikia/pandora/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wikia/pandora/merges","archive_url":"https://api.github.com/repos/Wikia/pandora/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wikia/pandora/downloads","issues_url":"https://api.github.com/repos/Wikia/pandora/issues{/number}","pulls_url":"https://api.github.com/repos/Wikia/pandora/pulls{/number}","milestones_url":"https://api.github.com/repos/Wikia/pandora/milestones{/number}","notifications_url":"https://api.github.com/repos/Wikia/pandora/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wikia/pandora/labels{/name}","releases_url":"https://api.github.com/repos/Wikia/pandora/releases{/id}","created_at":"2014-11-15T00:29:06Z","updated_at":"2015-03-20T13:57:05Z","pushed_at":"2015-03-20T17:28:47Z","git_url":"git://github.com/Wikia/pandora.git","ssh_url":"git@github.com:Wikia/pandora.git","clone_url":"https://github.com/Wikia/pandora.git","svn_url":"https://github.com/Wikia/pandora","homepage":null,"size":5179,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":6,"forks":1,"open_issues":6,"watchers":3,"default_branch":"master"}},"base":{"label":"Wikia:master","ref":"master","sha":"98a7694eb9c258e191d24a64a200ddb8732bd501","user":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"repo":{"id":26663749,"name":"pandora","full_name":"Wikia/pandora","owner":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Wikia/pandora","description":"API Service","fork":false,"url":"https://api.github.com/repos/Wikia/pandora","forks_url":"https://api.github.com/repos/Wikia/pandora/forks","keys_url":"https://api.github.com/repos/Wikia/pandora/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wikia/pandora/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wikia/pandora/teams","hooks_url":"https://api.github.com/repos/Wikia/pandora/hooks","issue_events_url":"https://api.github.com/repos/Wikia/pandora/issues/events{/number}","events_url":"https://api.github.com/repos/Wikia/pandora/events","assignees_url":"https://api.github.com/repos/Wikia/pandora/assignees{/user}","branches_url":"https://api.github.com/repos/Wikia/pandora/branches{/branch}","tags_url":"https://api.github.com/repos/Wikia/pandora/tags","blobs_url":"https://api.github.com/repos/Wikia/pandora/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wikia/pandora/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wikia/pandora/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wikia/pandora/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wikia/pandora/statuses/{sha}","languages_url":"https://api.github.com/repos/Wikia/pandora/languages","stargazers_url":"https://api.github.com/repos/Wikia/pandora/stargazers","contributors_url":"https://api.github.com/repos/Wikia/pandora/contributors","subscribers_url":"https://api.github.com/repos/Wikia/pandora/subscribers","subscription_url":"https://api.github.com/repos/Wikia/pandora/subscription","commits_url":"https://api.github.com/repos/Wikia/pandora/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wikia/pandora/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wikia/pandora/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wikia/pandora/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wikia/pandora/contents/{+path}","compare_url":"https://api.github.com/repos/Wikia/pandora/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wikia/pandora/merges","archive_url":"https://api.github.com/repos/Wikia/pandora/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wikia/pandora/downloads","issues_url":"https://api.github.com/repos/Wikia/pandora/issues{/number}","pulls_url":"https://api.github.com/repos/Wikia/pandora/pulls{/number}","milestones_url":"https://api.github.com/repos/Wikia/pandora/milestones{/number}","notifications_url":"https://api.github.com/repos/Wikia/pandora/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wikia/pandora/labels{/name}","releases_url":"https://api.github.com/repos/Wikia/pandora/releases{/id}","created_at":"2014-11-15T00:29:06Z","updated_at":"2015-03-20T13:57:05Z","pushed_at":"2015-03-20T17:28:47Z","git_url":"git://github.com/Wikia/pandora.git","ssh_url":"git@github.com:Wikia/pandora.git","clone_url":"https://github.com/Wikia/pandora.git","svn_url":"https://github.com/Wikia/pandora","homepage":null,"size":5179,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":6,"forks":1,"open_issues":6,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/100"},"html":{"href":"https://github.com/Wikia/pandora/pull/100"},"issue":{"href":"https://api.github.com/repos/Wikia/pandora/issues/100"},"comments":{"href":"https://api.github.com/repos/Wikia/pandora/issues/100/comments"},"review_comments":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/100/comments"},"review_comment":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/100/commits"},"statuses":{"href":"https://api.github.com/repos/Wikia/pandora/statuses/24c3be91b3387bf97221fb3f8ef902892b1fb545"}}}}