mirror of
https://github.com/LukeHagar/pypistats.org.git
synced 2025-12-06 04:21:09 +00:00
move plot declarations to app config
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import os
|
||||
|
||||
from celery.schedules import crontab
|
||||
from flask import json
|
||||
|
||||
|
||||
def get_db_uri(env):
|
||||
@@ -34,6 +35,15 @@ class Config(object):
|
||||
SECRET_KEY = os.environ.get("PYPISTATS_SECRET", "secret-key")
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||
|
||||
# Plotly chart definitions
|
||||
PLOT_BASE = json.load(
|
||||
open(os.path.join(os.path.dirname(__file__), "plots", "plot_base.json"))
|
||||
)
|
||||
DATA_BASE = json.load(
|
||||
open(os.path.join(os.path.dirname(__file__), "plots", "data_base.json"))
|
||||
)
|
||||
|
||||
|
||||
|
||||
class ProdConfig(Config):
|
||||
"""Production configuration."""
|
||||
|
||||
@@ -33,15 +33,6 @@ MODELS = [
|
||||
]
|
||||
|
||||
|
||||
# Plotly chart definitions
|
||||
PLOT_BASE = json.load(
|
||||
open(os.path.join(current_app.root_path, 'plots', 'plot_base.json'))
|
||||
)
|
||||
DATA_BASE = json.load(
|
||||
open(os.path.join(current_app.root_path, 'plots', 'data_base.json'))
|
||||
)
|
||||
|
||||
|
||||
class MyForm(FlaskForm):
|
||||
"""Search form."""
|
||||
|
||||
@@ -128,10 +119,10 @@ def package(package):
|
||||
# Build the plots
|
||||
plots = []
|
||||
for model in model_data:
|
||||
plot = deepcopy(PLOT_BASE)
|
||||
plot = deepcopy(current_app.config["PLOT_BASE"])
|
||||
data = []
|
||||
for category, values in model["data"].items():
|
||||
base = deepcopy(DATA_BASE["data"][0])
|
||||
base = deepcopy(current_app.config["DATA_BASE"]["data"][0])
|
||||
base["x"] = values["x"]
|
||||
base["y"] = values["y"]
|
||||
base["name"] = category.title()
|
||||
|
||||
Reference in New Issue
Block a user