Skip to content

Commit

Permalink
request with synchronize, update testing workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
PNixx committed Jan 24, 2025
1 parent 545c1ac commit 5f2fbf4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ jobs:
rails: 7.2.1
- ruby: 3.2
rails: 8.0.1
clickhouse: [ '22.1', '24.6' ]
clickhouse: [ '22.1', '24.9' ]

steps:
- uses: actions/checkout@v4

- name: Start ClickHouse ${{ matrix.clickhouse }}
uses: isbang/compose-action@v1.5.1
uses: hoverkraft-tech/compose-action@v2.1.0
env:
CLICKHOUSE_VERSION: ${{ matrix.clickhouse }}
with:
Expand Down Expand Up @@ -74,14 +74,16 @@ jobs:
- ruby: 3.2
rails: 7.1.3
- ruby: 3.2
rails: 7.2.0
clickhouse: [ '22.1', '24.6' ]
rails: 7.2.1
- ruby: 3.2
rails: 8.0.1
clickhouse: [ '22.1', '24.9' ]

steps:
- uses: actions/checkout@v4

- name: Start ClickHouse Cluster ${{ matrix.clickhouse }}
uses: isbang/compose-action@v1.5.1
uses: hoverkraft-tech/compose-action@v2.1.0
env:
CLICKHOUSE_VERSION: ${{ matrix.clickhouse }}
with:
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,11 @@ Action.settings(optimize_read_in_order: 1).where(date: Date.current).limit(10)

User.joins(:actions).using(:group_id)
# Clickhouse User Load (10.3ms) SELECT users.* FROM users INNER JOIN actions USING group_id
#=> #<ActiveRecord::Relation [#<Action *** >]>
#=> #<ActiveRecord::Relation [#<User *** >]>

User.window('x', order: 'date', partition: 'name', rows: 'UNBOUNDED PRECEDING').select('sum(value) OVER x')
# SELECT sum(value) OVER x FROM users WINDOW x AS (PARTITION BY name ORDER BY date ROWS UNBOUNDED PRECEDING)
#=> #<ActiveRecord::Relation [#<User *** >]>
```


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,12 @@ def with_yaml_fallback(value) # :nodoc:
def request(sql, format = nil, settings = {})
formatted_sql = apply_format(sql, format)
request_params = @connection_config || {}
@connection.post("/?#{request_params.merge(settings).to_param}", formatted_sql, {
'User-Agent' => "Clickhouse ActiveRecord #{ClickhouseActiverecord::VERSION}",
'Content-Type' => 'application/x-www-form-urlencoded',
})
@lock.synchronize do
@connection.post("/?#{request_params.merge(settings).to_param}", formatted_sql, {
'User-Agent' => "Clickhouse ActiveRecord #{ClickhouseActiverecord::VERSION}",
'Content-Type' => 'application/x-www-form-urlencoded',
})
end
end

def apply_format(sql, format)
Expand Down
2 changes: 1 addition & 1 deletion lib/clickhouse-activerecord/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ClickhouseActiverecord
VERSION = '1.2.1'
VERSION = '1.3.0'
end

0 comments on commit 5f2fbf4

Please sign in to comment.