<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="284857" data-post-id="284857">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="gregvaughn" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/gregvaughn/120/954_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  gregvaughn
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’m joining this thread late and to be honest, have not read all the correction details. I offer another approach with <code>get_in</code> that may or may not be of interest. I like these sorts of data manipulation puzzles though <img src="https://forum.elixirforum.com/images/emoji/apple/grin.png?v=15" title=":grin:" class="emoji" alt=":grin:" loading="lazy" width="20" height="20"></p>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex(11)&gt; data1
[
  %{id: "111", name: "name1"},
  %{id: "222", name: "name2"},
  %{id: "333", name: "name3"},
  %{id: "444", name: "name4"}
]
iex(12)&gt; data2
[
  %{mapData: %{"111": "data1", "222": "data2_test", "333": "data3_test"}},
  %{mapData: %{"111": "data11_test", "222": "data22_test"}},
  %{mapData: %{"111": "data111_test"}}
]
iex(13)&gt; Enum.flat_map(data1, fn %{id: id} = d1 -&gt;
...(13)&gt;   id2 = String.to_atom(id)
...(13)&gt;   addrs = data2 |&gt; get_in([Access.all(), :mapData, id2]) |&gt; Enum.reject(&amp;is_nil/1)
...(13)&gt;   addrs = if addrs == [], do: [""], else: addrs
...(13)&gt;  Enum.map(addrs, &amp;Map.put(d1, :address, &amp;1))
...(13)&gt; end)
[
  %{address: "data1", id: "111", name: "name1"},
  %{address: "data11_test", id: "111", name: "name1"},
  %{address: "data111_test", id: "111", name: "name1"},
  %{address: "data2_test", id: "222", name: "name2"},
  %{address: "data22_test", id: "222", name: "name2"},
  %{address: "data3_test", id: "333", name: "name3"},
  %{address: "", id: "444", name: "name4"}
]
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="284857" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/merging-two-lists-of-maps/55167/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-284857" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="284857"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-most-liked cat-most-liked" title="One of the top 3 liked posts in this thread!"></div>
  </section>
</div>
    <div class="postbit" id="284903" data-post-id="284903">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="zhanjingbaobao" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  zhanjingbaobao
                      <span class="op-star" title="Thread Starter">
                        <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                      </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>sorry，this is the new data</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">data1 = [
      %{channelId: "1", describtion: "dev-test_001", tags: %{pipelineId: "1001", pipelineTemplate: "live-drm"}},
      %{channelId: "2", describtion: "dev-test_002", tags: %{pipelineId: "1002", pipelineTemplate: "live-drm"}},
      %{channelId: "3", describtion: "dev-test_003", tags: %{pipelineId: "1003", pipelineTemplate: "live-drm"}},
      %{channelId: "4", describtion: "dev-test_004", tags: %{pipelineId: "1004", pipelineTemplate: "live-drm"}}
    ]

    data2 = [
      %{mediaTailoId: %{"1": "channel1_data", "2": "channel2_dadta", "3": "channel3_dadta"}, mediaTailorRegion: "us-east-1", name: "testName1"},
      %{mediaTailoId: %{"1": "channel1_data", "2": "channel2_dadta"}, mediaTailorRegion: "us-east-2", name: "testName2"},
      %{mediaTailoId: %{"1": "channel1_data"}, mediaTailorRegion: "us-east-3", name: "testName3"}
    ]
</code></pre>
<p>On this basis I also want to get the name attribute in data2 as another attribute of data1. I tried without success. Do you have any good suggestions?<br>
my expect_data</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">expect_data = [
  %{
    channelId: "1",
    description: "dev-test_001",
    tags: %{pipelineId: "1001", pipelineTemplate: "live-drm"},
    name: "testName1"
  },
  %{
    channelId: "1",
    description: "dev-test_001",
    tags: %{pipelineId: "1001", pipelineTemplate: "live-drm"},
    name: "testName2"
  },
  %{
    channelId: "1",
    description: "dev-test_001",
    tags: %{pipelineId: "1001", pipelineTemplate: "live-drm"},
    name: "testName3"
  },
  %{
    channelId: "2",
    description: "dev-test_002",
    tags: %{pipelineId: "1002", pipelineTemplate: "live-drm"},
    name: "testName1"
  },
  %{
    channelId: "2",
    description: "dev-test_002",
    tags: %{pipelineId: "1002", pipelineTemplate: "live-drm"},
    name: "testName2"
  },
  %{
    channelId: "3",
    description: "dev-test_003",
    tags: %{pipelineId: "1003", pipelineTemplate: "live-drm"},
    # fix: "testName2" -&gt; "testName1" 
    name: "testName1"
  },
  %{
    channelId: "4",
    description: "dev-test_004",
    tags: %{pipelineId: "1004", pipelineTemplate: "live-drm"},
    name: ""
  }
]
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="284903" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/merging-two-lists-of-maps/55167/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-284903" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="284903"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>