def show(): # get current_user location to show at center of map post_data = request.get_json() print(post_data) user = User.get_or_none(id=post_data.get('id')) current_location = Position.get(Position.user == user.id) locations = [] # positions = (Position.select() # .where( # Position.user!=user.id, # Position.updated_at+datetime.timedelta(minutes=180) > datetime.datetime.now() # )) positions = (Position.select().where( Position.updated_at + datetime.timedelta(minutes=180) > datetime.datetime.now())) for position in positions: locations.append({ 'user': position.user.username, 'position': { 'lat': float(position.lat), 'lng': float(position.lng) } }) return jsonify({ 'ok': True, 'locations': locations, 'current_user': user.username, 'current_location_lat': float(current_location.lat), 'current_location_lng': float(current_location.lng) })
def show(): # get current_user location to show at center of map current_location = Position.get(Position.user == current_user.id) locations = [] positions = (Position.select().where( Position.user != current_user.id, Position.updated_at + datetime.timedelta(minutes=15) > datetime.datetime.now())) for position in positions: locations.append({ 'user': position.user.username, 'position': { 'lat': float(position.lat), 'lng': float(position.lng) } }) return jsonify({ 'ok': True, 'locations': locations, 'current_user': current_user.username, 'current_location_lat': float(current_location.lat), 'current_location_lng': float(current_location.lng) })