From b952083d13f94b5714093dcbfa17d406444b1f39 Mon Sep 17 00:00:00 2001 From: "sqrd.max" Date: Wed, 29 Nov 2023 18:00:28 +0200 Subject: [PATCH] finished select value --- python/rcdb/model.py | 4 +- rcdb_web/__init__.py | 22 ++++++----- rcdb_web/select_values/veiws.py | 11 ++++-- rcdb_web/templates/run_search_box.html | 43 +++++++++------------ rcdb_web/templates/select_values/index.html | 4 +- 5 files changed, 42 insertions(+), 42 deletions(-) diff --git a/python/rcdb/model.py b/python/rcdb/model.py index dabc1db..2263dc1 100644 --- a/python/rcdb/model.py +++ b/python/rcdb/model.py @@ -119,10 +119,10 @@ class RunPeriod(ModelBase): id = Column(Integer, primary_key=True) name = Column(String(255), nullable=False) description = Column(String(255), nullable=True) - start_date = Column(Date, nullable=True) - end_date = Column(Date, nullable=True) run_min = Column(Integer, nullable=False) run_max = Column(Integer, nullable=False) + start_date = Column(Date, nullable=True) + end_date = Column(Date, nullable=True) def __repr__(self): return "".format(self.name, self.run_min, self.run_max) diff --git a/rcdb_web/__init__.py b/rcdb_web/__init__.py index e4d64a9..17bddf4 100644 --- a/rcdb_web/__init__.py +++ b/rcdb_web/__init__.py @@ -1,5 +1,5 @@ from rcdb.alias import get_default_aliases_by_name -from rcdb.model import Run +from rcdb.model import Run, RunPeriod from flask import Flask, render_template, g, request, url_for import rcdb from datetime import datetime @@ -46,22 +46,26 @@ def not_found(error): @app.route('/sample') def sample(): - return render_template('index.html') +@app.route('/run_periods') +def run_periods(): + run_periods = g.tdb.session.query(RunPeriod).all() + + @app.route('/') def index(): - # Select the last 50 runs and - runs = g.tdb.session\ - .query(Run)\ - .order_by(Run.number.desc())\ - .options(subqueryload(Run.conditions))\ + runs = g.tdb.session \ + .query(Run) \ + .order_by(Run.number.desc()) \ + .options(subqueryload(Run.conditions)) \ .limit(50) condition_types = g.tdb.get_condition_types() - return render_template("index.html", runs=runs, DefaultConditions=rcdb.DefaultConditions, condition_types=condition_types) + return render_template("index.html", runs=runs, DefaultConditions=rcdb.DefaultConditions, + condition_types=condition_types) @app.template_filter('remove_dot_conf') @@ -82,8 +86,6 @@ def url_for_other_page(page): app.jinja_env.globals['url_for_other_page'] = url_for_other_page app.jinja_env.globals['rcdb_default_alias'] = rcdb.alias.default_aliases - - app.register_blueprint(runs_module) app.register_blueprint(logs_module) app.register_blueprint(files_module) diff --git a/rcdb_web/select_values/veiws.py b/rcdb_web/select_values/veiws.py index 4aa812f..dcd53b2 100644 --- a/rcdb_web/select_values/veiws.py +++ b/rcdb_web/select_values/veiws.py @@ -6,7 +6,7 @@ # from werkzeug import check_password_hash, generate_password_hash import rcdb from collections import defaultdict -from rcdb.model import Run, Condition, ConditionType +from rcdb.model import Run, Condition, ConditionType, RunPeriod from sqlalchemy.orm import subqueryload from rcdb.provider import RCDBProvider @@ -18,15 +18,17 @@ @mod.route('/') def index(): all_conditions = g.tdb.session.query(ConditionType).order_by(ConditionType.name.asc()).all() + run_periods = g.tdb.session.query(RunPeriod).all() run_from_str = request.args.get('runFrom', '') run_to_str = request.args.get('runTo', '') search_query = request.args.get('q', '') req_conditions_str = request.args.get('cnd', '') - print("search" + search_query) + print(run_periods) return render_template("select_values/index.html", all_conditions=all_conditions, + run_periods=run_periods, run_from_str=run_from_str, run_to_str=run_to_str, search_query=search_query, @@ -36,6 +38,7 @@ def index(): @mod.route('/search', methods=['GET']) def search(): all_conditions = g.tdb.session.query(ConditionType).order_by(ConditionType.name.asc()).all() + run_periods = g.tdb.session.query(RunPeriod).all() run_range = request.args.get('rr', '') search_query = request.args.get('q', '') req_conditions_str = request.args.get('cnd', '') @@ -52,15 +55,15 @@ def search(): try: table = g.tdb.select_values(val_names=req_conditions_values, search_str=search_query, run_min=run_from, run_max=run_to, sort_desc=True) - print(req_conditions_values, run_from, run_to) except Exception as err: flash("Error in performing request: {}".format(err), 'danger') return redirect(url_for('select_values.index')) - print(search_query) + return render_template("select_values/index.html", all_conditions=all_conditions, + run_periods=run_periods, run_range=run_range, run_from=run_from, run_to=run_to, diff --git a/rcdb_web/templates/run_search_box.html b/rcdb_web/templates/run_search_box.html index 2528d26..994eb47 100644 --- a/rcdb_web/templates/run_search_box.html +++ b/rcdb_web/templates/run_search_box.html @@ -1,4 +1,4 @@ -{% macro run_search_box(condition_types=[], run_from=-1, run_to=-1, search_query="", form_url=url_for("runs.search"), req_conditions_str="", show_req_conditions=False) %} +{% macro run_search_box(condition_types=[], run_periods=[], run_from=-1, run_to=-1, search_query="", form_url=url_for("runs.search"), req_conditions_str="", show_req_conditions=False) %} {% set run_from_str = "" if run_from == -1 else run_from %} {% set run_to_str = "" if run_to == -1 else run_to %} @@ -18,15 +18,9 @@ @@ -40,21 +34,25 @@ +{# Primex, GluexI, Gluex-II, CLASS-12, CSR,#} +{#
  • [70000+] 2019-01 2020
  • #} +{#
  • [60000+] 2019-01 2019-04 – DIRC-com/PrimEx
  • #} +{#
  • [50000+] 2018-08 2018-11 – 78B GlueX-I/PrimEx-Com
  • #} +{#
  • [40000+] 2018-01 2018-05 – 145B
  • #} +{#
  • [30000+] 2017-01 2017-04 – 50B 12 GeV e-
  • #} +{#
  • [20000+] 2016-10 2016-12 – 7B 12 GeV e-
  • #} +{#
  • [10000+] 2016-02
  • #} +{#
  • [3939, 10000) 2015-12
  • #} +{#
  • [3607, 3939]2015-06
  • #}
    @@ -93,7 +91,6 @@
    -