monocle-views 0.1.7 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/monocle.rb +5 -0
- data/lib/monocle/generators/matview_generator.rb +1 -0
- data/lib/monocle/version.rb +1 -1
- data/lib/monocle/version_generator.rb +10 -4
- data/lib/monocle/view.rb +13 -0
- data/lib/tasks/monocle.rake +7 -1
- 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: 53586f4daaba8fb51c88c7e6a21120a3f4e6ab16
|
4
|
+
data.tar.gz: f76088758289e841ff8b6d1d90a12963b41995c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f04d6a94c484e8c9f9fafb6d60128ed532c294494d67608dfca41e1c521964bfdb0c52520c1ffc3a046c7fad25ce93b2ad9001d1eed30f3f8dec260c83eb1b42
|
7
|
+
data.tar.gz: 8eb2112b7f67c0883cdcda43469b076e846e829a93abdc7b27ad2e54389db2ba23566b4d90b212a1778179505d8a0e5d105bb2c7fa5a57e00dbd317a06089692
|
data/lib/monocle.rb
CHANGED
@@ -11,6 +11,7 @@ require "monocle/view"
|
|
11
11
|
require "monocle/migration"
|
12
12
|
|
13
13
|
require "monocle/bump_command"
|
14
|
+
require "monocle/drop_command"
|
14
15
|
require "monocle/list_command"
|
15
16
|
|
16
17
|
module Monocle
|
@@ -47,6 +48,10 @@ module Monocle
|
|
47
48
|
BumpCommand.new(fetch(view_name)).call
|
48
49
|
end
|
49
50
|
|
51
|
+
def drop(view_name)
|
52
|
+
DropCommand.new(fetch(view_name)).call
|
53
|
+
end
|
54
|
+
|
50
55
|
def refresh(view_name, concurrently: false)
|
51
56
|
fetch(view_name).refresh concurrently: concurrently
|
52
57
|
end
|
data/lib/monocle/version.rb
CHANGED
@@ -9,10 +9,16 @@ module Monocle
|
|
9
9
|
|
10
10
|
def generate
|
11
11
|
timestamp = File.open path, &:readline
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
case timestamp
|
13
|
+
when /^-- Timestamp:/
|
14
|
+
# Get only the digits out of the timestamp line
|
15
|
+
timestamp.gsub!(/[^\d]/, '')
|
16
|
+
return "#{view}_#{timestamp}"
|
17
|
+
when /^-- Drop/
|
18
|
+
return :drop
|
19
|
+
else
|
20
|
+
fail "can't read timestamp of #{path}! Aborting..."
|
21
|
+
end
|
16
22
|
end
|
17
23
|
end
|
18
24
|
end
|
data/lib/monocle/view.rb
CHANGED
@@ -16,6 +16,9 @@ module Monocle
|
|
16
16
|
!!(@materialized ||= create_command =~ /MATERIALIZED VIEW/i)
|
17
17
|
end
|
18
18
|
|
19
|
+
def drop_requested?
|
20
|
+
end
|
21
|
+
|
19
22
|
def drop
|
20
23
|
debug "Dropping #{name}..."
|
21
24
|
self.dependants = get_dependants_from_pg
|
@@ -46,6 +49,11 @@ module Monocle
|
|
46
49
|
end
|
47
50
|
|
48
51
|
def migrate
|
52
|
+
if :drop == slug
|
53
|
+
drop
|
54
|
+
info "#{name} dropped."
|
55
|
+
return true
|
56
|
+
end
|
49
57
|
if versions.include?(slug)
|
50
58
|
debug "Skipping #{name} as it's already up to date."
|
51
59
|
true
|
@@ -57,6 +65,11 @@ module Monocle
|
|
57
65
|
end
|
58
66
|
|
59
67
|
def refresh(concurrently: false)
|
68
|
+
if :drop == slug
|
69
|
+
drop
|
70
|
+
info "#{name} dropped."
|
71
|
+
return true
|
72
|
+
end
|
60
73
|
# We don't refresh normal views
|
61
74
|
return false unless materialized?
|
62
75
|
_concurrently = " CONCURRENTLY" if concurrently
|
data/lib/tasks/monocle.rake
CHANGED
@@ -20,7 +20,7 @@ namespace :monocle do
|
|
20
20
|
Monocle.refresh(args.view_name)
|
21
21
|
end
|
22
22
|
|
23
|
-
desc "Refreshes
|
23
|
+
desc "Refreshes all monocle views"
|
24
24
|
task :refresh_all => :environment do |t, args|
|
25
25
|
Monocle.refresh_all
|
26
26
|
end
|
@@ -31,4 +31,10 @@ namespace :monocle do
|
|
31
31
|
view_name = args.view_name
|
32
32
|
Monocle.bump(view_name)
|
33
33
|
end
|
34
|
+
|
35
|
+
desc "drop a monocle view"
|
36
|
+
task :drop, [:view_name] => :environment do |t, args|
|
37
|
+
view_name = args.view_name
|
38
|
+
Monocle.drop(view_name)
|
39
|
+
end
|
34
40
|
end
|