Conditions | 2 |
Total Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | from flask import Blueprint, jsonify |
||
8 | @api.route('/current') |
||
9 | def current(): |
||
10 | latest = db.session.scalar(func.MAX(TrailStatus.dt)) |
||
11 | |||
12 | trails = db.session.query(Trail.name, |
||
13 | Trail.difficulty, |
||
14 | Area.name.label('area'), |
||
15 | TrailStatus.open, |
||
16 | TrailStatus.groomed, |
||
17 | TrailStatus.snowmaking, |
||
18 | )\ |
||
19 | .filter(TrailStatus.trail_id == Trail.id, |
||
20 | Area.id == Trail.area_id, |
||
21 | TrailStatus.dt == latest) |
||
22 | |||
23 | return jsonify( |
||
24 | {'trails': [{'name': trail.name, |
||
25 | 'difficulty': trail.difficulty, |
||
26 | 'area': trail.area, |
||
27 | 'groomed': trail.groomed, |
||
28 | 'snowmaking': trail.snowmaking, |
||
29 | 'open': trail.open} for trail in trails]}) |
||
30 |