viewy 0.0.11 → 0.1.0
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62560b62ac3aa4943d8558eb2c6b9579bf65e57b
|
4
|
+
data.tar.gz: 0f5670763c82cebadaf5f968cddd0bee6fefe8e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4e4c8ad48a4964fa2290bfa9c7186e8700e4a89620f859d20e3acd2091ae8d2ebef75f152fadcb94051fbf028b895af21cbe40cedeff7078b3dc9b5c2897284
|
7
|
+
data.tar.gz: 5efc54a37a6e6d12621f033abb3bafeab1c039b4a7e2cdbdd303f94c1fa89e8d94e5c30fbf33d2a79aa5f087687f520eb6f3c2fb1365832d745f0dbf922b2219
|
@@ -11,11 +11,9 @@ module Viewy
|
|
11
11
|
# @raise [ActiveRecord::StatementInvalidError] raised if a dependent view is somehow not refreshed correctly
|
12
12
|
#
|
13
13
|
# @return [PG::Result] the result of the refresh statement on the materialized view
|
14
|
-
def refresh!
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
refresh_without_dependencies!
|
14
|
+
def refresh!(concurrently: false)
|
15
|
+
refresher = Viewy::DependencyManagement::ViewRefresher.new(Viewy.connection)
|
16
|
+
refresher.refresh_materialized_view(table_name, with_dependencies: true, concurrently: concurrently)
|
19
17
|
end
|
20
18
|
|
21
19
|
# Refreshes this view without refreshing any dependencies
|
@@ -23,11 +21,12 @@ module Viewy
|
|
23
21
|
# @raise [ActiveRecord::StatementInvalidError] raised if a dependent view is somehow not refreshed correctly
|
24
22
|
#
|
25
23
|
# @return [PG::Result] the result of the refresh statement on the materialized view
|
26
|
-
def refresh_without_dependencies!
|
27
|
-
|
24
|
+
def refresh_without_dependencies!(concurrently: false)
|
25
|
+
refresher = Viewy::DependencyManagement::ViewRefresher.new(Viewy.connection)
|
26
|
+
refresher.refresh_materialized_view(table_name, with_dependencies: false, concurrently: concurrently)
|
28
27
|
end
|
29
28
|
|
30
|
-
# Provides an array of sorted view
|
29
|
+
# Provides an array of sorted view dependencies
|
31
30
|
#
|
32
31
|
# @return [Array<String>]
|
33
32
|
def sorted_view_dependencies
|
@@ -19,24 +19,46 @@ module Viewy
|
|
19
19
|
# This method will refresh all materialized views in order of dependency
|
20
20
|
def refresh_all_materialized_views
|
21
21
|
@sorter.sorted_materialized_views.each do |view_name|
|
22
|
-
|
22
|
+
refresh_single_view(view_name, concurrently: false)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
# Refreshes a single materialized view
|
27
27
|
#
|
28
28
|
# @param view_name [String] the name of a materialized view
|
29
|
-
def refresh_materialized_view(view_name)
|
30
|
-
|
29
|
+
def refresh_materialized_view(view_name, with_dependencies: false, concurrently: false)
|
30
|
+
if with_dependencies
|
31
|
+
refresh_dependent_views(view_name, concurrently: concurrently)
|
32
|
+
end
|
33
|
+
refresh_single_view(view_name, concurrently: concurrently)
|
34
|
+
end
|
35
|
+
|
36
|
+
private def refresh_dependent_views(view_name, concurrently:)
|
37
|
+
view_dep = Viewy::Models::MaterializedViewDependency.find(view_name)
|
38
|
+
dependencies = @sorter.sorted_materialized_view_subset(view_names: view_dep.view_dependencies)
|
39
|
+
dependencies.each do |view_dependency|
|
40
|
+
refresh_single_view(view_dependency, concurrently: concurrently)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private def refresh_single_view(view_name, concurrently:)
|
45
|
+
connection.execute(refresh_sql(view_name, concurrently))
|
31
46
|
end
|
32
47
|
|
33
48
|
# @param name [String] the name of a materialized view
|
34
49
|
# @return [String] the SQL statement needed to refresh the passed view
|
35
|
-
def refresh_sql(name)
|
50
|
+
private def refresh_sql(name, concurrently)
|
51
|
+
return concurrent_refersh_sql(name) if concurrently
|
36
52
|
<<-SQL.strip
|
37
53
|
REFRESH MATERIALIZED VIEW #{name}
|
38
54
|
SQL
|
39
55
|
end
|
56
|
+
|
57
|
+
private def concurrent_refersh_sql(name)
|
58
|
+
<<-SQL.strip
|
59
|
+
REFRESH MATERIALIZED VIEW CONCURRENTLY #{name}
|
60
|
+
SQL
|
61
|
+
end
|
40
62
|
end
|
41
63
|
end
|
42
64
|
end
|
data/lib/viewy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: viewy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emerson Huitt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|