Manages a user request.
Summary
Functions
This function is called on a /extent request.
It will fetch all the contents corresponding to the filters that were set up by
AvyWeb.Plugs.Filters, in the assigns of the connection plug (conn.assigns.filters).
For each filter, the database request is done asynchronously in parallel.
Desactivate the timeout, as the DB pool has it's own already, and some requests can get quite long.
This controller exists to reformat the output suitable for a grafana state timeline
This function will convert a list of ordered datasources to
show gaps.
Functions
@spec manage_request(Plug.Conn.t(), atom()) :: {:ok, list()} | {:too_much_data, String.t()}
This function is called on a /extent request.
It will fetch all the contents corresponding to the filters that were set up by
AvyWeb.Plugs.Filters, in the assigns of the connection plug (conn.assigns.filters).
For each filter, the database request is done asynchronously in parallel.
Desactivate the timeout, as the DB pool has it's own already, and some requests can get quite long.
For each entry, we call the post_process function in order to build a list of datasources and merge the contents of the same properties.
Finally, the datasources are put in the conn.assigns in order for ther renderer to access them in the :availabilities keyword.
@spec open_api_operation(atom()) :: OpenApiSpex.Operation.t()
This controller exists to reformat the output suitable for a grafana state timeline
All the formatting logic takes place in the render function AvyJson.statetimeline/1
This function will convert a list of ordered datasources to
show gaps.
First, group all datasources by the full keys. Then for each list:
- keep the previous end date. (Start first iteration at second element)
- on the current element:
- set the start time at previous end date
- set then end time at current start.
- put the result at the head of the list we are building
- we obtain a reversed list, so at the end we need to reverse it.