{"action":"created","comment":{"url":"https://api.github.com/repos/scenic-views/scenic/pulls/comments/242391902","pull_request_review_id":185888686,"id":242391902,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MjM5MTkwMg==","diff_hunk":"@@ -132,6 +132,41 @@ module Adapters\n         end\n       end\n \n+      describe \"#materialized_view_populated?\" do\n+        it \"returns true if the view is populated\" do\n+          adapter = Postgres.new\n+          adapter.create_materialized_view(\n+            \"greetings\",\n+            \"SELECT text 'hi' AS greeting\",\n+            no_data: true,\n+          )\n+          adapter.refresh_materialized_view(\"greetings\")\n+\n+          expect(adapter.materialized_view_populated?(\"greetings\")).to eq true\n+        end\n+\n+        it \"returns false if the view is not populated\" do\n+          adapter = Postgres.new\n+          adapter.create_materialized_view(\n+            \"greetings\",\n+            \"SELECT text 'hi' AS greeting\",\n+            no_data: true,","path":"spec/scenic/adapters/postgres_spec.rb","position":22,"original_position":22,"commit_id":"6238916a1cc07e584b7ea2531652baea20fc03ff","original_commit_id":"6238916a1cc07e584b7ea2531652baea20fc03ff","user":{"login":"hound[bot]","id":30008653,"node_id":"MDM6Qm90MzAwMDg2NTM=","avatar_url":"https://avatars1.githubusercontent.com/in/3598?v=4","gravatar_id":"","url":"https://api.github.com/users/hound%5Bbot%5D","html_url":"https://github.com/apps/hound","followers_url":"https://api.github.com/users/hound%5Bbot%5D/followers","following_url":"https://api.github.com/users/hound%5Bbot%5D/following{/other_user}","gists_url":"https://api.github.com/users/hound%5Bbot%5D/gists{/gist_id}","starred_url":"https://api.github.com/users/hound%5Bbot%5D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hound%5Bbot%5D/subscriptions","organizations_url":"https://api.github.com/users/hound%5Bbot%5D/orgs","repos_url":"https://api.github.com/users/hound%5Bbot%5D/repos","events_url":"https://api.github.com/users/hound%5Bbot%5D/events{/privacy}","received_events_url":"https://api.github.com/users/hound%5Bbot%5D/received_events","type":"Bot","site_admin":false},"body":"Style/TrailingCommaInArguments: Avoid comma after the last parameter of a method call.","created_at":"2018-12-18T02:51:10Z","updated_at":"2018-12-18T02:51:11Z","html_url":"https://github.com/scenic-views/scenic/pull/249#discussion_r242391902","pull_request_url":"https://api.github.com/repos/scenic-views/scenic/pulls/249","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/scenic-views/scenic/pulls/comments/242391902"},"html":{"href":"https://github.com/scenic-views/scenic/pull/249#discussion_r242391902"},"pull_request":{"href":"https://api.github.com/repos/scenic-views/scenic/pulls/249"}}},"pull_request":{"url":"https://api.github.com/repos/scenic-views/scenic/pulls/249","id":204382672,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA0MzgyNjcy","html_url":"https://github.com/scenic-views/scenic/pull/249","diff_url":"https://github.com/scenic-views/scenic/pull/249.diff","patch_url":"https://github.com/scenic-views/scenic/pull/249.patch","issue_url":"https://api.github.com/repos/scenic-views/scenic/issues/249","number":249,"state":"open","locked":false,"title":"Add method to return materialized view is populated or not","user":{"login":"fujimura","id":134072,"node_id":"MDQ6VXNlcjEzNDA3Mg==","avatar_url":"https://avatars2.githubusercontent.com/u/134072?v=4","gravatar_id":"","url":"https://api.github.com/users/fujimura","html_url":"https://github.com/fujimura","followers_url":"https://api.github.com/users/fujimura/followers","following_url":"https://api.github.com/users/fujimura/following{/other_user}","gists_url":"https://api.github.com/users/fujimura/gists{/gist_id}","starred_url":"https://api.github.com/users/fujimura/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fujimura/subscriptions","organizations_url":"https://api.github.com/users/fujimura/orgs","repos_url":"https://api.github.com/users/fujimura/repos","events_url":"https://api.github.com/users/fujimura/events{/privacy}","received_events_url":"https://api.github.com/users/fujimura/received_events","type":"User","site_admin":false},"body":"Added a method which return the view is populated or not.\r\n\r\n`REFRESH MATERIALIZED VIEW CONCURRENTLY` doesn't work for a view which is not populated, even it has unique index. This method is useful to perform concurrent refresh if it's possible.\r\n\r\nReal use case in Rails will be like this:\r\n\r\n- Database is loaded from structure.sql to run specs, but the view isn't populated yet so concurrent refresh is not possible. We want to fallback to normal(non-concurrent) refresh in this case.\r\n- After initial population, views are expected to be refreshed concurrently. It's possible because the view is already populated.\r\n\r\nOur team is using a concern below to cope with the case. This pull request is extracted from this.\r\n\r\n```\r\nmodule MaterializedView\r\n  extend ActiveSupport::Concern\r\n\r\n  included do\r\n    class << self\r\n      def materialized_view_populated?\r\n        connection.execute(\"SELECT relispopulated FROM pg_class WHERE relname = '#{table_name}'\").first['relispopulated']\r\n      end\r\n\r\n      def refresh_materialized_view(concurrently = true)\r\n        Scenic.database.refresh_materialized_view(table_name, concurrently: materialized_view_populated? && concurrently, cascade: false)\r\n      end\r\n    end\r\n  end\r\nend\r\n```","created_at":"2018-07-27T09:48:41Z","updated_at":"2018-12-18T02:51:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a57b5a2bcdaf80c7eae62e293b05f1738641a1c4","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/scenic-views/scenic/pulls/249/commits","review_comments_url":"https://api.github.com/repos/scenic-views/scenic/pulls/249/comments","review_comment_url":"https://api.github.com/repos/scenic-views/scenic/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scenic-views/scenic/issues/249/comments","statuses_url":"https://api.github.com/repos/scenic-views/scenic/statuses/6238916a1cc07e584b7ea2531652baea20fc03ff","head":{"label":"fujimura:add-method-to-return-materialized-view-is-populated-or-not","ref":"add-method-to-return-materialized-view-is-populated-or-not","sha":"6238916a1cc07e584b7ea2531652baea20fc03ff","user":{"login":"fujimura","id":134072,"node_id":"MDQ6VXNlcjEzNDA3Mg==","avatar_url":"https://avatars2.githubusercontent.com/u/134072?v=4","gravatar_id":"","url":"https://api.github.com/users/fujimura","html_url":"https://github.com/fujimura","followers_url":"https://api.github.com/users/fujimura/followers","following_url":"https://api.github.com/users/fujimura/following{/other_user}","gists_url":"https://api.github.com/users/fujimura/gists{/gist_id}","starred_url":"https://api.github.com/users/fujimura/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fujimura/subscriptions","organizations_url":"https://api.github.com/users/fujimura/orgs","repos_url":"https://api.github.com/users/fujimura/repos","events_url":"https://api.github.com/users/fujimura/events{/privacy}","received_events_url":"https://api.github.com/users/fujimura/received_events","type":"User","site_admin":false},"repo":{"id":142557187,"node_id":"MDEwOlJlcG9zaXRvcnkxNDI1NTcxODc=","name":"scenic","full_name":"fujimura/scenic","private":false,"owner":{"login":"fujimura","id":134072,"node_id":"MDQ6VXNlcjEzNDA3Mg==","avatar_url":"https://avatars2.githubusercontent.com/u/134072?v=4","gravatar_id":"","url":"https://api.github.com/users/fujimura","html_url":"https://github.com/fujimura","followers_url":"https://api.github.com/users/fujimura/followers","following_url":"https://api.github.com/users/fujimura/following{/other_user}","gists_url":"https://api.github.com/users/fujimura/gists{/gist_id}","starred_url":"https://api.github.com/users/fujimura/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fujimura/subscriptions","organizations_url":"https://api.github.com/users/fujimura/orgs","repos_url":"https://api.github.com/users/fujimura/repos","events_url":"https://api.github.com/users/fujimura/events{/privacy}","received_events_url":"https://api.github.com/users/fujimura/received_events","type":"User","site_admin":false},"html_url":"https://github.com/fujimura/scenic","description":"Versioned database views for Rails","fork":true,"url":"https://api.github.com/repos/fujimura/scenic","forks_url":"https://api.github.com/repos/fujimura/scenic/forks","keys_url":"https://api.github.com/repos/fujimura/scenic/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fujimura/scenic/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fujimura/scenic/teams","hooks_url":"https://api.github.com/repos/fujimura/scenic/hooks","issue_events_url":"https://api.github.com/repos/fujimura/scenic/issues/events{/number}","events_url":"https://api.github.com/repos/fujimura/scenic/events","assignees_url":"https://api.github.com/repos/fujimura/scenic/assignees{/user}","branches_url":"https://api.github.com/repos/fujimura/scenic/branches{/branch}","tags_url":"https://api.github.com/repos/fujimura/scenic/tags","blobs_url":"https://api.github.com/repos/fujimura/scenic/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fujimura/scenic/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fujimura/scenic/git/refs{/sha}","trees_url":"https://api.github.com/repos/fujimura/scenic/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fujimura/scenic/statuses/{sha}","languages_url":"https://api.github.com/repos/fujimura/scenic/languages","stargazers_url":"https://api.github.com/repos/fujimura/scenic/stargazers","contributors_url":"https://api.github.com/repos/fujimura/scenic/contributors","subscribers_url":"https://api.github.com/repos/fujimura/scenic/subscribers","subscription_url":"https://api.github.com/repos/fujimura/scenic/subscription","commits_url":"https://api.github.com/repos/fujimura/scenic/commits{/sha}","git_commits_url":"https://api.github.com/repos/fujimura/scenic/git/commits{/sha}","comments_url":"https://api.github.com/repos/fujimura/scenic/comments{/number}","issue_comment_url":"https://api.github.com/repos/fujimura/scenic/issues/comments{/number}","contents_url":"https://api.github.com/repos/fujimura/scenic/contents/{+path}","compare_url":"https://api.github.com/repos/fujimura/scenic/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fujimura/scenic/merges","archive_url":"https://api.github.com/repos/fujimura/scenic/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fujimura/scenic/downloads","issues_url":"https://api.github.com/repos/fujimura/scenic/issues{/number}","pulls_url":"https://api.github.com/repos/fujimura/scenic/pulls{/number}","milestones_url":"https://api.github.com/repos/fujimura/scenic/milestones{/number}","notifications_url":"https://api.github.com/repos/fujimura/scenic/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fujimura/scenic/labels{/name}","releases_url":"https://api.github.com/repos/fujimura/scenic/releases{/id}","deployments_url":"https://api.github.com/repos/fujimura/scenic/deployments","created_at":"2018-07-27T09:29:09Z","updated_at":"2018-11-26T20:52:08Z","pushed_at":"2018-12-18T02:50:57Z","git_url":"git://github.com/fujimura/scenic.git","ssh_url":"git@github.com:fujimura/scenic.git","clone_url":"https://github.com/fujimura/scenic.git","svn_url":"https://github.com/fujimura/scenic","homepage":"","size":281,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"scenic-views:master","ref":"master","sha":"8071d5eabae617db6b9c26424334defb211a621d","user":{"login":"scenic-views","id":45371432,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ1MzcxNDMy","avatar_url":"https://avatars0.githubusercontent.com/u/45371432?v=4","gravatar_id":"","url":"https://api.github.com/users/scenic-views","html_url":"https://github.com/scenic-views","followers_url":"https://api.github.com/users/scenic-views/followers","following_url":"https://api.github.com/users/scenic-views/following{/other_user}","gists_url":"https://api.github.com/users/scenic-views/gists{/gist_id}","starred_url":"https://api.github.com/users/scenic-views/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scenic-views/subscriptions","organizations_url":"https://api.github.com/users/scenic-views/orgs","repos_url":"https://api.github.com/users/scenic-views/repos","events_url":"https://api.github.com/users/scenic-views/events{/privacy}","received_events_url":"https://api.github.com/users/scenic-views/received_events","type":"Organization","site_admin":false},"repo":{"id":19283674,"node_id":"MDEwOlJlcG9zaXRvcnkxOTI4MzY3NA==","name":"scenic","full_name":"scenic-views/scenic","private":false,"owner":{"login":"scenic-views","id":45371432,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ1MzcxNDMy","avatar_url":"https://avatars0.githubusercontent.com/u/45371432?v=4","gravatar_id":"","url":"https://api.github.com/users/scenic-views","html_url":"https://github.com/scenic-views","followers_url":"https://api.github.com/users/scenic-views/followers","following_url":"https://api.github.com/users/scenic-views/following{/other_user}","gists_url":"https://api.github.com/users/scenic-views/gists{/gist_id}","starred_url":"https://api.github.com/users/scenic-views/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scenic-views/subscriptions","organizations_url":"https://api.github.com/users/scenic-views/orgs","repos_url":"https://api.github.com/users/scenic-views/repos","events_url":"https://api.github.com/users/scenic-views/events{/privacy}","received_events_url":"https://api.github.com/users/scenic-views/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/scenic-views/scenic","description":"Versioned database views for Rails","fork":false,"url":"https://api.github.com/repos/scenic-views/scenic","forks_url":"https://api.github.com/repos/scenic-views/scenic/forks","keys_url":"https://api.github.com/repos/scenic-views/scenic/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scenic-views/scenic/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scenic-views/scenic/teams","hooks_url":"https://api.github.com/repos/scenic-views/scenic/hooks","issue_events_url":"https://api.github.com/repos/scenic-views/scenic/issues/events{/number}","events_url":"https://api.github.com/repos/scenic-views/scenic/events","assignees_url":"https://api.github.com/repos/scenic-views/scenic/assignees{/user}","branches_url":"https://api.github.com/repos/scenic-views/scenic/branches{/branch}","tags_url":"https://api.github.com/repos/scenic-views/scenic/tags","blobs_url":"https://api.github.com/repos/scenic-views/scenic/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scenic-views/scenic/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scenic-views/scenic/git/refs{/sha}","trees_url":"https://api.github.com/repos/scenic-views/scenic/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scenic-views/scenic/statuses/{sha}","languages_url":"https://api.github.com/repos/scenic-views/scenic/languages","stargazers_url":"https://api.github.com/repos/scenic-views/scenic/stargazers","contributors_url":"https://api.github.com/repos/scenic-views/scenic/contributors","subscribers_url":"https://api.github.com/repos/scenic-views/scenic/subscribers","subscription_url":"https://api.github.com/repos/scenic-views/scenic/subscription","commits_url":"https://api.github.com/repos/scenic-views/scenic/commits{/sha}","git_commits_url":"https://api.github.com/repos/scenic-views/scenic/git/commits{/sha}","comments_url":"https://api.github.com/repos/scenic-views/scenic/comments{/number}","issue_comment_url":"https://api.github.com/repos/scenic-views/scenic/issues/comments{/number}","contents_url":"https://api.github.com/repos/scenic-views/scenic/contents/{+path}","compare_url":"https://api.github.com/repos/scenic-views/scenic/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scenic-views/scenic/merges","archive_url":"https://api.github.com/repos/scenic-views/scenic/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scenic-views/scenic/downloads","issues_url":"https://api.github.com/repos/scenic-views/scenic/issues{/number}","pulls_url":"https://api.github.com/repos/scenic-views/scenic/pulls{/number}","milestones_url":"https://api.github.com/repos/scenic-views/scenic/milestones{/number}","notifications_url":"https://api.github.com/repos/scenic-views/scenic/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scenic-views/scenic/labels{/name}","releases_url":"https://api.github.com/repos/scenic-views/scenic/releases{/id}","deployments_url":"https://api.github.com/repos/scenic-views/scenic/deployments","created_at":"2014-04-29T16:36:17Z","updated_at":"2018-12-16T02:59:45Z","pushed_at":"2018-12-18T02:50:58Z","git_url":"git://github.com/scenic-views/scenic.git","ssh_url":"git@github.com:scenic-views/scenic.git","clone_url":"https://github.com/scenic-views/scenic.git","svn_url":"https://github.com/scenic-views/scenic","homepage":"","size":285,"stargazers_count":1927,"watchers_count":1927,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":130,"mirror_url":null,"archived":false,"open_issues_count":20,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":130,"open_issues":20,"watchers":1927,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scenic-views/scenic/pulls/249"},"html":{"href":"https://github.com/scenic-views/scenic/pull/249"},"issue":{"href":"https://api.github.com/repos/scenic-views/scenic/issues/249"},"comments":{"href":"https://api.github.com/repos/scenic-views/scenic/issues/249/comments"},"review_comments":{"href":"https://api.github.com/repos/scenic-views/scenic/pulls/249/comments"},"review_comment":{"href":"https://api.github.com/repos/scenic-views/scenic/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scenic-views/scenic/pulls/249/commits"},"statuses":{"href":"https://api.github.com/repos/scenic-views/scenic/statuses/6238916a1cc07e584b7ea2531652baea20fc03ff"}},"author_association":"NONE"}}
{"actor":{"display_login":"hound"}}