db2s3 0.3.0 → 0.3.1

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.
Files changed (5) hide show
  1. data/HISTORY +2 -0
  2. data/VERSION +1 -1
  3. data/lib/db2s3.rb +18 -0
  4. data/tasks/tasks.rake +2 -16
  5. metadata +2 -2
data/HISTORY CHANGED
@@ -1,3 +1,5 @@
1
+ 0.3.1 (7 Dec 2009)
2
+ - Fixed hardcoded DB name in statistics task
1
3
  0.3.0 (6 Dec 2009)
2
4
  - Added db2s3:backup:clean task to delete old backups
3
5
  - Added dependency on activesupport for the clean task
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
data/lib/db2s3.rb CHANGED
@@ -53,6 +53,24 @@ class DB2S3
53
53
  end
54
54
  end
55
55
 
56
+ def statistics
57
+ # From http://mysqlpreacher.com/wordpress/tag/table-size/
58
+ results = ActiveRecord::Base.connection.execute(<<-EOS)
59
+ SELECT
60
+ engine,
61
+ ROUND(data_length/1024/1024,2) total_size_mb,
62
+ ROUND(index_length/1024/1024,2) total_index_size_mb,
63
+ table_rows,
64
+ table_name article_attachment
65
+ FROM information_schema.tables
66
+ WHERE table_schema = '#{db_credentials[:database]}'
67
+ ORDER BY 3 desc;
68
+ EOS
69
+ rows = []
70
+ results.each {|x| rows << x.to_a }
71
+ rows
72
+ end
73
+
56
74
  private
57
75
 
58
76
  def dump_db
data/tasks/tasks.rake CHANGED
@@ -18,23 +18,9 @@ namespace :db2s3 do
18
18
 
19
19
  desc "Show table sizes for your database"
20
20
  task :statistics => :environment do
21
- # From http://mysqlpreacher.com/wordpress/tag/table-size/
22
- results = ActiveRecord::Base.connection.execute(<<-EOS)
23
- SELECT
24
- engine,
25
- ROUND(data_length/1024/1024,2) total_size_mb,
26
- ROUND(index_length/1024/1024,2) total_index_size_mb,
27
- table_rows,
28
- table_name article_attachment
29
- FROM information_schema.tables
30
- WHERE table_schema = 'rhnh_production'
31
- ORDER BY 3 desc;
32
- EOS
33
-
34
- rows = []
35
- header = [["Type", "Data MB", "Index", "Rows", "Name"], []]
36
- results.each {|x| rows << x.to_a }
21
+ rows = DB2S3.new.statistics
37
22
  rows.sort_by {|x| -x[3].to_i }
23
+ header = [["Type", "Data MB", "Index", "Rows", "Name"], []]
38
24
  puts (header + rows).collect {|x| x.join("\t") }
39
25
  end
40
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db2s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xavier Shay
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-06 00:00:00 +11:00
12
+ date: 2009-12-07 00:00:00 +11:00
13
13
  default_executable:
14
14
  dependencies: []
15
15