AdrianFerJ / v2go-api

V2go web app's repo contains client and server apps (django and angular), and infastructure setup for both apps, postgres, redis, and nginx using docker
0 stars 0 forks source link

Issues retriving CS from reservation volt_reservation/services.py #35

Closed AdrianFerJ closed 5 years ago

AdrianFerJ commented 5 years ago

The ReservationService.get_available_cs_event() method returns a django.db.models.fields.related object, not a CS event instance, neither a CS instance (as the previous method name suggested, get_available_charging_station() ).

This is not necessarily a bug, but I couldn't figure how to retrieve the related CS from this output. So I moved the query inside the service method, onto the view ChargingStationTopNearListView.get_top_cs_near_poi_available_date() and it did work.

@niroigen , if you know how to retrieve the CS related to the CSEvents, then let's replace this query with a call to the service (I agree it's better practice to have the view and the first query decoupled).

niroigen commented 5 years ago

Hmm this seems like an interesting find! So just to be clear it seems to be the case that when you try to call get_available_cs_event it would return a django.db.models.fields.related object? So it seems to be the case that it has something to do with the CSEvent.objects.filter. An interesting find!

AdrianFerJ commented 5 years ago

Yes, it could be. An easy way to test that would be to replace the query, inside the service itself, with a more generic query that doesn't use filter, the objects.all() kind of query.