GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 3eec9f...47bd99 )
by Alex
01:51
created

current()   A

Complexity

Conditions 2

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 22
rs 9.2
1
from flask import Blueprint, jsonify
2
from sqlalchemy import JSON, func
3
4
from sugarloaf.models import db, TrailStatus, Trail, Area
5
6
api = Blueprint('api', __name__)
7
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