Hello, I am new to elixir and ecto and working with a pretty large database. I am trying to modify this function that queries the db:
def query_active_truck_load_counts do
from(
well in Well,
where: is_nil(well.deleted_at),
where: well.closed == false,
left_join: truck_load in TruckLoad,
on: well.id == truck_load.well_id,
left_join: fulfillment_authorization in assoc(truck_load, :fulfillment_authorization),
left_join: dispatch_event in TruckLoadEvent,
on:
truck_load.id == dispatch_event.truck_load_id and is_nil(dispatch_event.deleted_at) and
dispatch_event.status == ^TruckLoadEventStatuses.dispatch(),
left_join: unloaded_event in TruckLoadEvent,
on:
truck_load.id == unloaded_event.truck_load_id and is_nil(unloaded_event.deleted_at) and
unloaded_event.status == ^TruckLoadEventStatuses.unloaded(),
left_join: rerouted_event in TruckLoadEvent,
on:
truck_load.id == rerouted_event.truck_load_id and is_nil(rerouted_event.deleted_at) and
rerouted_event.status == ^TruckLoadEventStatuses.rerouted(),
where: not (is_nil(fulfillment_authorization.accepted_at) and is_nil(dispatch_event.id)),
where: is_nil(unloaded_event.id),
where: is_nil(rerouted_event.id),
where: is_nil(truck_load.deleted_at),
group_by: well.id,
select: %{well_id: well.id, active_truck_loads: count(truck_load.id)}
)
end
My question is, how can I test the function? It is being called by different components on the front end, so I can test it that way, but is there a way I can console log and see different parts of the function?
Thanks!! and sorry if this is a dumb question