@@ -12,6 +12,7 @@ def self.update_runtime(runtime)
1212 :namespace_project ,
1313 module_configurations : { module_configuration_definition : :runtime_module }
1414 )
15+ runtime_modules = runtime . runtime_modules . includes ( :module_configuration_definitions )
1516
1617 flows = [ ]
1718 assignments . each do |assignment |
@@ -29,7 +30,7 @@ def self.update_runtime(runtime)
2930 runtime . id
3031 )
3132
32- grouped_module_configurations ( assignments ) . each do |module_configuration |
33+ grouped_module_configurations ( assignments , runtime_modules ) . each do |module_configuration |
3334 send_update (
3435 Tucana ::Sagittarius ::FlowResponse . new (
3536 module_configurations : module_configuration
@@ -48,14 +49,18 @@ def self.update_started(runtime_id)
4849 update_runtime ( runtime )
4950 end
5051
51- def self . grouped_module_configurations ( assignments )
52+ def self . grouped_module_configurations ( assignments , runtime_modules )
5253 grouped_entries = assignments . flat_map do |assignment |
53- assignment . module_configurations . map do |configuration |
54- [
55- configuration . module_configuration_definition . runtime_module . identifier ,
56- assignment ,
57- configuration
58- ]
54+ saved_configurations = assignment . module_configurations . index_by ( &:module_configuration_definition_id )
55+
56+ runtime_modules . flat_map do |runtime_module |
57+ runtime_module . module_configuration_definitions . map do |definition |
58+ [
59+ runtime_module . identifier ,
60+ assignment ,
61+ saved_configurations [ definition . id ] || definition
62+ ]
63+ end
5964 end
6065 end . group_by ( &:first )
6166
@@ -81,8 +86,20 @@ def self.grouped_project_configurations(entries)
8186
8287 def self . grpc_module_configurations ( entries )
8388 entries . map ( &:last )
84- . sort_by { |configuration | configuration . module_configuration_definition . identifier }
85- . map ( &:to_grpc )
89+ . sort_by { |configuration | module_configuration_identifier ( configuration ) }
90+ . map { |configuration | module_configuration_to_grpc ( configuration ) }
91+ end
92+
93+ def self . module_configuration_identifier ( configuration )
94+ return configuration . identifier if configuration . is_a? ( ModuleConfigurationDefinition )
95+
96+ configuration . module_configuration_definition . identifier
97+ end
98+
99+ def self . module_configuration_to_grpc ( configuration )
100+ return configuration . to_default_grpc if configuration . is_a? ( ModuleConfigurationDefinition )
101+
102+ configuration . to_grpc
86103 end
87104
88105 def self . encoders = { update : -> ( grpc_object ) { Tucana ::Sagittarius ::FlowResponse . encode ( grpc_object ) } }
0 commit comments