osmosis 0.1.8 → 0.1.9

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
  SHA256:
3
- metadata.gz: c04401d175133d21d021ebbe2567a6ece2afd498368e7cea5d1be9c049bcbf1f
4
- data.tar.gz: e8ab7a5e7074c4d96735dcdacacfaaab1f9b781f611cbef84e71a2210d17441b
3
+ metadata.gz: e57f00785e0aba7cd790404973ed6406ee765183ac531aca29222d880f39f567
4
+ data.tar.gz: 2577ac906cea414ce5aa5ff1a01326344154b155a8ec8bfe65c452fb67597937
5
5
  SHA512:
6
- metadata.gz: 13e70d75144e24b2cfc94f65c7bb397c2afb2a72e0a8dd0754fa0a8c707b6fea14a86e67d6ff26759097cb1e0e9684d3d176f7c6bbbb659af4c10cdd5d4fcdbf
7
- data.tar.gz: 726925f0485199c9d9f779350149a971f8baa44a578df98bde24da033b134e8c16b08a528412baa9b337aaa91b9e39ecd17c6ab9d78fe9524e8b43e40d9733a0
6
+ metadata.gz: e5a014c5163b1013b83fa6860afc9f400e1232be6436b0992914208e4030584ae956048d98ac07a25d1dc0bf41c4a91b12656853a4c71708be1fa3ad42e7588c
7
+ data.tar.gz: 11d0aecc24b52d1989737311e6b965da2f4645e8270688efcd99f506cad3304e27f2015c34999d18d2eaf33ae2a1e193b9d058fd795cf357a693957a52d0d8e3
@@ -50,6 +50,22 @@ module Osmosis
50
50
  ]
51
51
  end
52
52
 
53
+ def self.analyze()
54
+ database = ActiveRecord::Base.connection_db_config.database
55
+ return [
56
+ OpenStruct.new(type: :sql, command: "ANALYZE")
57
+ OpenStruct.new(type: :print, command: "Analyzed database '#{database}'")
58
+ ]
59
+ end
60
+
61
+ def self.vacuum_analyze()
62
+ database = ActiveRecord::Base.connection_db_config.database
63
+ return [
64
+ OpenStruct.new(type: :sql, command: "VACUUM ANALYZE")
65
+ OpenStruct.new(type: :print, command: "Vacuum analyzed database '#{database}'")
66
+ ]
67
+ end
68
+
53
69
  def self.run(commands)
54
70
  commands.each do |cmd|
55
71
  if cmd.type == :rake
@@ -58,6 +74,8 @@ module Osmosis
58
74
  system cmd.command
59
75
  elsif cmd.type == :print
60
76
  puts cmd.command
77
+ elsif cmd.type == :sql
78
+ ActiveRecord::Base.connection.execute(cmd.command)
61
79
  elsif cmd.type == :pty
62
80
  PTY.spawn(cmd.command) do |stdout, stdin, pid|
63
81
  trap("INT") { Process.kill("INT", pid) }
@@ -0,0 +1,13 @@
1
+ namespace :db do
2
+ desc "Analyze database tables for query optimization"
3
+ task analyze: :environment do
4
+ commands = Osmosis::Command.analyze()
5
+ Osmosis::Command.run(commands)
6
+ end
7
+
8
+ desc "Vacuum and analyze database"
9
+ task vacuum_analyze: :environment do
10
+ commands = Osmosis::Command.vacuum_analyze()
11
+ Osmosis::Command.run(commands)
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Osmosis
4
- VERSION = "0.1.8"
4
+ VERSION = "0.1.9"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osmosis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas_Skywalker
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-16 00:00:00.000000000 Z
11
+ date: 2025-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ostruct
@@ -42,6 +42,7 @@ files:
42
42
  - lib/osmosis.rb
43
43
  - lib/osmosis/command.rb
44
44
  - lib/osmosis/railtie.rb
45
+ - lib/osmosis/tasks/db/analyze.rake
45
46
  - lib/osmosis/tasks/db/connect.rake
46
47
  - lib/osmosis/tasks/db/export.rake
47
48
  - lib/osmosis/tasks/db/import.rake
@@ -70,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
71
  - !ruby/object:Gem::Version
71
72
  version: '0'
72
73
  requirements: []
73
- rubygems_version: 3.5.16
74
+ rubygems_version: 3.5.22
74
75
  signing_key:
75
76
  specification_version: 4
76
77
  summary: A versatile database utility library that streamlines common tasks like exporting