Remove unnecessary video_id

master
Nikola Forró 7 years ago
parent fa1721725b
commit 929651b223

@ -15,7 +15,6 @@ Example response:
```JSON ```JSON
{ {
"id": 28, "id": 28,
"video_id": 0,
"date": "2018-01-01", "date": "2018-01-01",
"game": "IRL", "game": "IRL",
"text": "Cheese?", "text": "Cheese?",
@ -42,7 +41,6 @@ Example response:
[ [
{ {
"id": 28, "id": 28,
"video_id": 0,
"date": "2018-01-01", "date": "2018-01-01",
"game": "IRL", "game": "IRL",
"text": "Cheese?", "text": "Cheese?",
@ -51,7 +49,6 @@ Example response:
}, },
{ {
"id": 42, "id": 42,
"video_id": 0,
"date": "2018-02-02", "date": "2018-02-02",
"game": "IRL", "game": "IRL",
"text": "Cheese!", "text": "Cheese!",
@ -87,7 +84,6 @@ Parameters:
* `date` (required) - Date in ISO 8601 format * `date` (required) - Date in ISO 8601 format
* `game` (required) - Related game * `game` (required) - Related game
* `text` (required) - Text of the quote * `text` (required) - Text of the quote
* `video_id` (optional) - Twitch video ID
## Replace specific quote ## Replace specific quote
@ -106,7 +102,6 @@ Parameters:
* `date` (required) - Date in ISO 8601 format * `date` (required) - Date in ISO 8601 format
* `game` (required) - Related game * `game` (required) - Related game
* `text` (required) - Text of the quote * `text` (required) - Text of the quote
* `video_id` (optional) - Twitch video ID
## Delete specific quote ## Delete specific quote

@ -23,7 +23,6 @@ api = flask_restful.Api(app)
quote_fields = { quote_fields = {
'id': flask_restful.fields.Integer(), 'id': flask_restful.fields.Integer(),
'video_id': flask_restful.fields.Integer(),
'date': flask_restful.fields.DateTime(dt_format='iso8601'), 'date': flask_restful.fields.DateTime(dt_format='iso8601'),
'game': flask_restful.fields.String(), 'game': flask_restful.fields.String(),
'text': flask_restful.fields.String(), 'text': flask_restful.fields.String(),
@ -34,7 +33,6 @@ quote_fields = {
quote_parser = flask_restful.reqparse.RequestParser() quote_parser = flask_restful.reqparse.RequestParser()
quote_parser.add_argument('id', type=int) quote_parser.add_argument('id', type=int)
quote_parser.add_argument('video_id', type=int)
quote_parser.add_argument('date', type=flask_restful.inputs.date, required=True) quote_parser.add_argument('date', type=flask_restful.inputs.date, required=True)
quote_parser.add_argument('game', type=str, required=True) quote_parser.add_argument('game', type=str, required=True)
quote_parser.add_argument('text', type=str, required=True) quote_parser.add_argument('text', type=str, required=True)
@ -80,7 +78,6 @@ class QuoteResource(flask_restful.Resource):
quote = q.first() quote = q.first()
if not quote: if not quote:
quote = Quote(id=id, created_at=now) quote = Quote(id=id, created_at=now)
quote.video_id = args['video_id'] # FIXME: NULL
quote.date = args['date'] quote.date = args['date']
quote.game = args['game'] quote.game = args['game']
quote.text = args['text'] quote.text = args['text']
@ -135,7 +132,6 @@ class QuotesResource(flask_restful.Resource):
quote = q.first() quote = q.first()
if not quote: if not quote:
quote = Quote(id=args['id'], created_at=now) quote = Quote(id=args['id'], created_at=now)
quote.video_id = args['video_id'] # FIXME: NULL
quote.date = args['date'] quote.date = args['date']
quote.game = args['game'] quote.game = args['game']
quote.text = args['text'] quote.text = args['text']

@ -8,7 +8,6 @@ class Quote(db.Model):
__tablename__ = 'quotes' __tablename__ = 'quotes'
id = db.Column(db.Integer, primary_key=True) id = db.Column(db.Integer, primary_key=True)
video_id = db.Column(db.Integer)
date = db.Column(db.Date) date = db.Column(db.Date)
game = db.Column(db.String) game = db.Column(db.String)
text = db.Column(db.String) text = db.Column(db.String)

@ -82,14 +82,12 @@ def main():
quote = m.groupdict() quote = m.groupdict()
quote['id'] = int(quote['id']) + 10000 quote['id'] = int(quote['id']) + 10000
quote['date'] = dateutil.parser.parse(quote['date'], dayfirst=True) quote['date'] = dateutil.parser.parse(quote['date'], dayfirst=True)
quote['video_id'] = video['id']
quotes.append(quote) quotes.append(quote)
for quote in quotes: for quote in quotes:
now = sqlalchemy.func.now() now = sqlalchemy.func.now()
q = db.session.query(Quote).filter(Quote.id == quote['id']).first() q = db.session.query(Quote).filter(Quote.id == quote['id']).first()
if not q: if not q:
q = Quote(id=quote['id'], created_at=now) q = Quote(id=quote['id'], created_at=now)
q.video_id = quote['video_id']
q.date = quote['date'] q.date = quote['date']
q.game = quote['game'] q.game = quote['game']
q.text = quote['text'] q.text = quote['text']

Loading…
Cancel
Save