def get_mutual_friends(args, person_id): source = Person.query.get_or_404(person_id) target = Person.query.get_or_404(args['target_id']) people_schema = PersonSchema(many=True) mutuals = source.mutual_friends(target) return people_schema.jsonify(mutuals), HTTPStatus.OK
def get_mutual_friends(person_id): target_id = int(request.args['target_id']) people_schema = PersonSchema(many=True) person = Person.query.filter(Person.id == person_id).one() target = Person.query.filter(Person.id == target_id).one() people = person.mutual_friends(target) return people_schema.jsonify(people), HTTPStatus.OK
def get_people(): people_schema = PersonSchema(many=True) opt_sort = request.args.get('sort') if opt_sort: if opt_sort[0] == ('-'): people = Person.query.order_by(desc(opt_sort[1:len(opt_sort)])) else: people = Person.query.order_by(opt_sort) else: people = Person.query.all() return people_schema.jsonify(people), HTTPStatus.OK
def get_people(args): people_schema = PersonSchema(many=True) order_by = None if(args): if(args['sort'] == '-created_at'): order_by = Person.created_at.desc() elif(args['sort'] == 'created_at'): order_by = Person.created_at elif(args['sort'] == '-name'): order_by = Person.first_name.desc() elif(args['sort'] == 'name'): order_by = Person.first_name people = (Person.query .order_by(order_by) .all()) return people_schema.jsonify(people), HTTPStatus.OK
def get_people(): people_schema = PersonSchema(many=True) people = Person.query.all() return people_schema.jsonify(people), HTTPStatus.OK