graphql-groups 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c30a036d32f2580c7dbbbd4ee10d8cc364e8dc4af0e92fc5d0ab1d3c8378f55e
4
- data.tar.gz: fcd1bb1beeaed5247eba94cb72ac3418d3f29ca19a839ff78ed83e1b86aa602b
3
+ metadata.gz: bc6f31b4fca864cefe1967ddd17af2a65a782f53378f6b4c3bc5d7fb76a7819a
4
+ data.tar.gz: e64200c1a65480d32cdfb2826615e3ce8d26ae6fa61677e17a95a187c1b2063c
5
5
  SHA512:
6
- metadata.gz: 8bbde25d65f689d6b2127761e1b535d1d1946bdedd569707498e4516d33d69da76b7efc9d34bb9bd41212b6822f195188c39556a88ad0d85a75e6eb34fbce93c
7
- data.tar.gz: 43acc2931f89122b3e23f20e181cb8ab9e02d979bfd9153554d1f72b4a27a81a9ae722b975342e9ab37e5a930b2a2b777af97af8249ad74bfad293c93efbbf62
6
+ metadata.gz: 697fab7612389337ab019a3820cffbf91546ac5ddf026903448b6f5eb6815f0c468225aebe10d3febcee88dcfd174903fa487ae6f83361ed91ec605c43b0e94a
7
+ data.tar.gz: 4c99e4cbe13c9fa4e80a7a8c7b0958c2127675ba1e94f501b280160f8b231eda19f1ffaf9dcdfbcb0304d3721d66d416833696c8cf2074cf1092b15010766867
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- graphql-groups (0.1.3)
4
+ graphql-groups (0.1.4)
5
5
  graphql (~> 1, > 1.9)
6
6
 
7
7
  GEM
@@ -36,8 +36,6 @@ GEM
36
36
  http (> 0.8, < 3.0)
37
37
  multi_json (~> 1)
38
38
  graphql (1.11.1)
39
- groupdate (5.1.0)
40
- activesupport (>= 5)
41
39
  gruff (0.10.0)
42
40
  histogram
43
41
  rmagick
@@ -91,15 +89,12 @@ GEM
91
89
  parser (>= 2.7.0.1)
92
90
  rubocop-rspec (1.42.0)
93
91
  rubocop (>= 0.87.0)
94
- ruby-prof (1.4.1)
95
92
  ruby-progressbar (1.10.1)
96
93
  simplecov (0.18.5)
97
94
  docile (~> 1.1)
98
95
  simplecov-html (~> 0.11)
99
96
  simplecov-html (0.12.2)
100
97
  sqlite3 (1.4.2)
101
- stackprof (0.2.15)
102
- test-prof (0.12.0)
103
98
  thread_safe (0.3.6)
104
99
  tzinfo (1.2.7)
105
100
  thread_safe (~> 0.1)
@@ -119,17 +114,13 @@ DEPENDENCIES
119
114
  database_cleaner-active_record (~> 1.8)
120
115
  gqli (~> 1.0)
121
116
  graphql-groups!
122
- groupdate
123
117
  gruff (~> 0.10)
124
118
  rake (~> 13.0)
125
119
  rspec (~> 3.0)
126
120
  rubocop (~> 0.88)
127
121
  rubocop-rspec (~> 1.42)
128
- ruby-prof
129
122
  simplecov (~> 0.18.5)
130
123
  sqlite3 (~> 1.4.2)
131
- stackprof
132
- test-prof
133
124
 
134
125
  BUNDLED WITH
135
126
  2.1.4
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  lib = File.expand_path('lib', __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
  require 'graphql/groups/version'
@@ -11,7 +13,7 @@ Gem::Specification.new do |spec|
11
13
  spec.summary = 'Create flexible and fast aggregation queries with graphql-ruby'
12
14
  spec.description = <<~HEREDOC
13
15
  GraphQL Groups makes it easy to add aggregation queries to your GraphQL schema. It combines a simple, flexible
14
- schema definition with high performance'
16
+ schema definition with high performance
15
17
  HEREDOC
16
18
  spec.homepage = 'https://github.com/hschne/graphql-groups'
17
19
  spec.license = 'MIT'
@@ -22,8 +24,8 @@ Gem::Specification.new do |spec|
22
24
 
23
25
  # Specify which files should be added to the gem when it is released.
24
26
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
26
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
28
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|benchmark|.github)/}) }
27
29
  end
28
30
  spec.bindir = 'exe'
29
31
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
@@ -68,13 +68,9 @@ module GraphQL
68
68
  end
69
69
 
70
70
  def merge(hashes)
71
- root_key = hashes.first.keys.first
72
- result = hashes.each_with_object({}) do |hash, object|
73
- inner = hash[root_key]
74
- inner_key = inner.keys.first
75
- object[inner_key] = inner.values.first
71
+ hashes.each_with_object({}) do |hash, object|
72
+ object.deep_merge!(hash)
76
73
  end
77
- { root_key => result }
78
74
  end
79
75
 
80
76
  def build_keys(key, keys)
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Graphql
2
4
  module Groups
3
- VERSION = '0.1.3'.freeze
5
+ VERSION = '0.1.4'
4
6
  end
5
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-groups
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hans-Jörg Schnedlitz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-18 00:00:00.000000000 Z
11
+ date: 2020-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -199,14 +199,13 @@ dependencies:
199
199
  - !ruby/object:Gem::Version
200
200
  version: '1.9'
201
201
  description: "GraphQL Groups makes it easy to add aggregation queries to your GraphQL
202
- schema. It combines a simple, flexible \nschema definition with high performance'\n"
202
+ schema. It combines a simple, flexible \nschema definition with high performance\n"
203
203
  email:
204
204
  - hans.schnedlitz@gmail.com
205
205
  executables: []
206
206
  extensions: []
207
207
  extra_rdoc_files: []
208
208
  files:
209
- - ".github/workflows/build.yml"
210
209
  - ".gitignore"
211
210
  - ".rspec"
212
211
  - ".rubocop.yml"
@@ -219,9 +218,6 @@ files:
219
218
  - Meister.png
220
219
  - README.md
221
220
  - Rakefile
222
- - benchmark/benchmark.jpg
223
- - benchmark/benchmark.rb
224
- - benchmark/benchmark_schema.rb
225
221
  - bin/console
226
222
  - bin/setup
227
223
  - graphql-groups.gemspec
@@ -1,28 +0,0 @@
1
- name: Build
2
-
3
- on:
4
- push:
5
- branches: [ master ]
6
- pull_request:
7
- branches: [ master ]
8
-
9
- jobs:
10
- test:
11
- runs-on: ubuntu-latest
12
- steps:
13
- - uses: actions/checkout@v2
14
- - name: Set up Ruby
15
- uses: ruby/setup-ruby@v1
16
- with:
17
- ruby-version: 2.6.5
18
- - name: Install dependencies
19
- run: bundle install
20
- - name: Run tests
21
- run: bundle exec rspec
22
- - name: Report coverage
23
- uses: paambaati/codeclimate-action@v2.6.0
24
- env:
25
- CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
26
- with:
27
- # Coverage is already generated in test step, need to run anything again
28
- coverageCommand: echo '' > /dev/null
Binary file
@@ -1,101 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'graphql/groups'
4
-
5
- require 'database_cleaner/active_record'
6
- require 'gqli/dsl'
7
- require 'benchmark/ips'
8
- require 'gruff'
9
-
10
- require_relative '../spec/graphql/support/test_schema/db'
11
- require_relative '../spec/graphql/support/test_schema/models'
12
- require_relative 'benchmark_schema'
13
-
14
- class Compare
15
- def run
16
- puts 'Generating reports...'
17
- datasets = perform_runs
18
- labels = { 0 => '10', 1 => '100', 2 => '1000', 3 => '10000' }
19
- puts 'Generating graph...'
20
- graph = graph(labels, datasets)
21
- graph.write('benchmark/benchmark.jpg')
22
- puts 'Done!'
23
- end
24
-
25
- private
26
-
27
- def perform_runs
28
- runs = [10, 100, 1000, 10_000]
29
- runs.map { |count| single_run(count) }
30
- .map(&:data)
31
- .map { |data| { groups: data.first[:ips], group_by: data.second[:ips] } }
32
- .each_with_object({ groups: [], group_by: [] }) do |item, object|
33
- object[:groups].push(item[:groups])
34
- object[:group_by].push(item[:group_by])
35
- end
36
- end
37
-
38
- def graph(labels, datasets)
39
- g = Gruff::Bar.new(800)
40
- g.title = 'graphql-groups vs group_by'
41
- g.theme = Gruff::Themes::THIRTYSEVEN_SIGNALS
42
- g.labels = labels
43
- g.x_axis_label = 'records'
44
- g.y_axis_label = 'iterations/second'
45
- datasets.each do |data|
46
- g.data(data[0], data[1])
47
- end
48
- g
49
- end
50
-
51
- def single_run(count)
52
- DatabaseCleaner.strategy = :transaction
53
- DatabaseCleaner.start
54
- seed(count)
55
- report = run_benchmark
56
- DatabaseCleaner.clean
57
- report
58
- end
59
-
60
- def seed(count)
61
- names = %w[Ada Alice Bob Bruce]
62
- count.times { Author.create(name: names.sample) }
63
- end
64
-
65
- def groups_query
66
- GQLi::DSL.query {
67
- fastGroups {
68
- name {
69
- key
70
- count
71
- }
72
- }
73
- }.to_gql
74
- end
75
-
76
- def naive_query
77
- GQLi::DSL.query {
78
- slowGroups {
79
- name {
80
- key
81
- count
82
- }
83
- }
84
- }.to_gql
85
- end
86
-
87
- def run_benchmark
88
- Benchmark.ips(quiet: true) do |x|
89
- # Configure the number of seconds used during
90
- # the warmup phase (default 2) and calculation phase (default 5)
91
- x.config(time: 2, warmup: 1)
92
-
93
- x.report('groups') { PerformanceSchema.execute(groups_query) }
94
-
95
- x.report('group-by') { PerformanceSchema.execute(naive_query) }
96
-
97
- # Compare the iterations per second of the various reports!
98
- x.compare!
99
- end
100
- end
101
- end
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'graphql'
4
- require 'graphql/groups'
5
-
6
- class BaseType < GraphQL::Schema::Object; end
7
-
8
- class AuthorGroupType < GraphQL::Groups::Schema::GroupType
9
- scope { Author.all }
10
-
11
- by :name
12
- end
13
-
14
- class SlowAuthorGroupResultType < GraphQL::Schema::Object
15
- field :key, String, null: false
16
- field :count, Integer, null: false
17
-
18
- def key
19
- object[0]
20
- end
21
-
22
- def count
23
- object[1].size
24
- end
25
- end
26
-
27
- class SlowAuthorGroupType < GraphQL::Schema::Object
28
- field :name, [SlowAuthorGroupResultType], null: false
29
-
30
- def name
31
- object.group_by(&:name)
32
- end
33
- end
34
-
35
- class QueryType < BaseType
36
- include GraphQL::Groups
37
-
38
- group :fast_groups, AuthorGroupType, camelize: true
39
-
40
- field :slow_groups, SlowAuthorGroupType, null: false, camelize: true
41
-
42
- def slow_groups
43
- Author.all
44
- end
45
- end
46
-
47
- class PerformanceSchema < GraphQL::Schema
48
- query QueryType
49
-
50
- def self.resolve_type(_type, obj, _ctx)
51
- "#{obj.class.name}Type"
52
- end
53
- end