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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="neuone" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  neuone
                    <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>I agree with this feedback.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="274042" 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/function-with-default-arguments-and-explicitly-declared-clauses/53020/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-274042" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="274042"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="274684" data-post-id="274684">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="neuone" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  neuone
                    <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">
								<h2><a name="p-274684-updated-solution-1" class="anchor" href="#p-274684-updated-solution-1" aria-label="Heading link" rel="nofollow"></a>Updated Solution</h2>
<p>I think I have a better understanding on how Keywords can be passed in as function arguments and the benefits. In my original post <strong>I was rigid in having my function arguments be in a specific order and named.</strong></p>
<p>But the new solution I think is more idiomatic. I am much happier and learned quite a lot in this thread.</p>
<h3><a name="p-274684-new-approach-2" class="anchor" href="#p-274684-new-approach-2" aria-label="Heading link" rel="nofollow"></a>New Approach</h3>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Example do

  @doc """
  Does a lookup

  ## Example

    iex&gt; Example.lookup("a")

    iex&gt; Example.lookup("a", date: "20230131")

    iex&gt; Example.lookup("a", date: "20230131", place_id: "b")

    iex&gt; Example.lookup("a", date: "20230131", place_id: "b", direction_id: :internal)

  """

  def lookup(id, opts \\ []) do
    defaults = [date: today_string()]
    opts = Keywords.merge(defaults, opts)

    results = QuerySomeDB.get(id, opts[:date]) # some querying would happen
    do_lookup(results, opts)
  end

  defp do_lookup(results, opts) do
    place_id   = opts[:place_id]
    company_id = opts[:company_id]

    results = if place_id, do: filter_by_place_id(results, place_id), else: results
    results = if company_id, do: filter_by_company_id(results, place_id), else: results

    results
end

 defp filter_by_place_id(results, place_id) do
    # ... do some filtering and return the new results
    results
 end

 defp filter_by_company_id(results, company_id) when company_id in [:internal, :external] do
    # ... do some filtering and return the new results
    results
  end

 defp today_string() do
    #... returns a date string
 end

end

</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="274684" 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/function-with-default-arguments-and-explicitly-declared-clauses/53020/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-274684" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="274684"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="274687" data-post-id="274687">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>In this new version, you query all your database, filtering only on dates. It can be fine, it can be a problem.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="274687" 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/function-with-default-arguments-and-explicitly-declared-clauses/53020/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-274687" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="274687"
                     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>