learning123

learning123

"(FunctionClauseError) no function clause matching" error

Hey all, I’m new to elixir and getting the following error:

** (FunctionClauseError) no function clause matching in TSS.DriverStatuses.list_assignable_drivers_by_truck_load/1

So in my module, I define a get_remaining_time function that takes a truck_load:

  defp get_remaining_time(truck_load) do
    time_since_available = DriverStatuses.list_assignable_drivers_by_truck_load(truck_load)
    Formatters.decorate_time_since_available(time_since_available)
  end

This function uses the list_assignable_drivers_by_truck_load in the DriverStatuses module, which looks like this:

  def list_assignable_drivers_by_truck_load(%TruckLoad{
        well: %{id: well_id},
        pull_point: pull_point
      }) do
    base_assignable_drivers_query()
    |> apply_default_select(pull_point.point)
    |> filter({:well_id, well_id})
    |> sort({:distance_in_meters, :asc}, %{"pull_point_id" => pull_point.id})
    |> preload(driver: [:trailer_type, driver_contract: [:carrier]])
    |> Repo.all()
  end

and then formats it using the decorate_time_since_available function in the Formatters module, which looks like this:

  def decorate_time_since_available(%{driver_status: %{last_available_at: last_available_at}})
      when not is_nil(last_available_at),
      do:
        humanize_time(DateTime.diff(DateTime.utc_now(), last_available_at), :seconds, :minutes) <>
          " (hh:mm)"

  def decorate_time_since_available(_), do: "N/A"

Finally, I am calling the function like so:

<CardInfo label="Time Since Available" title={{ get_remaining_time(@truck_load) }} small />

I think I’m not pattern matching correctly, but nothing I’ve tried is working. How can I fix this?
Thanks so much!!

Most Liked Responses

derek-zhou

derek-zhou

So your @truck_load is not a %TruckLoad(...} then. the error message after the ** (FunctionClausError)... line should give you more clue

Where Next?

Popular in Questions Top

chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: The documentation above suggests that while ...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

Other popular topics Top

Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52341 488
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New

We're in Beta

About us Mission Statement