fix prediction
This commit is contained in:
parent
ba69c2a97f
commit
06af95ce57
BIN
freeriders/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
freeriders/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
freeriders/__pycache__/functions.cpython-311.pyc
Normal file
BIN
freeriders/__pycache__/functions.cpython-311.pyc
Normal file
Binary file not shown.
BIN
freeriders/__pycache__/models.cpython-311.pyc
Normal file
BIN
freeriders/__pycache__/models.cpython-311.pyc
Normal file
Binary file not shown.
BIN
freeriders/__pycache__/routes.cpython-311.pyc
Normal file
BIN
freeriders/__pycache__/routes.cpython-311.pyc
Normal file
Binary file not shown.
@ -11,6 +11,6 @@ def predict(timestamp):
|
|||||||
base_timestamp = 1694003498
|
base_timestamp = 1694003498
|
||||||
step = 8
|
step = 8
|
||||||
|
|
||||||
ticket = base_ticket + (int(time.time()) - base_timestamp) * step
|
ticket = base_ticket + (timestamp - base_timestamp) * step
|
||||||
return ticket
|
return ticket
|
||||||
|
|
||||||
|
@ -5,12 +5,11 @@ from freeriders.models import Tickets
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import time
|
import time
|
||||||
|
|
||||||
PREDICTTIMERANGE = 60 * 80
|
|
||||||
|
|
||||||
@app.route('/sms', methods=['GET'])
|
@app.route('/sms', methods=['GET'])
|
||||||
def sms():
|
def sms():
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
timenow = time.time()
|
timenow = int(time.time())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
lastticket = Tickets.query.order_by(Tickets.timestamp.desc()).first()
|
lastticket = Tickets.query.order_by(Tickets.timestamp.desc()).first()
|
||||||
@ -21,7 +20,7 @@ def sms():
|
|||||||
lastticket = formatprefix10(lastticket.ticket)
|
lastticket = formatprefix10(lastticket.ticket)
|
||||||
date = datetime.now()
|
date = datetime.now()
|
||||||
datenow = f'{formatprefix2(date.day)}.{formatprefix2(date.month)}.{date.year}'
|
datenow = f'{formatprefix2(date.day)}.{formatprefix2(date.month)}.{date.year}'
|
||||||
timenow = f'{formatprefix2(date.hour)}:{formatprefix2(date.minute)}:formatprefix2{date.second}'
|
timenow = f'{formatprefix2(date.hour)}:{formatprefix2(date.minute)}:{formatprefix2(date.second)}'
|
||||||
return render_template('sms.html', ticket = lastticket, date = datenow, time = timenow)
|
return render_template('sms.html', ticket = lastticket, date = datenow, time = timenow)
|
||||||
except:
|
except:
|
||||||
return 'Error retriving last ticket'
|
return 'Error retriving last ticket'
|
||||||
@ -30,6 +29,7 @@ def sms():
|
|||||||
|
|
||||||
@app.route('/submit', methods=['POST', 'GET'])
|
@app.route('/submit', methods=['POST', 'GET'])
|
||||||
def submit():
|
def submit():
|
||||||
|
PREDICTTIMERANGE = 60 * 80
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
return render_template('submit.html')
|
return render_template('submit.html')
|
||||||
elif request.method == 'POST':
|
elif request.method == 'POST':
|
||||||
@ -37,9 +37,13 @@ def submit():
|
|||||||
ticket_input = request.form['ticket']
|
ticket_input = request.form['ticket']
|
||||||
|
|
||||||
if ticket_input.isdigit() and len(ticket_input) == 10 :
|
if ticket_input.isdigit() and len(ticket_input) == 10 :
|
||||||
if ticket_input < predict(timenow + PREDICTTIMERANGE ) and ticket_input > predict(timenow - PREDICTTIMERANGE ) :
|
if int(ticket_input) < predict(timenow + PREDICTTIMERANGE ) and int(ticket_input) > predict(timenow - PREDICTTIMERANGE ) :
|
||||||
ticket = Tickets(ticket = int(ticket_input), timestamp = timenow)
|
ticket = Tickets(ticket = int(ticket_input), timestamp = timenow)
|
||||||
else:
|
else:
|
||||||
|
print(int(ticket_input))
|
||||||
|
print(predict(timenow - PREDICTTIMERANGE))
|
||||||
|
print(predict(timenow + PREDICTTIMERANGE))
|
||||||
|
print(predict(timenow))
|
||||||
return 'Ticket number is in unexpected range.'
|
return 'Ticket number is in unexpected range.'
|
||||||
else:
|
else:
|
||||||
return 'Ticket format is wrong. Only 10 digits allowed.'
|
return 'Ticket format is wrong. Only 10 digits allowed.'
|
||||||
|
Loading…
Reference in New Issue
Block a user