Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix - include username in laptime.to_dict() #47

Merged
merged 9 commits into from
Jul 3, 2024
4 changes: 3 additions & 1 deletion tracknow/backend/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Laptime(db.Model):
youtube_link = db.Column(db.String(255), nullable=True) # youtube link or evidence.
comment = db.Column(db.String(500), nullable=True)
# TODO Add date time.

def __repr__(self):
return f'<Laptime {self.time}>'

Expand All @@ -56,5 +57,6 @@ def to_dict(self):
'simracing': self.simracing,
'platform': self.platform,
'youtube_link': self.youtube_link,
'comment': self.comment
'comment': self.comment,
'by': self.user.username if self.user else None
}
4 changes: 3 additions & 1 deletion tracknow/backend/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ def get_user_laptime(id):
# Global - get all laptimes posted around the world.
@routes.route('/api/v1/laptimes', methods=['GET'])
def get_laptimes():
laptimes = Laptime.query.filter_by().all()
# TODO introduce randomness, recently added
laptimes = Laptime.query.all() #Laptime.query.filter_by().all()

return jsonify([lt.to_dict() for lt in laptimes]), 200

# Global - get one user laptime selected.
Expand Down
5 changes: 4 additions & 1 deletion tracknow/backend/static/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"basePath": "/api/v1",
"schemes": [
"http"
"https"
],
"paths": {
"/hello": {
Expand Down Expand Up @@ -538,6 +538,9 @@
},
"comment": {
"type": "string"
},
"by": {
"type": "string"
}
}
}
Expand Down