active_house 0.6.6 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/tests.yml +27 -0
- data/Gemfile +6 -0
- data/README.md +2 -0
- data/active_house.gemspec +0 -4
- data/bin/setup +0 -0
- data/lib/active_house/configuration.rb +1 -1
- data/lib/active_house/connection.rb +1 -1
- data/lib/active_house/model.rb +1 -0
- data/lib/active_house/modeling/attributes.rb +8 -0
- data/lib/active_house/version.rb +1 -1
- data/lib/active_house.rb +3 -0
- data/lib/clickhouse/connection/post_query.rb +47 -0
- metadata +5 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 37ab26790fba1015a2f2ac44b0ddf9005522cd7ac95c4d23bb14e53f3150e056
|
4
|
+
data.tar.gz: 4e2019851cac1a421b271affce47ebd307ae359b91065221865fbd58bda4c30a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60710bbb58d4a18f03ba694ca0030824be1cf380b2ea2ac47f8d63121d854c2d87a9a791773bff413fe8ffb039defe3929b12eafb8a478e2672a1e5e7db99e40
|
7
|
+
data.tar.gz: 5e8dcb184f5a032d35bfeb2304c54ec150a8a4b3fabe1ef6d0e0e69dbc059cf628f9fb14644cf53515be329fc2c277ce79e48baf2e70b1485cf265a61825295b
|
@@ -0,0 +1,27 @@
|
|
1
|
+
name: Tests
|
2
|
+
on:
|
3
|
+
pull_request:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
test:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
strategy:
|
12
|
+
matrix:
|
13
|
+
ruby: [ '2.5', '2.6', '2.7' ]
|
14
|
+
rails: [ '~> 5.0', '~> 6.0' ]
|
15
|
+
name: Tests with Ruby ${{ matrix.ruby }} Activemodel/Activesupport ${{ matrix.rails }}
|
16
|
+
env:
|
17
|
+
RAILS_VERSION: ${{ matrix.rails }}
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v2
|
20
|
+
- uses: actions/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: ${{ matrix.ruby }}
|
23
|
+
- name: Run tests
|
24
|
+
run: |
|
25
|
+
gem install bundler
|
26
|
+
bundle install
|
27
|
+
bundle exec rake
|
data/Gemfile
CHANGED
@@ -5,6 +5,12 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
5
5
|
# Specify your gem's dependencies in active_house.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
+
gem 'activemodel', ENV['RAILS_VERSION'], require: false
|
9
|
+
gem 'activesupport', ENV['RAILS_VERSION'], require: false
|
10
|
+
|
8
11
|
group :test do
|
12
|
+
gem 'minitest', '~> 5.0', require: false
|
13
|
+
gem 'rake', '~> 10.0', require: false
|
9
14
|
gem 'rubocop', '0.58.1', require: false
|
15
|
+
gem 'webmock', require: false
|
10
16
|
end
|
data/README.md
CHANGED
data/active_house.gemspec
CHANGED
@@ -27,8 +27,4 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_dependency 'clickhouse', '~> 0.1.10'
|
28
28
|
spec.add_dependency 'kaminari-core', '~> 1.1'
|
29
29
|
spec.add_dependency 'plain_model', '~> 0.2'
|
30
|
-
|
31
|
-
spec.add_development_dependency 'bundler', '~> 1.16'
|
32
|
-
spec.add_development_dependency 'minitest', '~> 5.0'
|
33
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
34
30
|
end
|
data/bin/setup
CHANGED
File without changes
|
data/lib/active_house/model.rb
CHANGED
data/lib/active_house/version.rb
CHANGED
data/lib/active_house.rb
CHANGED
@@ -3,6 +3,9 @@ require 'active_house/configuration'
|
|
3
3
|
require 'active_house/model'
|
4
4
|
require 'active_house/query_builder'
|
5
5
|
|
6
|
+
require 'clickhouse/connection/post_query'
|
7
|
+
Clickhouse::Connection.include Clickhouse::Connection::PostQuery
|
8
|
+
|
6
9
|
module ActiveHouse
|
7
10
|
def self.configure
|
8
11
|
yield configuration
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Clickhouse
|
2
|
+
class Connection
|
3
|
+
# By default Clickhouse uses GET request for query, but it has limitation for length on server side.
|
4
|
+
# So we will allow to use POST request with query in a body.
|
5
|
+
module PostQuery
|
6
|
+
|
7
|
+
def post_query(query)
|
8
|
+
query = Utils.extract_format(query)[0]
|
9
|
+
query += ' FORMAT JSONCompact'
|
10
|
+
parse_data post(nil, query)
|
11
|
+
end
|
12
|
+
|
13
|
+
def select_rows(options)
|
14
|
+
post_query to_select_query(options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def request(method, query, body = nil)
|
18
|
+
raise ArgumentError, 'when query is omitted body must be passed' if query.nil? && body.nil?
|
19
|
+
|
20
|
+
connect!
|
21
|
+
body = body.strip unless body.nil?
|
22
|
+
query = query.strip unless query.nil?
|
23
|
+
|
24
|
+
start = Time.now
|
25
|
+
|
26
|
+
headers = { 'Content-Type' => 'text/plain' }
|
27
|
+
response = client.send(method, path(query), body, headers)
|
28
|
+
status = response.status
|
29
|
+
duration = Time.now - start
|
30
|
+
if query.nil?
|
31
|
+
query, format = Utils.extract_format(body)
|
32
|
+
else
|
33
|
+
query, format = Utils.extract_format(query)
|
34
|
+
end
|
35
|
+
response = parse_body(format, response.body)
|
36
|
+
stats = parse_stats(response)
|
37
|
+
|
38
|
+
write_log duration, query, stats
|
39
|
+
raise QueryError, "Got status #{status} (expected 200): #{response}" unless status == 200
|
40
|
+
response
|
41
|
+
rescue Faraday::Error => e
|
42
|
+
raise ConnectionError, e.message
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_house
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Talakevich
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -80,48 +80,6 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.2'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: bundler
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '1.16'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '1.16'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: minitest
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '5.0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '5.0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rake
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '10.0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '10.0'
|
125
83
|
description: ORM and Query DSL for ClickHouse
|
126
84
|
email:
|
127
85
|
- senid231@gmail.com
|
@@ -129,6 +87,7 @@ executables: []
|
|
129
87
|
extensions: []
|
130
88
|
extra_rdoc_files: []
|
131
89
|
files:
|
90
|
+
- ".github/workflows/tests.yml"
|
132
91
|
- ".gitignore"
|
133
92
|
- ".rubocop.yml"
|
134
93
|
- ".travis.yml"
|
@@ -166,6 +125,7 @@ files:
|
|
166
125
|
- lib/active_house/querying/union.rb
|
167
126
|
- lib/active_house/querying/where.rb
|
168
127
|
- lib/active_house/version.rb
|
128
|
+
- lib/clickhouse/connection/post_query.rb
|
169
129
|
homepage: https://github.com/senid231/active_house
|
170
130
|
licenses:
|
171
131
|
- MIT
|
@@ -185,8 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
145
|
- !ruby/object:Gem::Version
|
186
146
|
version: '0'
|
187
147
|
requirements: []
|
188
|
-
|
189
|
-
rubygems_version: 2.4.8
|
148
|
+
rubygems_version: 3.2.3
|
190
149
|
signing_key:
|
191
150
|
specification_version: 4
|
192
151
|
summary: ORM and Query DSL for ClickHouse
|