mirror of
https://github.com/LukeHagar/pypistats.org.git
synced 2025-12-09 20:57:48 +00:00
move plot declarations to app config
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from celery.schedules import crontab
|
from celery.schedules import crontab
|
||||||
|
from flask import json
|
||||||
|
|
||||||
|
|
||||||
def get_db_uri(env):
|
def get_db_uri(env):
|
||||||
@@ -34,6 +35,15 @@ class Config(object):
|
|||||||
SECRET_KEY = os.environ.get("PYPISTATS_SECRET", "secret-key")
|
SECRET_KEY = os.environ.get("PYPISTATS_SECRET", "secret-key")
|
||||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
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):
|
class ProdConfig(Config):
|
||||||
"""Production configuration."""
|
"""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):
|
class MyForm(FlaskForm):
|
||||||
"""Search form."""
|
"""Search form."""
|
||||||
|
|
||||||
@@ -128,10 +119,10 @@ def package(package):
|
|||||||
# Build the plots
|
# Build the plots
|
||||||
plots = []
|
plots = []
|
||||||
for model in model_data:
|
for model in model_data:
|
||||||
plot = deepcopy(PLOT_BASE)
|
plot = deepcopy(current_app.config["PLOT_BASE"])
|
||||||
data = []
|
data = []
|
||||||
for category, values in model["data"].items():
|
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["x"] = values["x"]
|
||||||
base["y"] = values["y"]
|
base["y"] = values["y"]
|
||||||
base["name"] = category.title()
|
base["name"] = category.title()
|
||||||
|
|||||||
Reference in New Issue
Block a user