gilbertosj
I currently have an index on the controller, as follows
def index(conn, params) do
cdr = Structure.list_cdr()
page = Structure.list_cdr
|> order_by([c], desc: c.calldate)
|> Repo.paginate(params)
filter = Structure.list_cdr()
|> where([c], fragment("? BETWEEN ? AND ?", c.calldate, ^date_start, ^date_end))
|> order_by([c], desc: c.calldate)
|> Repo.paginate(params)
render(conn, "index.html", cdr: page.entries, page: page, filter: page)
end
Notice that I added ^ date_start is ^ date_end
I want to create a
defp date_start do
end
defp date_end do
end
In the same controller.
Can someone help me with this?
This date_start is date_end would be to pick up from
“Template”
<%= form_for @conn, Routes.ecdr_path(@conn, :index), [method: :get], fn f -> %>
<%= date_input(:calldate, :date_start, class: "form-control", id: "inlineFormInputGroupDatestart", placeholder: "Data") %>
<%= date_input(:calldate, :date_end, class: "form-control", id: "inlineFormInputGroupDateend", placeholder: "Data") %>
<% end %>
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Anyone here using Honeybadger?
My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of
Bandit.HTTPError...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #elixirconf-us
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
benwilson512
Those will come in from the params, you need to grab those values out of the params and parse them into date times. Try doing
IO.inspect(params)to see what it is.NobbZ
Please keep this discussion in Recognize new params in the template, it seems to be the same problem you have there but phrased differently.
gilbertosj
For the sake of simplicity, the question has been rephrased.
If anyone can help me, I’ll be grateful.
gilbertosj
I made the following modification to accept the parameters …
When I pass no value, it returns me the following error
controller:
nil ↩︎
nil ↩︎
NobbZ
The error suggest that you never query the database, but instead try to iterate over the query, probably in the template you want to render.
gilbertosj
I managed to do, to query database perfectly.
More when I execute “submit the template”, it does not load my filtered information.
I see that it is a small detail that I am letting go …
can you help me?
Controller:
Template
index.html
<%= render "filter.html", Map.put(assigns, :action, Routes.ecdr_path(@conn, :index)) %>Template
filter.html
Debug:
[info] GET /relatorios
[debug] Processing with GcallWeb.EcdrController.index/2
Parameters: %{“_utf8” => “✓”, “date_end” => “2019-06-08”, “date_start” => “2019-06-01”, “dcontext” => %{“contexto” => “”}, “disposition” => %{“status” => “Todas”}, “dst” => %{“destino” => “”}, “src” => %{“origem” => “”}}
Pipelines: [:browser]
[debug] QUERY OK source=“cdr” db=12.1ms
SELECT count(‘‘) FROM
cdrAS c0 [][debug] QUERY OK source=“cdr” db=0.3ms
SELECT c0.
calldate, c0.accountcode, c0.amaflags, c0.billsec, c0.channel, c0.clid, c0.dcontext, c0.disposition, c0.dst, c0.dstchannel, c0.duration, c0.lastapp, c0.lastdata, c0.src, c0.uniqueid, c0.userfieldFROMcdrAS c0 ORDER BY c0.calldateDESC LIMIT ? OFFSET ? [10, 0][debug] QUERY OK source=“cdr” db=0.5ms
SELECT count(’’) FROM
cdrAS c0 WHERE (c0.calldateBETWEEN ? AND ?) [“2019-06-01”, “2019-06-08”][debug] QUERY OK source=“cdr” db=0.5ms
SELECT c0.
calldate, c0.accountcode, c0.amaflags, c0.billsec, c0.channel, c0.clid, c0.dcontext, c0.disposition, c0.dst, c0.dstchannel, c0.duration, c0.lastapp, c0.lastdata, c0.src, c0.uniqueid, c0.userfieldFROMcdrAS c0 WHERE (c0.calldateBETWEEN ? AND ?) ORDER BY c0.calldateDESC LIMIT ? OFFSET ? [“2019-06-01”, “2019-06-08”, 10, 0][info] Sent 200 in 15ms
[info] Replied phoenix:live_reload :ok