jamespfennell / transiter

Web service for transit data
https://demo.transiter.dev
MIT License
59 stars 7 forks source link

New custom parser API #40

Closed jamespfennell closed 4 years ago

jamespfennell commented 4 years ago

Currently, someone writing a custom Transiter feed parser is expected to know a bit about how Transiter works internally because they are responsible for persisting entities in the feed to the DB. This is unnecessary. Someone writing a custom feed parser should just be responsible for converting the feed content into the Transiter entities represented in the feed. The business logic for how these should be persisted should be handled exclusively by Transiter.

New feed parser API

A feed parser is a Python function that accepts two arguments:

  1. A transiter.models.FeedUpdate object containing information on the current feed update event,
  2. The current content of the feed in binary,

and returns

An updatable Transiter object is one of the following objects:

  1. Stop
  2. Route
  3. ScheduledService
  4. ScheduledTrip (with ScheduledTripStopTime objects contained in the stop_times field)
  5. Trip (with TripStopTime objects contained in the stop_times field)
  6. Alert

After the parser returns these objects, Transiter will sync them to the DB automatically.

jamespfennell commented 4 years ago

Will resolve #10

jamespfennell commented 4 years ago

Resolved on branch NewParserAPI