Skip to content

Commit 52d0977

Browse files
authored
Merge pull request #874 from code0-tech/871-implement-data-type-changes-from-tucana
Implement data type changes from tucana
2 parents 66b634a + 02112a8 commit 52d0977

181 files changed

Lines changed: 1143 additions & 4036 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ gem 'good_job', '~> 4.0'
7979
gem 'rotp'
8080

8181
gem 'grpc', '~> 1.67'
82-
gem 'tucana', '0.0.53'
82+
gem 'tucana', '0.0.58'
8383

8484
gem 'code0-identities', '~> 0.0.3'
8585

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ GEM
377377
thor (1.4.0)
378378
timeout (0.6.0)
379379
tsort (0.2.0)
380-
tucana (0.0.53)
380+
tucana (0.0.58)
381381
grpc (~> 1.64)
382382
tzinfo (2.0.6)
383383
concurrent-ruby (~> 1.0)
@@ -431,7 +431,7 @@ DEPENDENCIES
431431
simplecov (~> 0.22.0)
432432
simplecov-cobertura (~> 3.0)
433433
test-prof (~> 1.0)
434-
tucana (= 0.0.53)
434+
tucana (= 0.0.58)
435435
tzinfo-data
436436

437437
RUBY VERSION

app/finders/data_type_identifiers_finder.rb

Lines changed: 0 additions & 152 deletions
This file was deleted.

app/finders/data_types_finder.rb

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# frozen_string_literal: true
2+
3+
class DataTypesFinder < ApplicationFinder
4+
def execute
5+
data_types = base_scope
6+
data_types = by_data_type(data_types)
7+
data_types = by_runtime_function_definition(data_types)
8+
data_types = by_flow_type_setting(data_types)
9+
data_types = by_flow_type(data_types)
10+
data_types = by_flow(data_types)
11+
12+
data_types = add_related_data_types(data_types)
13+
14+
super(data_types)
15+
end
16+
17+
private
18+
19+
def base_scope
20+
DataType.all
21+
end
22+
23+
def by_data_type(data_types)
24+
return data_types unless params[:data_type]
25+
26+
data_types.where(id: params[:data_type].referenced_data_types.pluck(:id))
27+
end
28+
29+
def by_runtime_function_definition(data_types)
30+
return data_types unless params[:runtime_function_definition]
31+
32+
data_types.where(id: params[:runtime_function_definition].referenced_data_types.pluck(:id))
33+
end
34+
35+
def by_flow_type_setting(data_types)
36+
return data_types unless params[:flow_type_setting]
37+
38+
data_types.where(id: params[:flow_type_setting].referenced_data_types.pluck(:id))
39+
end
40+
41+
def by_flow_type(data_types)
42+
return data_types unless params[:flow_type]
43+
44+
data_types.where(id: params[:flow_type].referenced_data_types.pluck(:id))
45+
end
46+
47+
def by_flow(data_types)
48+
return data_types unless params[:flow]
49+
50+
data_types.where(id: params[:flow].referenced_data_types.pluck(:id))
51+
end
52+
53+
def add_related_data_types(data_types)
54+
return data_types unless params[:expand_recursively]
55+
56+
tree = Arel::Table.new(:data_type_tree)
57+
58+
DataType
59+
.with_recursive(data_type_tree: [
60+
data_types,
61+
add_related_data_types_recursive_case
62+
])
63+
.from(tree)
64+
.select(tree[Arel.star])
65+
.distinct
66+
.order(:id)
67+
end
68+
69+
def add_related_data_types_recursive_case
70+
tree = Arel::Table.new(:data_type_tree)
71+
dt = DataType.arel_table
72+
link = DataTypeDataTypeLink.arel_table
73+
74+
DataType
75+
.from(tree)
76+
.joins(
77+
tree.join(link, Arel::Nodes::InnerJoin)
78+
.on(tree[:id].eq(link[:data_type_id]))
79+
.join(dt, Arel::Nodes::InnerJoin)
80+
.on(link[:referenced_data_type_id].eq(dt[:id]))
81+
.join_sources
82+
)
83+
.select(dt[Arel.star])
84+
end
85+
end

app/graphql/types/data_type_identifier_type.rb

Lines changed: 0 additions & 18 deletions
This file was deleted.

app/graphql/types/data_type_rule_type.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ def variant
1919
end
2020

2121
def config
22-
if object.variant_parent_type?
23-
object
24-
else
25-
object.config.merge(variant: object.variant)
26-
end
22+
object.config.merge(variant: object.variant)
2723
end
2824
end
2925
end

app/graphql/types/data_type_rules/config_type.rb

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,14 @@ module DataTypeRules
55
class ConfigType < Types::BaseUnion
66
description 'Represents a rule that can be applied to a data type.'
77

8-
possible_types ContainsKeyConfigType, ContainsTypeConfigType, NumberRangeConfigType, ItemOfCollectionConfigType,
9-
RegexConfigType, InputTypesConfigType, ReturnTypeConfigType, ParentTypeConfigType
8+
possible_types NumberRangeConfigType, RegexConfigType
109

1110
def self.resolve_type(object, _context)
1211
case object[:variant].to_sym
13-
when :contains_key
14-
Types::DataTypeRules::ContainsKeyConfigType
15-
when :contains_type
16-
Types::DataTypeRules::ContainsTypeConfigType
1712
when :number_range
1813
Types::DataTypeRules::NumberRangeConfigType
19-
when :item_of_collection
20-
Types::DataTypeRules::ItemOfCollectionConfigType
2114
when :regex
2215
Types::DataTypeRules::RegexConfigType
23-
when :input_types
24-
Types::DataTypeRules::InputTypesConfigType
25-
when :return_type
26-
Types::DataTypeRules::ReturnTypeConfigType
27-
when :parent_type
28-
Types::DataTypeRules::ParentTypeConfigType
2916
else
3017
raise GraphQL::ExecutionError, "Unknown data type rule variant: #{object[:variant]}"
3118
end

app/graphql/types/data_type_rules/contains_key_config_type.rb

Lines changed: 0 additions & 25 deletions
This file was deleted.

app/graphql/types/data_type_rules/contains_type_config_type.rb

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)