Save every trip in new table named tc_trips

roneskinder6 years ago

Im looking for an easy implementation to save all the trips into a new table named tc_trips, containing all the data from the trip. This can be triggered every time a trip is finished (engine off), maybe a daemon to search for this event and then flag as completed.

All the coordinates can be saved in a field as JSON. This way will be easier to generate trips report it wont have to query the entire tc_locations table and do all the calculations every time the trips are needed to be shown, just query the tc_trips table with all the trip related data.

Any suggestions will be appreciated.

roneskinder6 years ago

For anyone looking for something similar:

  1. Created a new table from the changelog named tc_trips with all the parameters returning from api/reports/trips.
  2. Added a column in table tc_positions "tripid", to reference the positions relevant to a specific trip.
  3. Changed query for trips added WHERE tripid = 0, so api/reports/trips will only returns new trips to the service.
  4. Added a daemon that runs every 5 minutes and GET all new trips from API then saves result to table tc_trips, then updates tc_positions with the "tripid".
  5. Added new API request trips that works with new table tc_trips to my own usage.