noi-techpark / bdp-core

Open Data Hub / Timeseries Core
https://opendatahub.com
Other
9 stars 4 forks source link

As a suedtirolmobil developer I would like that certain issues with ODH Mobility are solved #207

Closed rcavaliere closed 2 years ago

rcavaliere commented 3 years ago

UPDATE 2021-09-29

The developers of the suedtirolmobil channels (Projektionisten) are developing for STA the integration with ODH Mobility in order to see real-time information about other mobility services on the map. During the implementation, following issues have been found:

Anfragen:
- ParkingStation: https://mobility.api.opendatahub.bz.it/v2/tree/ParkingStation/*/latest?limit=-1&distinct=true&where=and(savailable.eq.true,sactive.eq.true)
- EChargingPlug: https://mobility.api.opendatahub.bz.it/v2/flat/EChargingPlug/*/latest?limit=-1&distinct=true&where=and(savailable.eq.true,sactive.eq.true)&select=pcode,smetadata,mvalue
- EChargingStation: https://mobility.api.opendatahub.bz.it/v2/flat/EChargingStation/*/latest?limit=-1&distinct=true&where=and(savailable.eq.true,sactive.eq.true,smetadata.accessType.neq."PRIVATE")

**Problem 1: Fehlende Daten bei Ladestationen**
Beim Aktivieren des Schalters für Ladestationen führen wir zeitgleich die Anfrage für EChargingPlug und EChargingStation aus.
Ein ca. 1 von 4 Fällen sind die Daten unvollständig. In Screenshot Problem 1 - Missing Data sieht man das Problem deutlich: Wichtige Daten wie Geokoordinaten, Aktualisierungszeitstempel und ID (scode) fehlen. In dem Screenshot habe ich die Ergebnisse einer normalen Anfrage für EChargingStation mit denen einer fehlerhaften Anfrage gegenübergestellt.

**Problem 2: Private-Filter greift nicht**
Beim Aktivieren des Schalters für Ladestationen führen wir zeitgleich die Anfrage für EChargingPlug und EChargingStation aus.
Ein ca. 1 von 4 Fällen sind die Daten unvollständig (siehe Problem 1). Zusätzlich greift der Filter nicht, welcher alle privaten Ladestationen herausfiltern sollte (smetadata.accessType.neq.%22PRIVATE%22). In der Ergebnismenge sind weiterhin private Ladestationen zu finden.
Dieses Problem ist wahrscheinlich eng mit Problem 1 verknüpft, da beide Probleme zeitgleich auftreten.

**Problem 3: Datenbankfehler**
Bei der gleichzeitigen Ausführung der Anfragen für ParkingStation, EChargingPlug und EChargingStation wird die Anfrage nach Parkplätzen in seltenen Fällen mit einem Fehler 400 beantwortet (Message: ERROR: each UNION query must have the same number of columns\n Position: 2075).
Das Problem ist in Screenshot Problem 3 - Database Error zu sehen.

**Problem 4: Fehlende Daten bei Parkplätzen**
Bei der gleichzeitigen Ausführung der Anfragen für ParkingStation, EChargingPlug und EChargingStation fehlen manchmal die Parkplätze (Das Attribut data ist leer). Das Problem ist in Screenshot Problem 4 - Missing Data zu sehen.
Generell habe ich die Vermutung, dass schon zwei parallele Anfragen die Datenbank durcheinanderbringt. Leider sollen ja noch vier weitere Abfragen folgen, welche im Extremfall gleichzeitig ausgeführt werden (vorausgesetzt der Nutzer hat alle Optionen eingeschaltet).

Problem 1

Screenshot Problem 1 - Missing Data

Problem 3

Screenshot Problem 3 - Database Error

Problem 4

Screenshot Problem 4 - Missing Data
bertolla commented 3 years ago

For problem 1 I created a shell script and tried to do this call 100 times in a row. I couldn't reproduce the issue. The data was always complete. Maybe it got solved on one of the previous releases or it was a temporary problem. In any case, I would suggest to add a select request parameter to drastically reduce the payload and maybe it could also solve the issue on their side.

bertolla commented 3 years ago

Same for number 2, since it is closely related to 1 I can't reproduce the issue.

bertolla commented 3 years ago

For problem 3: I'm also not able to reproduce it, but I'll create a separate issue on ninja. In the meantime my suggestion is to handle the 400 status code and redo the same request if it only happens rarely.

Piiit commented 3 years ago

They talk about contemporaneous calls of all echarging types... maybe that causes the problem... was not able to reproduce either. I think we need more information about the calls... that is not just the single calls, but which get called at the same time.

bertolla commented 3 years ago

Well concurrent queries should not affect the results. How is that even possible?

Piiit commented 3 years ago

Theoretically not, but who knows... we had concurrency problems in the past... should be fixed by now.... but just saying that we might need more information....

rcavaliere commented 3 years ago

@bertolla @Piiit I got a feedback. The error is obtained if you make several times requests one after the other, see video...

https://user-images.githubusercontent.com/9825179/128006785-2f6cf94f-ffdf-4562-aeb5-a0e25a8bf96f.mp4

bertolla commented 3 years ago

This is just one of the issues which needs to be addressed. I created a first issue here: https://github.com/noi-techpark/it.bz.opendatahub.api.mobility-ninja/issues/20

Piiit commented 3 years ago

@rcavaliere I think I have pinned down this issue, it should now work and is testable on our testingmachine.eu instance.

Testable with https://mobility.api.opendatahub.testingmachine.eu as base URL...

Could you please get in contact with Projektionisten and ask if they could test again. Are they on github? So we could invite them directly to this issue?

Piiit commented 3 years ago

The commit that solves this issue is https://github.com/noi-techpark/it.bz.opendatahub.api.mobility-ninja/commit/57e02f053835a5172a1165c2b55d0c7a93a3c66f

rcavaliere commented 3 years ago

@Piiit testing by Projektionisten done, works well! Let's go in production with this bug-fix

Piiit commented 2 years ago

@rcavaliere on production now, please test again with the production endpoint