示例#1
0
def index():
    fix_schema = TrackingFixSchema(only=('time', 'location', 'altitude',
                                         'elevation', 'pilot'))
    airport_schema = AirportSchema(only=('id', 'name', 'countryCode'))

    @cache.memoize(timeout=(60 * 60))
    def get_nearest_airport(track):
        airport = Airport.by_location(track.location, None)
        if not airport:
            return None

        return dict(airport=airport_schema.dump(airport).data,
                    distance=airport.distance(track.location))

    tracks = []
    for t in TrackingFix.get_latest():
        nearest_airport = get_nearest_airport(t)

        track = fix_schema.dump(t).data
        if nearest_airport:
            track['nearestAirport'] = nearest_airport['airport']
            track['nearestAirportDistance'] = nearest_airport['distance']

        tracks.append(track)

    if request.user_id:
        followers = [
            f.destination_id for f in Follower.query(source_id=request.user_id)
        ]
    else:
        followers = []

    return jsonify(friends=followers, tracks=tracks)
示例#2
0
def index():
    fix_schema = TrackingFixSchema(only=("time", "location", "altitude",
                                         "elevation", "pilot"))
    airport_schema = AirportSchema(only=("id", "name", "countryCode"))

    @cache.memoize(timeout=(60 * 60))
    def get_nearest_airport(track):
        airport = Airport.by_location(track.location, None)
        if not airport:
            return None

        return dict(
            airport=airport_schema.dump(airport).data,
            distance=airport.distance(track.location),
        )

    tracks = []
    for t in TrackingFix.get_latest():
        nearest_airport = get_nearest_airport(t)

        track = fix_schema.dump(t).data
        if nearest_airport:
            track["nearestAirport"] = nearest_airport["airport"]
            track["nearestAirportDistance"] = nearest_airport["distance"]

        tracks.append(track)

    if request.user_id:
        followers = [
            f.destination_id for f in Follower.query(source_id=request.user_id)
        ]
    else:
        followers = []

    return jsonify(friends=followers, tracks=tracks)
示例#3
0
def index():
    if 'application/json' not in request.headers.get('Accept', ''):
        return render_template('ember-page.jinja', active_page='tracking')

    fix_schema = TrackingFixSchema(only=('time', 'location', 'altitude', 'elevation', 'pilot'))
    airport_schema = AirportSchema(only=('id', 'name', 'countryCode'))

    @current_app.cache.memoize(timeout=(60 * 60))
    def get_nearest_airport(track):
        airport = Airport.by_location(track.location, None)
        if not airport:
            return None

        return dict(airport=airport_schema.dump(airport).data,
                    distance=airport.distance(track.location))

    tracks = []
    for t in TrackingFix.get_latest():
        nearest_airport = get_nearest_airport(t)

        track = fix_schema.dump(t).data
        if nearest_airport:
            track['nearestAirport'] = nearest_airport['airport']
            track['nearestAirportDistance'] = nearest_airport['distance']

        tracks.append(track)

    if g.current_user:
        followers = [f.destination_id for f in Follower.query(source=g.current_user)]
    else:
        followers = []

    return jsonify(friends=followers, tracks=tracks)
示例#4
0
def index():
    fix_schema = TrackingFixSchema(only=('time', 'location', 'altitude', 'elevation', 'pilot'))
    airport_schema = AirportSchema(only=('id', 'name', 'countryCode'))

    @cache.memoize(timeout=(60 * 60))
    def get_nearest_airport(track):
        airport = Airport.by_location(track.location, None)
        if not airport:
            return None

        return dict(airport=airport_schema.dump(airport).data,
                    distance=airport.distance(track.location))

    tracks = []
    for t in TrackingFix.get_latest():
        nearest_airport = get_nearest_airport(t)

        track = fix_schema.dump(t).data
        if nearest_airport:
            track['nearestAirport'] = nearest_airport['airport']
            track['nearestAirportDistance'] = nearest_airport['distance']

        tracks.append(track)

    if request.user_id:
        followers = [f.destination_id for f in Follower.query(source_id=request.user_id)]
    else:
        followers = []

    return jsonify(friends=followers, tracks=tracks)
示例#5
0
def index():
    if 'application/json' not in request.headers.get('Accept', ''):
        return render_template('ember-page.jinja', active_page='tracking')

    fix_schema = TrackingFixSchema(only=('time', 'location', 'altitude',
                                         'elevation', 'pilot'))
    airport_schema = AirportSchema(only=('id', 'name', 'countryCode'))

    @current_app.cache.memoize(timeout=(60 * 60))
    def get_nearest_airport(track):
        airport = Airport.by_location(track.location, None)
        if not airport:
            return None

        return dict(airport=airport_schema.dump(airport).data,
                    distance=airport.distance(track.location))

    tracks = []
    for t in TrackingFix.get_latest():
        nearest_airport = get_nearest_airport(t)

        track = fix_schema.dump(t).data
        if nearest_airport:
            track['nearestAirport'] = nearest_airport['airport']
            track['nearestAirportDistance'] = nearest_airport['distance']

        tracks.append(track)

    if g.current_user:
        followers = [
            f.destination_id for f in Follower.query(source=g.current_user)
        ]
    else:
        followers = []

    return jsonify(friends=followers, tracks=tracks)
示例#6
0
def index():
    fix_schema = TrackingFixSchema(
        only=("time", "location", "altitude", "elevation", "pilot")
    )
    airport_schema = AirportSchema(only=("id", "name", "countryCode"))

    @cache.memoize(timeout=(60 * 60))
    def get_nearest_airport(track):
        airport = Airport.by_location(track.location, None)
        if not airport:
            return None

        return dict(
            airport=airport_schema.dump(airport).data,
            distance=airport.distance(track.location),
        )

    tracks = []
    for t in TrackingFix.get_latest():
        nearest_airport = get_nearest_airport(t)

        track = fix_schema.dump(t).data
        if nearest_airport:
            track["nearestAirport"] = nearest_airport["airport"]
            track["nearestAirportDistance"] = nearest_airport["distance"]

        tracks.append(track)

    if request.user_id:
        followers = [
            f.destination_id for f in Follower.query(source_id=request.user_id)
        ]
    else:
        followers = []

    return jsonify(friends=followers, tracks=tracks)