Hello!
I am having trouble sorting and displaying data that I get from Repo.all query.
I am getting that kind on info from Repo.all query:
[
%Parking.Park.ParkingPlace{
__meta__: #Ecto.Schema.Metadata<:loaded, "parking_places">,
available_spots: 10,
id: 1,
inserted_at: ~N[2020-12-01 19:07:55],
lat: "xxx",
location: "zzz",
long: "yy",
price_zone: "A",
reservations: #Ecto.Association.NotLoaded<association :reservations is not loaded>,
total_spots: 200,
updated_at: ~N[2020-12-01 19:07:55]
},
%Parking.Park.ParkingPlace{
__meta__: #Ecto.Schema.Metadata<:loaded, "parking_places">,
available_spots: 50,
id: 2,
inserted_at: ~N[2020-12-01 19:07:55],
lat: "yyy",
location: "yyy",
long: "xxx",
price_zone: "B",
reservations: #Ecto.Association.NotLoaded<association :reservations is not loaded>,
total_spots: 50,
updated_at: ~N[2020-12-01 19:07:55]
},
%Parking.Park.ParkingPlace{
__meta__: #Ecto.Schema.Metadata<:loaded, "parking_places">,
available_spots: 100,
id: 3,
inserted_at: ~N[2020-12-01 19:07:55],
lat: "ttt",
location: "uuu",
long: "vvv",
price_zone: "A",
reservations: #Ecto.Association.NotLoaded<association :reservations is not loaded>,
total_spots: 300,
updated_at: ~N[2020-12-01 19:07:55]
},
]
I can get that data on phoenix page with no problem.
Now I would like to add to the query list items distance from my location.
I could add to list end some item with ++[].
Would I need to calculate distance and create in another list or can I add distance to that list item so I could get it in phoenix easily?