elasticgraph 0.19.1.1 → 0.19.2.0

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: 4216f5fd015ccd7747fe31e176991c5e964f5d1e35a1a4cc1ff850255e199093
4
- data.tar.gz: 8c666e0b5472ded7333ff51b011a190d64b7907e6790b2232782daa35b895c4c
3
+ metadata.gz: 58ba3bb1a9f40188184fbc0643ce36b185899c313f7d20ee31cbaff2f7a7780e
4
+ data.tar.gz: 28b7ebeebf6e62758d96c71a7cb65cd6407faee2ffbc73bae7cfdac9c6e7d80b
5
5
  SHA512:
6
- metadata.gz: 60dd8cca595070065b5a98d883600b970e32126048f1c0c34c47d7b79085f1b8824a887d7ab307615130c0dafbf44ed8f11763c59c6c134d94c0573d9a88ae71
7
- data.tar.gz: b3e96d1d0df7464927feaea717ac4ab9afaaddbf6100521ad461bb24dedec7329defc83b71a4d98ed2e544cfa3a8f760bffbe540dca2a8b97cf44aa74343aec8
6
+ metadata.gz: 0d08e4fdb06b68f8d624e4c9f11287b50569de46ca8ff220bb899fd454600f131b6bd27b8482a6521d30c9a7beca02bbd6b820af4c4c3197ad45469a33b3e0a1
7
+ data.tar.gz: 6cc08418acf93e855bb3445869be51e0903c000fcb025a0d773f82d3fc3e6f72606a33bea333440c9211393fbebd30b3ac367ce5e71f501c2f70c0c1dc70e340
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2024 Block, Inc.
3
+ Copyright (c) 2024 - 2025 Block, Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Block, Inc.
1
+ # Copyright 2024 - 2025 Block, Inc.
2
2
  #
3
3
  # Use of this source code is governed by an MIT-style
4
4
  # license that can be found in the LICENSE file or at
@@ -28,7 +28,7 @@ module ElasticGraph
28
28
  option :datastore, desc: "elasticsearch or opensearch", type: :string, default: "opensearch"
29
29
  desc "new APP_NAME", "Generate a new ElasticGraph project in APP_NAME."
30
30
  def new(app_path)
31
- new_app_path = ::File.join(::Dir.pwd, app_path)
31
+ new_app_path = ::File.absolute_path?(app_path) ? app_path : ::File.join(::Dir.pwd, app_path)
32
32
  app_name = ::File.basename(new_app_path)
33
33
 
34
34
  unless app_name.match?(/\A[a-z][a-z0-9_]+\z/)
@@ -39,11 +39,25 @@ module ElasticGraph
39
39
  raise ::Thor::Error, "Invalid datastore option: #{options[:datastore]}. Must be #{VALID_DATASTORES.join(" or ")}."
40
40
  end
41
41
 
42
+ # This determines where the ElasticGraph gems are sourced from. By default, we source them from the
43
+ # released gems (using the current `VERSION`). However, we also need to be able to use the local
44
+ # unreleased gems in some specific situations:
45
+ #
46
+ # - From our cli acceptance spec -- we want to test against our local gems, not the released gems.
47
+ # - From our Dockerfile -- we want it to build the docker image from our local gems.
48
+ gemfile_elasticgraph_details_code_snippet = %(["#{VERSION}"])
49
+ if (eg_gems_path = ENV["ELASTICGRAPH_GEMS_PATH"])
50
+ gemfile_elasticgraph_details_code_snippet = %([path: "#{eg_gems_path}"])
51
+ # :nocov: -- our tests always override `gemfile_elasticgraph_details_code_snippet` using the ENV var.
52
+ else
53
+ # :nocov:
54
+ end
55
+
42
56
  setup_env = SetupEnv.new(
43
57
  app_name: app_name,
44
58
  app_module: app_name.split("_").map(&:capitalize).join,
45
59
  datastore: options.fetch(:datastore),
46
- gemfile_elasticgraph_details_code_snippet: %(["#{VERSION}"])
60
+ gemfile_elasticgraph_details_code_snippet: gemfile_elasticgraph_details_code_snippet
47
61
  )
48
62
 
49
63
  say "Creating a new #{setup_env.datastore_name} ElasticGraph project called '#{app_name}' at: #{new_app_path}", :green
@@ -61,10 +61,10 @@ bundle exec rake -T
61
61
  bundle exec rake boot_locally
62
62
 
63
63
  # The GraphiQL UI should open automatically
64
- open http://localhost:9393/
64
+ open http://localhost:9000/
65
65
 
66
66
  # You can also visit <%= ElasticGraph.setup_env.datastore_ui_name %> via:
67
- open http://localhost:19293/
67
+ open http://localhost:19200/
68
68
  ```
69
69
 
70
70
  ### Run Build Tasks
@@ -108,7 +108,7 @@ If you use a `:daemon` task, you can later use the corresponding `:halt` task to
108
108
  ### Using the GraphiQL interactive GraphQL query editor
109
109
 
110
110
  When running `bundle exec rake boot_locally` the GraphiQL editor should open automatically
111
- (`open http://localhost:9393/`). Using it you can query your ElasticGraph cluster using GraphQL.
111
+ (`open http://localhost:9000/`). Using it you can query your ElasticGraph cluster using GraphQL.
112
112
 
113
113
  ### Seeding Fake Data
114
114
 
@@ -119,7 +119,7 @@ You can pass an arg (note quotes) to seed more batches of data:
119
119
  ### Using <%= ElasticGraph.setup_env.datastore_ui_name %>
120
120
 
121
121
  After running `bundle exec rake boot_locally` and opening <%= ElasticGraph.setup_env.datastore_ui_name %>
122
- `open http://localhost:19293/` click "Dev Tools" to open the <%= ElasticGraph.setup_env.datastore_name %> console.
122
+ `open http://localhost:19200/` click "Dev Tools" to open the <%= ElasticGraph.setup_env.datastore_name %> console.
123
123
 
124
124
  Here are some queries to get you started:
125
125
 
@@ -43,7 +43,7 @@ ElasticGraph::Local::RakeTasks.new(
43
43
 
44
44
  # TODO: replace this with a fake data generator for your own dataset.
45
45
  tasks.define_fake_data_batch_for :artists do
46
- <%= ElasticGraph.setup_env.app_module %>::FakeDataBatchGenerator.generate(artists: 100, venues: 10)
46
+ <%= ElasticGraph.setup_env.app_module %>::FakeDataBatchGenerator.generate(venues: 100)
47
47
  end
48
48
  end
49
49
 
@@ -62,3 +62,6 @@ task build: ["schema_artifacts:dump", *standard_checks]
62
62
 
63
63
  desc "Check everything. Intended to be run on CI to check your project."
64
64
  task check: ["schema_artifacts:check", *standard_checks]
65
+
66
+ # Make `rake` run `rake build` for convenience.
67
+ task default: :build
@@ -1,10 +1,32 @@
1
1
  # TODO: replace this file with one that defines the schema for your own dataset.
2
2
  ElasticGraph.define_schema do |schema|
3
+ schema.enum_type "MusicGenre" do |t|
4
+ t.value "ALTERNATIVE"
5
+ t.value "BLUES"
6
+ t.value "BLUEGRASS"
7
+ t.value "CLASSICAL"
8
+ t.value "COUNTRY"
9
+ t.value "ELECTRONIC"
10
+ t.value "FOLK"
11
+ t.value "HIP_HOP"
12
+ t.value "INDIE"
13
+ t.value "JAZZ"
14
+ t.value "METAL"
15
+ t.value "POP"
16
+ t.value "PUNK"
17
+ t.value "REGGAE"
18
+ t.value "RNB"
19
+ t.value "ROCK"
20
+ t.value "SKA"
21
+ t.value "SOUL"
22
+ end
23
+
3
24
  schema.object_type "Artist" do |t|
4
25
  t.field "id", "ID"
5
26
  t.field "name", "String"
6
27
  t.field "lifetimeSales", "JsonSafeLong"
7
28
  t.field "bio", "ArtistBio"
29
+ t.field "genres", "[MusicGenre!]!"
8
30
 
9
31
  t.field "albums", "[Album!]!" do |f|
10
32
  f.mapping type: "nested"
@@ -5,7 +5,7 @@ datastore:
5
5
  clusters:
6
6
  main:
7
7
  backend: <%= ElasticGraph.setup_env.datastore %>
8
- url: http://localhost:9293
8
+ url: http://localhost:9200
9
9
  settings: {}
10
10
  index_definitions:
11
11
  # TODO: replace the `artists:` and `venues:` keys with the indices from your dataset
@@ -1,3 +1,4 @@
1
+ require "digest/md5"
1
2
  require "factory_bot"
2
3
  require "faker"
3
4
  require_relative "shared_factories"
@@ -6,20 +7,37 @@ require_relative "shared_factories"
6
7
  FactoryBot.define do
7
8
  factory :artist, parent: :indexed_type_base do
8
9
  __typename { "Artist" }
10
+ # Prevent multiple artists with the same name by hashing the name to produce the id.
11
+ id { Digest::MD5.hexdigest(name) }
12
+
9
13
  name { Faker::Music.band }
10
14
 
11
15
  lifetimeSales do
12
16
  albums.map { |a| a.fetch(:soldUnits) }.sum
13
17
  end
14
18
 
15
- bio { build(:artist_bio) }
19
+ bio { build(:artist_bio, artistName: name) }
20
+
21
+ genres do
22
+ # Available genres from the MusicGenre enum
23
+ all_genres = %w[
24
+ ALTERNATIVE BLUES BLUEGRASS CLASSICAL COUNTRY ELECTRONIC FOLK HIP_HOP
25
+ INDIE JAZZ METAL POP PUNK REGGAE RNB ROCK SKA SOUL
26
+ ]
27
+
28
+ # Pick 1-3 random genres
29
+ Faker::Base.sample(all_genres, Faker::Number.between(from: 1, to: 3)).uniq
30
+ end
16
31
 
17
32
  albums do
18
- Faker::Number.between(from: 1, to: 10).times.map { build(:album) }
33
+ Faker::Number.between(from: 1, to: 6).times.map { build(:album) }
19
34
  end
20
35
 
21
36
  tours do
22
- Faker::Number.between(from: 0, to: 8).times.map { build(:tour, venueIds: venueIds) }
37
+ Faker::Number.between(from: 0, to: 4).times.map do
38
+ song = Faker::Base.sample(albums.flat_map { |a| a.fetch(:tracks).map { |t| t.fetch(:name) } })
39
+ build(:tour, venueIds: venueIds, name: "The #{song} Tour")
40
+ end
23
41
  end
24
42
 
25
43
  transient do
@@ -31,16 +49,76 @@ FactoryBot.define do
31
49
  __typename { "ArtistBio" }
32
50
  yearFormed { Faker::Number.between(from: 1900, to: 2025) }
33
51
  homeCountry { Faker::Address.country }
34
- description { Faker::Lorem.paragraphs(number: 3).join("\n\n") }
52
+ description do
53
+ # Generate a realistic artist bio by combining multiple sentences
54
+ year = yearFormed
55
+
56
+ # Common adjectives for music descriptions
57
+ adjectives = [
58
+ "innovative", "groundbreaking", "distinctive", "masterful", "energetic",
59
+ "soulful", "dynamic", "melodic", "haunting", "powerful", "ethereal",
60
+ "raw", "polished", "intricate", "atmospheric", "intense", "virtuosic"
61
+ ].shuffle
62
+
63
+ # Musical elements for variety
64
+ musical_elements = [
65
+ "harmonies", "compositions", "arrangements", "rhythms", "melodies",
66
+ "songwriting", "instrumentation", "productions", "performances", "vocals"
67
+ ].shuffle
68
+
69
+ genres = Faker::Base.sample(Faker::Base.translate("faker.music.genres"), 20)
70
+ instruments = Faker::Base.sample(Faker::Base.translate("faker.music.instruments"), 20).map(&:downcase)
71
+
72
+ # Origin story variants
73
+ origin = [
74
+ "#{artistName} was formed in #{year} in #{homeCountry}.",
75
+ "Emerging from #{homeCountry}'s #{genres.pop.downcase} scene in #{year}, #{artistName} began their musical journey.",
76
+ "Founded in #{homeCountry} in #{year}, #{artistName} started as a collective of #{genres.pop.downcase} musicians.",
77
+ "The story of #{artistName} began in #{year} when a group of musicians in #{homeCountry} came together."
78
+ ].sample
79
+
80
+ # Musical style variants
81
+ style = [
82
+ "Drawing inspiration from #{genres.pop} and #{genres.pop}, they developed a sound featuring #{instruments.pop}, #{instruments.pop}, #{instruments.pop}, and #{instruments.pop}.",
83
+ "Their #{adjectives.pop} style blends elements of #{genres.pop} with #{genres.pop}, creating a unique musical identity centered on their #{adjectives.pop} #{instruments.pop} and #{instruments.pop} counterpoint.",
84
+ "Known for their #{adjectives.pop} #{musical_elements.pop}, they combine #{instruments.pop} and #{instruments.pop} with #{adjectives.pop} #{instruments.pop} and #{adjectives.pop} #{instruments.pop} arrangements.",
85
+ "Their music explores the intersection of #{instruments.pop} #{genres.pop} and #{instruments.pop} #{genres.pop}, highlighted by #{adjectives.pop} #{musical_elements.pop}."
86
+ ].sample
87
+
88
+ # Career highlight variants
89
+ highlight_year = year + rand(2..5)
90
+ highlight = [
91
+ "Their breakthrough came with '#{Faker::Music.album}' in #{highlight_year}, which showcased their #{adjectives.pop} style.",
92
+ "The release of '#{Faker::Music.album}' in #{highlight_year} marked a turning point, earning critical acclaim for its #{adjectives.pop} #{musical_elements.pop}.",
93
+ "#{highlight_year} saw the release of their defining work '#{Faker::Music.album}', which demonstrated their #{adjectives.pop} approach to #{musical_elements.pop}.",
94
+ "With the #{adjectives.pop} '#{Faker::Music.album}' in #{highlight_year}, they established themselves as pioneers in #{genres.pop.downcase}."
95
+ ].sample
96
+
97
+ # Legacy/impact variants
98
+ legacy = [
99
+ "They continue to influence the music scene with their #{adjectives.pop} approach to #{musical_elements.pop}.",
100
+ "Their #{adjectives.pop} contributions to #{genres.pop.downcase} have left a lasting impact on the genre.",
101
+ "To this day, their #{adjectives.pop} #{musical_elements.pop} continue to inspire new generations of musicians.",
102
+ "They remain celebrated for their #{adjectives.pop} live performances and #{adjectives.pop} #{musical_elements.pop}.",
103
+ "Their influence on #{genres.pop.downcase} endures through their #{adjectives.pop} body of work.",
104
+ "Artists today still draw inspiration from their #{adjectives.pop} approach to #{musical_elements.pop}."
105
+ ].sample
106
+
107
+ [origin, style, highlight, legacy].join(" ")
108
+ end
109
+
110
+ transient do
111
+ artistName { raise "`artistName` must be provided." }
112
+ end
35
113
  end
36
114
 
37
115
  factory :album, parent: :hash_base do
38
116
  __typename { "Album" }
39
117
  name { Faker::Music.album }
40
- releasedOn { Faker::Date.between(from: "1900-01-01", to: "2025-12-31").iso8601 }
118
+ releasedOn { Faker::Date.between(from: "1950-01-01", to: "2025-12-31").iso8601 }
41
119
  soldUnits { Faker::Number.between(from: 10000, to: 100_000_000) }
42
120
  tracks do
43
- Faker::Number.between(from: 1, to: 20).times.map do |index|
121
+ Faker::Number.between(from: 1, to: 15).times.map do |index|
44
122
  build(:album_track, trackNumber: index + 1)
45
123
  end
46
124
  end
@@ -57,9 +135,9 @@ FactoryBot.define do
57
135
  __typename { "Tour" }
58
136
  name { "#{Faker::Music::RockBand.song} Tour" }
59
137
  shows do
60
- start_date = Faker::Date.between(from: "1900-01-01", to: "2025-12-31")
138
+ start_date = Faker::Date.between(from: "1950-01-01", to: "2025-12-31")
61
139
 
62
- Faker::Number.between(from: 3, to: 200).times.map do |index|
140
+ Faker::Number.between(from: 3, to: 30).times.map do |index|
63
141
  venue_id = Faker::Base.sample(venueIds)
64
142
  build(:show, date: start_date + index, venueId: venue_id)
65
143
  end
@@ -77,7 +155,7 @@ FactoryBot.define do
77
155
  venueId { nil }
78
156
 
79
157
  transient do
80
- date { Faker::Date.between(from: "1900-01-01", to: "2025-12-31") }
158
+ date { Faker::Date.between(from: "1950-01-01", to: "2025-12-31") }
81
159
  startTime { Faker::Base.sample(%w[19:00:00Z 19:30:00Z 20:00:00Z 20:30:00Z]) }
82
160
  end
83
161
  end
@@ -2,11 +2,15 @@ require_relative "factories"
2
2
 
3
3
  module <%= ElasticGraph.setup_env.app_module %>
4
4
  module FakeDataBatchGenerator
5
- def self.generate(artists:, venues:)
6
- venue_list = FactoryBot.build_list(:venue, venues)
5
+ def self.generate(venues:)
6
+ venue_list = FactoryBot.build_list(:venue, venues - 1) + [FactoryBot.build(:venue, name: nil)]
7
7
  venue_ids = venue_list.map { |v| v.fetch(:id) }
8
8
 
9
- artist_list = FactoryBot.build_list(:artist, artists, venueIds: venue_ids)
9
+ # Make one artist per unique name available via Faker.
10
+ artist_names = ::Faker::Base.translate("faker.music.bands") + ::Faker::Base.translate("faker.rock_band.name")
11
+ artist_list = artist_names.uniq.map do |name|
12
+ FactoryBot.build(:artist, name: name, venueIds: venue_ids)
13
+ end
10
14
 
11
15
  venue_list + artist_list
12
16
  end
@@ -1,6 +1,6 @@
1
- require "date"
2
1
  require "factory_bot"
3
2
  require "faker"
3
+ require "yaml"
4
4
 
5
5
  FactoryBot.define do
6
6
  factory :hash_base, class: Hash do
@@ -12,7 +12,8 @@ FactoryBot.define do
12
12
  end
13
13
 
14
14
  trait :versioned do
15
- __version { Faker::Number.between(from: 1, to: 10) }
15
+ # Use the current time as the version so that newly generated records always "win" over previously indexed records.
16
+ __version { Time.now.to_i }
16
17
  end
17
18
 
18
19
  current_json_schema_version = nil
@@ -13,7 +13,11 @@ RSpec.describe "ElasticGraph project" do
13
13
 
14
14
  # TODO: update this spec as needed to generate example fake data for your dataset.
15
15
  it "generates a batch of valid records from `FakeDataBatchGenerator`" do
16
- batch = <%= ElasticGraph.setup_env.app_module %>::FakeDataBatchGenerator.generate(artists: 20, venues: 5)
17
- expect(batch.size).to eq(25)
16
+ batch = <%= ElasticGraph.setup_env.app_module %>::FakeDataBatchGenerator.generate(venues: 5)
17
+
18
+ expect(batch.map { |r| r.fetch(:__typename) }.tally).to match({
19
+ "Artist" => a_value > 100,
20
+ "Venue" => 5
21
+ })
18
22
  end
19
23
  end
metadata CHANGED
@@ -1,16 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticgraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.1.1
4
+ version: 0.19.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Myron Marston
8
8
  - Ben VandenBos
9
9
  - Block Engineering
10
- autorequire:
11
10
  bindir: exe
12
11
  cert_chain: []
13
- date: 2025-02-07 00:00:00.000000000 Z
12
+ date: 2025-04-09 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: elasticgraph-support
@@ -18,14 +17,14 @@ dependencies:
18
17
  requirements:
19
18
  - - '='
20
19
  - !ruby/object:Gem::Version
21
- version: 0.19.1.1
20
+ version: 0.19.2.0
22
21
  type: :runtime
23
22
  prerelease: false
24
23
  version_requirements: !ruby/object:Gem::Requirement
25
24
  requirements:
26
25
  - - '='
27
26
  - !ruby/object:Gem::Version
28
- version: 0.19.1.1
27
+ version: 0.19.2.0
29
28
  - !ruby/object:Gem::Dependency
30
29
  name: thor
31
30
  requirement: !ruby/object:Gem::Requirement
@@ -33,6 +32,9 @@ dependencies:
33
32
  - - "~>"
34
33
  - !ruby/object:Gem::Version
35
34
  version: '1.3'
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: 1.3.2
36
38
  type: :runtime
37
39
  prerelease: false
38
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -40,7 +42,9 @@ dependencies:
40
42
  - - "~>"
41
43
  - !ruby/object:Gem::Version
42
44
  version: '1.3'
43
- description:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.3.2
44
48
  email:
45
49
  - myron@squareup.com
46
50
  executables:
@@ -71,12 +75,11 @@ licenses:
71
75
  - MIT
72
76
  metadata:
73
77
  bug_tracker_uri: https://github.com/block/elasticgraph/issues
74
- changelog_uri: https://github.com/block/elasticgraph/releases/tag/v0.19.1.1
75
- documentation_uri: https://block.github.io/elasticgraph/docs/main/
78
+ changelog_uri: https://github.com/block/elasticgraph/releases/tag/v0.19.2.0
79
+ documentation_uri: https://block.github.io/elasticgraph/api-docs/v0.19.2.0/
76
80
  homepage_uri: https://block.github.io/elasticgraph/
77
- source_code_uri: https://github.com/block/elasticgraph/tree/v0.19.1.1/elasticgraph
78
- gem_category: core
79
- post_install_message:
81
+ source_code_uri: https://github.com/block/elasticgraph/tree/v0.19.2.0/elasticgraph
82
+ gem_category: local
80
83
  rdoc_options: []
81
84
  require_paths:
82
85
  - lib
@@ -94,8 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
97
  - !ruby/object:Gem::Version
95
98
  version: '0'
96
99
  requirements: []
97
- rubygems_version: 3.5.22
98
- signing_key:
100
+ rubygems_version: 3.6.2
99
101
  specification_version: 4
100
102
  summary: Bootstraps ElasticGraph projects.
101
103
  test_files: []