Compare commits
9 Commits
master
...
prepare202
Author | SHA1 | Date |
---|---|---|
jlusiardi | 0f7c36a804 | |
Joachim Lusiardi | 3bfc2fc182 | |
Joachim Lusiardi | 802af2418a | |
jlusiardi | cd9fc4755e | |
jlusiardi | 158c419747 | |
Patrick Kilian | 79e5fdf56b | |
jlusiardi | a9338805e2 | |
jlusiardi | 7f82a288da | |
jlusiardi | 8728d3028b |
|
@ -6,7 +6,6 @@ from flask_sqlalchemy import SQLAlchemy
|
|||
import os
|
||||
from config import config
|
||||
from flask_security.forms import LoginForm
|
||||
from flask_limiter import Limiter
|
||||
from flask_limiter.util import get_remote_address
|
||||
|
||||
from .forms import *
|
||||
|
@ -15,13 +14,6 @@ from .forms import *
|
|||
app = Flask(__name__)
|
||||
app.config.from_object(config[os.getenv('FLASK_CONFIG') or 'default'])
|
||||
|
||||
# applies to all routes, so choose limits wisely!
|
||||
limiter = Limiter(
|
||||
app,
|
||||
key_func=get_remote_address,
|
||||
# default_limits=["500 per second"]
|
||||
)
|
||||
|
||||
|
||||
@app.errorhandler(429)
|
||||
def ratelimit_handler(e):
|
||||
|
|
|
@ -4,7 +4,7 @@ from flask_security.core import current_user
|
|||
import requests
|
||||
|
||||
from ..entities import FillingStation
|
||||
from .. import app, db, limiter
|
||||
from .. import app, db
|
||||
|
||||
|
||||
@app.route('/filling_stations/favourites/toggle/<fsid>')
|
||||
|
@ -24,7 +24,6 @@ def add_favourite_filling_stations(fsid):
|
|||
|
||||
@app.route('/filling_stations', methods=['GET'])
|
||||
@login_required
|
||||
@limiter.limit('1 per second')
|
||||
def query_filling_stations():
|
||||
api_key = app.config['TANKERKOENIG_API_KEY']
|
||||
|
||||
|
|
|
@ -164,6 +164,7 @@
|
|||
<ul id="consumable_{{vehicle.id}}_{{consumable.id}}_tabs" class="nav nav-tabs" data-tabs="tabs">
|
||||
{{ nav_tab(vehicle.id|string + '_' + consumable.id|string + '_consumption', 'Consumption', true) }}
|
||||
{{ nav_tab(vehicle.id|string + '_' + consumable.id|string + '_amount', 'Amount', false) }}
|
||||
{{ nav_tab(vehicle.id|string + '_' + consumable.id|string + '_price', 'Price', false) }}
|
||||
</ul>
|
||||
<div id="consumable_{{vehicle.id}}_{{consumable.id}}_content" class="tab-content ">
|
||||
{{ tab_pane(
|
||||
|
@ -188,6 +189,17 @@
|
|||
false
|
||||
)
|
||||
}}
|
||||
{{ tab_pane(
|
||||
vehicle.id|string + '_' + consumable.id|string + '_price',
|
||||
chart(
|
||||
consumable.price,
|
||||
'ref_' + vehicle.id|string + '_' + consumable.id|string + '_price',
|
||||
'€ / '+consumable.unit,
|
||||
url_for('create_pit_stop_form', vid=vehicle.id, cid=consumable.id)
|
||||
),
|
||||
false
|
||||
)
|
||||
}}
|
||||
</div>
|
||||
{{ tab_script('vehicle_' + vehicle.id|string + '_' + consumable.id|string + '_tabs') }}
|
||||
</div>
|
||||
|
|
|
@ -27,6 +27,7 @@ class ConsumableStats:
|
|||
self.average_amount_used = 0
|
||||
self.average_amount = []
|
||||
self.amounts = []
|
||||
self.price = []
|
||||
|
||||
pitstops = [
|
||||
stop for stop in vehicle.pitstops if stop.consumable_id == consumable.id
|
||||
|
@ -37,6 +38,9 @@ class ConsumableStats:
|
|||
for pitstop in pitstops:
|
||||
self.overall_amount += pitstop.amount
|
||||
self.amounts.append(StatsEvent(pitstop.date, pitstop.amount))
|
||||
# some pitstops seem to have lost their costs...
|
||||
if pitstop.costs:
|
||||
self.price.append(StatsEvent(pitstop.date, pitstop.costs/pitstop.amount))
|
||||
self.average_amount_fuelled = self.overall_amount / pitstop_count
|
||||
if pitstop_count > 1:
|
||||
overall_distance = (
|
||||
|
|
|
@ -41,8 +41,8 @@ class TestingConfig(Config):
|
|||
|
||||
|
||||
class ProductionConfig(Config):
|
||||
SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:{h}@database/pitstops'.format(
|
||||
h=os.environ.get('DATABASE_ENV_MYSQL_ROOT_PASSWORD'))
|
||||
SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://pitstops:{h}@localhost/pitstops'.format(
|
||||
h=os.environ.get('MYSQL_PASSWORD'))
|
||||
|
||||
|
||||
config = {
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
Flask
|
||||
Flask-SQLAlchemy
|
||||
Flask-Security
|
||||
Flask-WTF
|
||||
PyMySQL
|
||||
Flask==2.1.2
|
||||
Flask-SQLAlchemy==2.5.1
|
||||
Flask-Security==3.0.0
|
||||
Flask-WTF==1.0.1
|
||||
PyMySQL==1.0.2
|
||||
markdown
|
||||
Flask-Limiter
|
||||
requests
|
||||
email_validator
|
||||
Flask-Limiter==2.4.5.1
|
||||
requests==2.27.1
|
||||
email-validator==1.2.1
|
||||
gunicorn==20.1.0
|
||||
pytz==2022.1
|
||||
SQLAlchemy==1.4.36
|
||||
Werkzeug==2.2.2
|
Loading…
Reference in New Issue