diff --git a/app.py b/app.py index 0635693ee67bb77b9f1910b00fe6eb98ba229bb0..825b8b731b7ef9709f33f83968d1fd984aaf7a7c 100644 --- a/app.py +++ b/app.py @@ -239,6 +239,90 @@ def url_who_date_reported(date_reported_id, page=1): page_info=page_info) +@app.route('/who/date_reported/<int:date_reported_id>/cases_new/page/<int:page>') +@app.route('/who/date_reported/<int:date_reported_id>/cases_new') +def url_who_date_reported_cases_new(date_reported_id, page=1): + date_reported = WhoDateReported.get_by_id(date_reported_id) + page_info = ApplicationPage( + "Date Reported: " + date_reported.date_reported, + 'WHO', + "data of all reported countries for WHO date reported " + date_reported.date_reported + " " + ) + try: + page_data = WhoGlobalData.get_data_for_day_order_by_cases_new(date_reported, page) + except OperationalError: + flash("No data in the database.") + page_data = None + return render_template( + 'who/who_date_reported_one_cases_new.html', + who_date_reported=date_reported, + page_data=page_data, + page_info=page_info) + + +@app.route('/who/date_reported/<int:date_reported_id>/cases_cumulative/page/<int:page>') +@app.route('/who/date_reported/<int:date_reported_id>/cases_cumulative') +def url_who_date_reported_cases_cumulative(date_reported_id, page=1): + date_reported = WhoDateReported.get_by_id(date_reported_id) + page_info = ApplicationPage( + "Date Reported: " + date_reported.date_reported, + 'WHO', + "data of all reported countries for WHO date reported " + date_reported.date_reported + " " + ) + try: + page_data = WhoGlobalData.get_data_for_day_order_by_cases_cumulative(date_reported, page) + except OperationalError: + flash("No data in the database.") + page_data = None + return render_template( + 'who/who_date_reported_one_cases_cumulative.html', + who_date_reported=date_reported, + page_data=page_data, + page_info=page_info) + + +@app.route('/who/date_reported/<int:date_reported_id>/deaths_new/page/<int:page>') +@app.route('/who/date_reported/<int:date_reported_id>/deaths_new') +def url_who_date_reported_deaths_new(date_reported_id, page=1): + date_reported = WhoDateReported.get_by_id(date_reported_id) + page_info = ApplicationPage( + "Date Reported: " + date_reported.date_reported, + 'WHO', + "data of all reported countries for WHO date reported " + date_reported.date_reported + " " + ) + try: + page_data = WhoGlobalData.get_data_for_day_order_by_deaths_new(date_reported, page) + except OperationalError: + flash("No data in the database.") + page_data = None + return render_template( + 'who/who_date_reported_one_deaths_new.html', + who_date_reported=date_reported, + page_data=page_data, + page_info=page_info) + + +@app.route('/who/date_reported/<int:date_reported_id>/deaths_cumulative/page/<int:page>') +@app.route('/who/date_reported/<int:date_reported_id>/deaths_cumulative') +def url_who_date_reported_deaths_cumulative(date_reported_id, page=1): + date_reported = WhoDateReported.get_by_id(date_reported_id) + page_info = ApplicationPage( + "Date Reported: " + date_reported.date_reported, + 'WHO', + "data of all reported countries for WHO date reported " + date_reported.date_reported + " " + ) + try: + page_data = WhoGlobalData.get_data_for_day_order_by_deaths_cumulative(date_reported, page) + except OperationalError: + flash("No data in the database.") + page_data = None + return render_template( + 'who/who_date_reported_one_deaths_cumulative.html', + who_date_reported=date_reported, + page_data=page_data, + page_info=page_info) + + @app.route('/who/region/all/page/<int:page>') @app.route('/who/region/all') def url_who_region_all(page=1): diff --git a/org/woehlke/covid19/who/who_model.py b/org/woehlke/covid19/who/who_model.py index a210b6d77a754d3e1a1ec348a8f01f41006cc6d8..63cbc0f51bc77bc42dd9adfd07ceffa03e69b712 100644 --- a/org/woehlke/covid19/who/who_model.py +++ b/org/woehlke/covid19/who/who_model.py @@ -212,6 +212,50 @@ class WhoGlobalData(db.Model): cls.cases_cumulative.desc() ).paginate(page, per_page=ITEMS_PER_PAGE) + @classmethod + def get_data_for_day_order_by_cases_new(cls, date_reported, page): + return db.session.query(cls).filter( + cls.date_reported_id == date_reported.id + ).populate_existing().options( + joinedload(cls.country).subqueryload(WhoCountry.region), + joinedload(cls.date_reported) + ).order_by( + cls.cases_new.desc() + ).paginate(page, per_page=ITEMS_PER_PAGE) + + @classmethod + def get_data_for_day_order_by_cases_cumulative(cls, date_reported, page): + return db.session.query(cls).filter( + cls.date_reported_id == date_reported.id + ).populate_existing().options( + joinedload(cls.country).subqueryload(WhoCountry.region), + joinedload(cls.date_reported) + ).order_by( + cls.cases_cumulative.desc() + ).paginate(page, per_page=ITEMS_PER_PAGE) + + @classmethod + def get_data_for_day_order_by_deaths_new(cls, date_reported, page): + return db.session.query(cls).filter( + cls.date_reported_id == date_reported.id + ).populate_existing().options( + joinedload(cls.country).subqueryload(WhoCountry.region), + joinedload(cls.date_reported) + ).order_by( + cls.deaths_new.desc() + ).paginate(page, per_page=ITEMS_PER_PAGE) + + @classmethod + def get_data_for_day_order_by_deaths_cumulative(cls, date_reported, page): + return db.session.query(cls).filter( + cls.date_reported_id == date_reported.id + ).populate_existing().options( + joinedload(cls.country).subqueryload(WhoCountry.region), + joinedload(cls.date_reported) + ).order_by( + cls.deaths_cumulative.desc() + ).paginate(page, per_page=ITEMS_PER_PAGE) + class WhoGlobalDataImportTable(db.Model): __tablename__ = 'who_global_data_import' diff --git a/templates/who/fragment_who_global_data_table_date_reported.html b/templates/who/fragment_who_global_data_table_date_reported.html new file mode 100644 index 0000000000000000000000000000000000000000..5aaa9530ad9851a41cbb2187444f8f2e62af5d25 --- /dev/null +++ b/templates/who/fragment_who_global_data_table_date_reported.html @@ -0,0 +1,66 @@ + <table class="table table-hover table-striped table-dark"> + <thead> + <tr> + <th scope="col">date reported</th> + <th scope="col"> + <a href="/who/date_reported/{{ who_date_reported.id }}/deaths_new"> + deaths new + </a> + </th> + <th scope="col"> + <a href="/who/date_reported/{{ who_date_reported.id }}/cases_new"> + cases new + </a> + </th> + <th scope="col"> + <a href="/who/date_reported/{{ who_date_reported.id }}/deaths_cumulative"> + deaths cumulative + </a> + </th> + <th scope="col"> + <a href="/who/date_reported/{{ who_date_reported.id }}/cases_cumulative"> + cases cumulative + </a> + </th> + <th scope="col">country code</th> + <th scope="col">country</th> + <th scope="col">region</th> + </tr> + </thead> + <tbody> + {% for who_global_data in page_data.items %} + <tr> + <th> + {{ who_global_data.date_reported.date_reported }} + </th> + <td> + {{ who_global_data.deaths_new }} + </td> + <td> + {{ who_global_data.cases_new }} + </td> + <td> + {{ who_global_data.deaths_cumulative }} + </td> + <td> + {{ who_global_data.cases_cumulative }} + </td> + <td> + <a href="/who/country/{{ who_global_data.country.id }}"> + {{ who_global_data.country.country_code }} + </a> + </td> + <td> + <a href="/who/country/{{ who_global_data.country.id }}"> + {{ who_global_data.country.country }} + </a> + </td> + <th> + <a href="/who/region/{{ who_global_data.country.region.id }}"> + {{ who_global_data.country.region.region }} + </a> + </th> + </tr> + {% endfor %} + </tbody> + </table> \ No newline at end of file diff --git a/templates/who/who_date_reported_one.html b/templates/who/who_date_reported_one.html index 9ddad9e1175414c6aae2403fa1da507e28b67a13..a824eeded1300edc6b65682de1412b42e1d5e424 100644 --- a/templates/who/who_date_reported_one.html +++ b/templates/who/who_date_reported_one.html @@ -57,7 +57,7 @@ </ul> {% endif %} - {% include 'who/fragment_who_global_data_table.html' %} + {% include 'who/fragment_who_global_data_table_date_reported.html' %} {% endblock %} diff --git a/templates/who/who_date_reported_one_cases_cumulative.html b/templates/who/who_date_reported_one_cases_cumulative.html new file mode 100644 index 0000000000000000000000000000000000000000..b0f789cb69711f7318d4c2b912276eae816db955 --- /dev/null +++ b/templates/who/who_date_reported_one_cases_cumulative.html @@ -0,0 +1,70 @@ +{% extends 'page_layout.html' %} + +{% include 'fragment_pagination.html' %} + +{% block navigation_breadcrumb %} + <nav aria-label="breadcrumb"> + <ol class="breadcrumb"> + <li class="breadcrumb-item"><a href="/">Home</a></li> + <li class="breadcrumb-item"><a href="/who/region/all">Regions</a></li> + <li class="breadcrumb-item active" aria-current="page">Countries</li> + </ol> + </nav> +{% endblock %} + +{% block navigation_navtabs %} + {% include 'fragment_navtabs_who.html' %} +{% endblock %} + + +{% block main_container %} + + {% if page_data.pages > 1 %} + <!-- previous page --> + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('url_who_date_reported_deaths_cumulative', + date_reported_id=who_date_reported.id, page=page_data.prev_num) }}">Previous</a> + </li> + {% endif %} + <!-- all page numbers --> + {% for page_num in page_data.iter_pages() %} + {% if page_num %} + {% if page_num != page_data.page %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('url_who_date_reported_deaths_cumulative', + date_reported_id=who_date_reported.id, page=page_num) }}">{{ page_num }}</a> + </li> + {% else %} + <li class="page-item active"> + <a class="page-link" href="#">{{ page_num }}</a> + </li> + {% endif %} + {% else %} + <li class="page-item"> + <span class="ellipsis page-link my-page-item-ellipsis-page-link">…</span> + </li> + {% endif %} + {% endfor %} + <!-- next page --> + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('url_who_date_reported_deaths_cumulative', + date_reported_id=who_date_reported.id, page=page_data.next_num) }}">Next</a> + </li> + {% endif %} + </ul> + {% endif %} + + {% include 'who/fragment_who_global_data_table_date_reported.html' %} + +{% endblock %} + +{% block footer_container %} + <div> + {% for error in errors %} + <h4>{{ error }}</h4> + {% endfor %} + </div> +{% endblock %} \ No newline at end of file diff --git a/templates/who/who_date_reported_one_cases_new.html b/templates/who/who_date_reported_one_cases_new.html new file mode 100644 index 0000000000000000000000000000000000000000..7f4529e30f4ae9b611bc7489f93aae5e61cac4b2 --- /dev/null +++ b/templates/who/who_date_reported_one_cases_new.html @@ -0,0 +1,70 @@ +{% extends 'page_layout.html' %} + +{% include 'fragment_pagination.html' %} + +{% block navigation_breadcrumb %} + <nav aria-label="breadcrumb"> + <ol class="breadcrumb"> + <li class="breadcrumb-item"><a href="/">Home</a></li> + <li class="breadcrumb-item"><a href="/who/region/all">Regions</a></li> + <li class="breadcrumb-item active" aria-current="page">Countries</li> + </ol> + </nav> +{% endblock %} + +{% block navigation_navtabs %} + {% include 'fragment_navtabs_who.html' %} +{% endblock %} + + +{% block main_container %} + + {% if page_data.pages > 1 %} + <!-- previous page --> + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('url_who_date_reported_cases_new', + date_reported_id=who_date_reported.id, page=page_data.prev_num) }}">Previous</a> + </li> + {% endif %} + <!-- all page numbers --> + {% for page_num in page_data.iter_pages() %} + {% if page_num %} + {% if page_num != page_data.page %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('url_who_date_reported_cases_new', + date_reported_id=who_date_reported.id, page=page_num) }}">{{ page_num }}</a> + </li> + {% else %} + <li class="page-item active"> + <a class="page-link" href="#">{{ page_num }}</a> + </li> + {% endif %} + {% else %} + <li class="page-item"> + <span class="ellipsis page-link my-page-item-ellipsis-page-link">…</span> + </li> + {% endif %} + {% endfor %} + <!-- next page --> + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('url_who_date_reported_cases_new', + date_reported_id=who_date_reported.id, page=page_data.next_num) }}">Next</a> + </li> + {% endif %} + </ul> + {% endif %} + + {% include 'who/fragment_who_global_data_table_date_reported.html' %} + +{% endblock %} + +{% block footer_container %} + <div> + {% for error in errors %} + <h4>{{ error }}</h4> + {% endfor %} + </div> +{% endblock %} \ No newline at end of file diff --git a/templates/who/who_date_reported_one_deaths_cumulative.html b/templates/who/who_date_reported_one_deaths_cumulative.html new file mode 100644 index 0000000000000000000000000000000000000000..b0f789cb69711f7318d4c2b912276eae816db955 --- /dev/null +++ b/templates/who/who_date_reported_one_deaths_cumulative.html @@ -0,0 +1,70 @@ +{% extends 'page_layout.html' %} + +{% include 'fragment_pagination.html' %} + +{% block navigation_breadcrumb %} + <nav aria-label="breadcrumb"> + <ol class="breadcrumb"> + <li class="breadcrumb-item"><a href="/">Home</a></li> + <li class="breadcrumb-item"><a href="/who/region/all">Regions</a></li> + <li class="breadcrumb-item active" aria-current="page">Countries</li> + </ol> + </nav> +{% endblock %} + +{% block navigation_navtabs %} + {% include 'fragment_navtabs_who.html' %} +{% endblock %} + + +{% block main_container %} + + {% if page_data.pages > 1 %} + <!-- previous page --> + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('url_who_date_reported_deaths_cumulative', + date_reported_id=who_date_reported.id, page=page_data.prev_num) }}">Previous</a> + </li> + {% endif %} + <!-- all page numbers --> + {% for page_num in page_data.iter_pages() %} + {% if page_num %} + {% if page_num != page_data.page %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('url_who_date_reported_deaths_cumulative', + date_reported_id=who_date_reported.id, page=page_num) }}">{{ page_num }}</a> + </li> + {% else %} + <li class="page-item active"> + <a class="page-link" href="#">{{ page_num }}</a> + </li> + {% endif %} + {% else %} + <li class="page-item"> + <span class="ellipsis page-link my-page-item-ellipsis-page-link">…</span> + </li> + {% endif %} + {% endfor %} + <!-- next page --> + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('url_who_date_reported_deaths_cumulative', + date_reported_id=who_date_reported.id, page=page_data.next_num) }}">Next</a> + </li> + {% endif %} + </ul> + {% endif %} + + {% include 'who/fragment_who_global_data_table_date_reported.html' %} + +{% endblock %} + +{% block footer_container %} + <div> + {% for error in errors %} + <h4>{{ error }}</h4> + {% endfor %} + </div> +{% endblock %} \ No newline at end of file diff --git a/templates/who/who_date_reported_one_deaths_new.html b/templates/who/who_date_reported_one_deaths_new.html new file mode 100644 index 0000000000000000000000000000000000000000..e9b05d8e94f8d46aff36a7e4859acbf3bfc5030f --- /dev/null +++ b/templates/who/who_date_reported_one_deaths_new.html @@ -0,0 +1,70 @@ +{% extends 'page_layout.html' %} + +{% include 'fragment_pagination.html' %} + +{% block navigation_breadcrumb %} + <nav aria-label="breadcrumb"> + <ol class="breadcrumb"> + <li class="breadcrumb-item"><a href="/">Home</a></li> + <li class="breadcrumb-item"><a href="/who/region/all">Regions</a></li> + <li class="breadcrumb-item active" aria-current="page">Countries</li> + </ol> + </nav> +{% endblock %} + +{% block navigation_navtabs %} + {% include 'fragment_navtabs_who.html' %} +{% endblock %} + + +{% block main_container %} + + {% if page_data.pages > 1 %} + <!-- previous page --> + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('url_who_date_reported_deaths_new', + date_reported_id=who_date_reported.id, page=page_data.prev_num) }}">Previous</a> + </li> + {% endif %} + <!-- all page numbers --> + {% for page_num in page_data.iter_pages() %} + {% if page_num %} + {% if page_num != page_data.page %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('url_who_date_reported_deaths_new', + date_reported_id=who_date_reported.id, page=page_num) }}">{{ page_num }}</a> + </li> + {% else %} + <li class="page-item active"> + <a class="page-link" href="#">{{ page_num }}</a> + </li> + {% endif %} + {% else %} + <li class="page-item"> + <span class="ellipsis page-link my-page-item-ellipsis-page-link">…</span> + </li> + {% endif %} + {% endfor %} + <!-- next page --> + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" href="{{ url_for('url_who_date_reported_deaths_new', + date_reported_id=who_date_reported.id, page=page_data.next_num) }}">Next</a> + </li> + {% endif %} + </ul> + {% endif %} + + {% include 'who/fragment_who_global_data_table_date_reported.html' %} + +{% endblock %} + +{% block footer_container %} + <div> + {% for error in errors %} + <h4>{{ error }}</h4> + {% endfor %} + </div> +{% endblock %} \ No newline at end of file diff --git a/who_date_reported_one_cases_new.html b/who_date_reported_one_cases_new.html new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391