ar-monocle 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +11 -1
- data/lib/monocle/version.rb +1 -1
- data/lib/monocle/view.rb +15 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4605eab43d5ef90c70e7c242c8e76a740cd77a0
|
4
|
+
data.tar.gz: 42cf6093efbda0ee8833413c481f512f99739dbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c5d66e5a7be45c7765d9b49389428da9f67cb6bfcd9b1d37986a22662321ff911715cff84fbfc937d549efba321c3dea457f3afb3a24280ed89de65d5cc8ed3
|
7
|
+
data.tar.gz: 1ad0d0d5d0c79bedbe5d8a477a0ef7dac5f9b34290cc4aba44e4418e1588ecc5c6305843bde1271c1eb147d41d6f3706e115d58d4fb892491008409b49c9a5f9
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -81,7 +81,17 @@ With monocle, you decide when it's time to upgrade a view. So even if you have a
|
|
81
81
|
|
82
82
|
$ rake monocle:bump[my_view_name]
|
83
83
|
|
84
|
-
|
84
|
+
### Refresh a view
|
85
|
+
|
86
|
+
For materialized views, this makes it easy for you to trigger a refresh, say, in a cron job or something.
|
87
|
+
|
88
|
+
$ rake monocle:refresh[my_view_name]
|
89
|
+
|
90
|
+
### Refresh all views
|
91
|
+
|
92
|
+
This is also available as a top level method for Monocle. It will refresh all your materialized views.
|
93
|
+
|
94
|
+
$ rake monocle:refresh_all
|
85
95
|
|
86
96
|
## Development
|
87
97
|
|
data/lib/monocle/version.rb
CHANGED
data/lib/monocle/view.rb
CHANGED
@@ -69,8 +69,21 @@ module Monocle
|
|
69
69
|
def refresh(concurrently: false)
|
70
70
|
# We don't refresh normal views
|
71
71
|
return false unless materialized?
|
72
|
-
_concurrently = "CONCURRENTLY" if concurrently
|
73
|
-
execute "REFRESH MATERIALIZED VIEW
|
72
|
+
_concurrently = " CONCURRENTLY" if concurrently
|
73
|
+
execute "REFRESH MATERIALIZED VIEW#{_concurrently} #{name}"
|
74
|
+
true
|
75
|
+
rescue ActiveRecord::StatementInvalid => e
|
76
|
+
# This view is trying to select from a different view that hasn't been
|
77
|
+
# populated.
|
78
|
+
if e.message =~ /PG::ObjectNotInPrerequisiteState/ &&
|
79
|
+
e.message.scan(/materialized view \"(\w+)\" has not been populated/) &&
|
80
|
+
list.keys.include?($1.to_sym)
|
81
|
+
warn "Can't refresh #{name} because it depends on #{$1} which hasn't been populated, refreshing that first..."
|
82
|
+
list.fetch($1.to_sym).refresh
|
83
|
+
retry
|
84
|
+
else
|
85
|
+
fail e
|
86
|
+
end
|
74
87
|
end
|
75
88
|
|
76
89
|
def slug
|