From 06af95ce57cb9925d745b9e842fc6328d08f5d92 Mon Sep 17 00:00:00 2001 From: fram3d Date: Wed, 4 Oct 2023 00:11:21 +0200 Subject: [PATCH] fix prediction --- freeriders/__pycache__/__init__.cpython-311.pyc | Bin 0 -> 602 bytes freeriders/__pycache__/functions.cpython-311.pyc | Bin 0 -> 817 bytes freeriders/__pycache__/models.cpython-311.pyc | Bin 0 -> 736 bytes freeriders/__pycache__/routes.cpython-311.pyc | Bin 0 -> 3978 bytes freeriders/functions.py | 2 +- freeriders/routes.py | 12 ++++++++---- 6 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 freeriders/__pycache__/__init__.cpython-311.pyc create mode 100644 freeriders/__pycache__/functions.cpython-311.pyc create mode 100644 freeriders/__pycache__/models.cpython-311.pyc create mode 100644 freeriders/__pycache__/routes.cpython-311.pyc diff --git a/freeriders/__pycache__/__init__.cpython-311.pyc b/freeriders/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fa4cf4eaf2ca8558ae25a0aef4d65cbb1975abe0 GIT binary patch literal 602 zcmZutJxc>Y5S_ivoykQ}u}GsFehhzuk81($zySw& z;3Eqmi4{-rv4z_hdkHI{07X>27gL_Z?Uxr(a;EsSd{0Exsgm5-YDT*7(oa Hu+Z@Z%6p(u literal 0 HcmV?d00001 diff --git a/freeriders/__pycache__/functions.cpython-311.pyc b/freeriders/__pycache__/functions.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0c2cd2f6d044468f18500e0dc6a171c914a9e427 GIT binary patch literal 817 zcmb_aF>ljA6nSh|5mCZGD@2kGAXSJ;kzmZytqV$h7hzG`;m(mD*ir`u ziv>11b^CyhX5ak&svSAzAGAC&-WTi+KrwRLOLAd zf6;+w2afNlyZx70aU#{1qUXHWkOkDy1*#>4eMs5Ww_9(v4(=tacEW1Mv^GXR{J);& zv8Ps(N0Oqfv=An($OWWX>CfU?O?erec}@k1u5Rf&TlvOT4jw10e!}X!TS9X<2Qb8ph=vsBO*_t)`)zR6pa0^gx|k!p(X0?Su24bO z?PqMatHhJQv7d<`D@_;YL8=1L&#XyQp)yppO}d)LVROe0NvfM)d2+LzEVg4SEicE#yu~$|QC&=aWBFimIax-jJRv{pY~g|H u^TD2YD6e5a|0U`X!pJ0qq`>y`XG969k6;ECA-D8$3YJAGBe)3pF~0$h-?0<` literal 0 HcmV?d00001 diff --git a/freeriders/__pycache__/models.cpython-311.pyc b/freeriders/__pycache__/models.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1b0b86c2e65de873569b42cae2cb5ea1f091e490 GIT binary patch literal 736 zcmb7Azi-n(6n=MhemG#sL@H7wCblp%QA7|zhym214($LH5?)SD?x1dMC!FmeOc@w5 zWXKSy9Xhu`?cahDDMNHC6I)Q2I&o*m<)@H%=X>|Pd!O}v_s&hT1TuQ}ObJBiZ6!zWr5sSio z`Gy-^?)nbzkt5dImUS_RJ-M`^nbS zY|PBY+-&r>7glA2$HvLs(|eP6YBgt8b8a>JJ8JP;nb2NU7o{Jz(pTnom7~;+rI-o5 wEYVf*aXOwSd_$HM8rG^k%KxO*tx70QCUYyzs3ZBuvI8DL;%mfjg+ zvsx-Y_yJXsiY1~TrImPST(@?lNR_2L`XQIDD!~P7| zmD9_eopaAU=iGDeoO`~*pK5A+2-?;Ar}(HBp?{J=sW}gc=PD4NA`Wp>28mRX66qu@ zGD(IaJUZhLok^$YO1jK3lW~ilq(}57y`nGaGkK1TUkoGzChg4Bh&9O?lXhilleIMB zor}TJqMV!a%u|oO4`_rQ!DBVfcMm-P@==L_lA$Adel7r-^fAqvW11&8*EEXOeot&g z86${!iR1Atg%_7IDTO!OnE&+(FDr%z^PGVBv=XHaCbhh5(A+F2)XZhEm{OK8KPTLI z%c!j$_Qwr3OmG4yQHFa)NH6h<45Wtx(~2PSlQ~D9EXoEmk(ePOBCjlDIXPY484zxG z7iz)6Zn7!RP2Ddkn_N;h%G2$2CkS(F)xncAh*VFkb9GRGl6jyvzS+~ z@R1}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ev z`@~LgLJdy*T0%AzK80sY~<^P+?fF6qTU=jSzYL3!&@q0uk~8 zy!)d4VMgnISMPrJS)&@6vXE`Vwc+|Mbn=t*RQqCWdyS)N^y7HHE0ZEB#+E;izhM0IQ-4h0c}W z>YLt?@gDTI9(p{^MC+h_fkI=+3Ne!RFiG=Sgs=e=_Ce_~ekpHgv2M0;}?}qP1*3WMxwgy$IU8CA{ zs=Y{usdGgHKR+;tK3(Q?m&Av*KH6T{%BoaMqhdN0E7GTk0{jq#J{!km<6+qJe*w+6 BY)=3H literal 0 HcmV?d00001 diff --git a/freeriders/functions.py b/freeriders/functions.py index a7af5fc..2a7e083 100644 --- a/freeriders/functions.py +++ b/freeriders/functions.py @@ -11,6 +11,6 @@ def predict(timestamp): base_timestamp = 1694003498 step = 8 - ticket = base_ticket + (int(time.time()) - base_timestamp) * step + ticket = base_ticket + (timestamp - base_timestamp) * step return ticket diff --git a/freeriders/routes.py b/freeriders/routes.py index adb4ac9..c3d3a3b 100644 --- a/freeriders/routes.py +++ b/freeriders/routes.py @@ -5,12 +5,11 @@ from freeriders.models import Tickets from datetime import datetime import time -PREDICTTIMERANGE = 60 * 80 @app.route('/sms', methods=['GET']) def sms(): if request.method == 'GET': - timenow = time.time() + timenow = int(time.time()) try: lastticket = Tickets.query.order_by(Tickets.timestamp.desc()).first() @@ -21,7 +20,7 @@ def sms(): lastticket = formatprefix10(lastticket.ticket) date = datetime.now() 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) except: return 'Error retriving last ticket' @@ -30,6 +29,7 @@ def sms(): @app.route('/submit', methods=['POST', 'GET']) def submit(): + PREDICTTIMERANGE = 60 * 80 if request.method == 'GET': return render_template('submit.html') elif request.method == 'POST': @@ -37,9 +37,13 @@ def submit(): ticket_input = request.form['ticket'] 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) else: + print(int(ticket_input)) + print(predict(timenow - PREDICTTIMERANGE)) + print(predict(timenow + PREDICTTIMERANGE)) + print(predict(timenow)) return 'Ticket number is in unexpected range.' else: return 'Ticket format is wrong. Only 10 digits allowed.'