Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: filtering by timespan #2

Open
myxor opened this issue Jan 15, 2020 · 6 comments
Open

API: filtering by timespan #2

myxor opened this issue Jan 15, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@myxor
Copy link
Owner

myxor commented Jan 15, 2020

The API should be able to filter by timespans

@myxor myxor added the enhancement New feature or request label Jan 15, 2020
@Funatiker
Copy link

First of all, thank you so much for this project!

If I may make a remark, then I would appreciate if more information on times was stored in log. Currently, lastStateChange is stored in vehicles. Shouldn't it be stored in log? A parking vehicle marks then probably the end of a ride since lastStateChange. If there are two log entries with slightly different GPS coordinates but the same lastStateChange, then this is probably not a trip (that would appear on the heatmap of #1 ) but drifting GPS coordinate. Additionally, log could store last timestamp when the log was received from the server. This could be an approximation of the begin of the next trip.

@myxor
Copy link
Owner Author

myxor commented Jan 17, 2020

First of all, thank you so much for this project!

You are welcome. Thank you for supporting this.

If I may make a remark, then I would appreciate if more information on times was stored in log. Currently, lastStateChange is stored in vehicles. Shouldn't it be stored in log? A parking vehicle marks then probably the end of a ride since lastStateChange.

As the TIER API is not documented i am not quite sure what kind of state-change this value represents. It could be driving/resting or rented/free or powered on/powered off or some other state.

Before moving this column to the log table i would suggest we should find out what kind of state this value repesents (probably easiest way is to really rent a scooter and see what happens with this value on the matching vehicle).

Additionally, log could store last timestamp when the log was received from the server. This could be an approximation of the begin of the next trip.

The column timestamp in the table log is filled with the current UTC timestamp when the row is inserted. See log.py#L109.
@Funatiker Is this what you are talking about?

@Funatiker
Copy link

The column timestamp in the table log is filled with the current UTC timestamp when the row is inserted. See log.py#L109.
@Funatiker Is this what you are talking about?
Almost! A line is only reinserted/updated when the location, the battery level or the 30-min-timegrame has changed.

query = "SELECT internal_id FROM log WHERE internal_id = ? AND timestamp > ? AND lat = ? AND lng = ? AND batteryLevel = ? AND state = ? ORDER BY timestamp DESC LIMIT 1"
This means that the timestamp you mentioned only stores when the log has first been touched but not when it has been touched for the last time. Or with other words: From the currently stored data, we can't tell the difference whether a scooter that has been logged at 11:51 has disappeared at 11:52 or at 12:26 if we see it a again at 12:27.

@myxor
Copy link
Owner Author

myxor commented Jan 17, 2020

Now i got you.
Wouldn't it be better then to fill a new column called lastSeen or similar in the vehicle table with the timestamp?

@Funatiker
Copy link

Ah. Sorry for having been unclear. I did mean storing an additional column with the lastSeen value.

About the other remark, the state change timestamp: From observing vehicles around me, I got the impression that the timestamp is updated when the vehicle gets (de)activated. The last rental/return time does not seem to be exposed directly by the API.

@myxor
Copy link
Owner Author

myxor commented Jan 22, 2020

Ah. Sorry for having been unclear. I did mean storing an additional column with the lastSeen value.

I can see the usage of this value.
Feel free to implement this and send a pull request so i can merge it :)

From observing vehicles around me, I got the impression that the timestamp is updated when the vehicle gets (de)activated. The last rental/return time does not seem to be exposed directly by the API.

Thanks for finding this. Good to know.
Let's see if we can use this information for this project somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants