mirror of
https://github.com/sartography/uva-covid19-testing-communicator.git
synced 2025-02-23 12:28:26 +00:00
Added Alexs Changes
This commit is contained in:
parent
efb4f9c29b
commit
a9545ec834
@ -157,8 +157,16 @@ def apply_filters(query, session):
|
||||
query = query.filter(
|
||||
Sample.station.in_(filters["station"].split()))
|
||||
if "compute_id" in filters:
|
||||
filtered_samples = filtered_samples.filter(
|
||||
Sample.compute_id.in_(filters["compute_id"].split()))
|
||||
query = query.filter(
|
||||
Sample.computing_id.in_(filters["compute_id"].split()))
|
||||
if "include_tests" in filters:
|
||||
if not filters["include_tests"]:
|
||||
query = query.filter(
|
||||
Sample.student_id != 0)
|
||||
else:
|
||||
query = query.filter(
|
||||
Sample.student_id != 0)
|
||||
|
||||
except Exception as e:
|
||||
logging.error(
|
||||
"Encountered an error building filters, so clearing. " + str(e))
|
||||
@ -174,7 +182,7 @@ def dow_count(start, end):
|
||||
counts = [0 for _ in range(7)]
|
||||
curr = start
|
||||
while curr <= end:
|
||||
counts[curr.weekday()] += 1
|
||||
counts[(1 + curr.weekday()) % 7] += 1
|
||||
curr += timedelta(1)
|
||||
return counts
|
||||
|
||||
@ -225,6 +233,8 @@ def index():
|
||||
session["index_filter"]["location"] = form.location.data
|
||||
if form.compute_id.data:
|
||||
session["index_filter"]["compute_id"] = form.compute_id.data
|
||||
if form.include_tests.data:
|
||||
session["index_filter"]["include_tests"] = form.include_tests.data
|
||||
samples = db.session.query(Sample).order_by(Sample.date.desc())
|
||||
# Store previous form submission settings in the session, so they are preseved through pagination.
|
||||
filtered_samples, filters = apply_filters(samples, session)
|
||||
@ -311,12 +321,12 @@ def index():
|
||||
offset = 6
|
||||
counts = result[2:]
|
||||
counts = counts[offset:] + counts[:offset]
|
||||
hourly_charts_data[location][station] = [round(i/days_in_search, 2) for i in counts]
|
||||
hourly_charts_data[location][station] = [round(i/days_in_search + .4) for i in counts]
|
||||
|
||||
# Count by weekday
|
||||
cases = [ ]
|
||||
for i in range(7):
|
||||
cases.append(func.count(case([(func.extract('isodow', Sample.date) == i + 1, 1)])))
|
||||
cases.append(func.count(case([(func.extract('dow', Sample.date) == i, 1)])))
|
||||
|
||||
q = db.session.query(Sample.location, Sample.station,
|
||||
*cases\
|
||||
@ -332,7 +342,7 @@ def index():
|
||||
weekday_charts_data[location][station] = []
|
||||
for dow, total in zip(range(7),result[2:]):
|
||||
if dow_counts[dow] > 0:
|
||||
weekday_charts_data[location][station].append(round(total/dow_counts[dow],2))
|
||||
weekday_charts_data[location][station].append(round(total/dow_counts[dow] + .4))
|
||||
else:
|
||||
weekday_charts_data[location][station].append(total)
|
||||
# Count by range
|
||||
@ -356,9 +366,9 @@ def index():
|
||||
# Aggregate results
|
||||
for location in location_stats_data:
|
||||
if location in daily_charts_data:
|
||||
overall_chart_data["daily"][location] = np.sum([daily_charts_data[location][station] for station in daily_charts_data[location]],axis=0,dtype=np.float16).tolist()
|
||||
overall_chart_data["hourly"][location] = np.sum([hourly_charts_data[location][station] for station in hourly_charts_data[location]],axis=0,dtype=np.float16).tolist()
|
||||
overall_chart_data["weekday"][location] = np.sum([weekday_charts_data[location][station] for station in weekday_charts_data[location]],axis=0,dtype=np.float16).tolist()
|
||||
overall_chart_data["daily"][location] = np.sum([daily_charts_data[location][station] for station in daily_charts_data[location]],axis=0,dtype=np.int).tolist()
|
||||
overall_chart_data["hourly"][location] = np.sum([hourly_charts_data[location][station] for station in hourly_charts_data[location]],axis=0,dtype=np.int).tolist()
|
||||
overall_chart_data["weekday"][location] = np.sum([weekday_charts_data[location][station] for station in weekday_charts_data[location]],axis=0,dtype=np.int).tolist()
|
||||
|
||||
overall_totals_data["one_week_ago"] += location_stats_data[location]["one_week_ago"]
|
||||
overall_totals_data["two_week_ago"] += location_stats_data[location]["two_week_ago"]
|
||||
|
@ -3,7 +3,7 @@ import re
|
||||
from flask_table import Table, Col, LinkCol, BoolCol, DatetimeCol, NestedTableCol
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import SelectMultipleField, StringField, BooleanField, SelectField, validators, HiddenField, TextAreaField, \
|
||||
ValidationError
|
||||
ValidationError, BooleanField
|
||||
|
||||
from wtforms.fields.html5 import DateField
|
||||
from wtforms.widgets import TextArea
|
||||
@ -27,3 +27,4 @@ class SearchForm(FlaskForm):
|
||||
studentId = TextAreaField('Student Id')
|
||||
location = TextAreaField('Location')
|
||||
compute_id = TextAreaField('Compute ID')
|
||||
include_tests = BooleanField("Include Test Strips", default=False)
|
||||
|
@ -2,51 +2,11 @@
|
||||
<!-- Sidenav -->
|
||||
<nav class="navbar navbar-vertical fixed-left navbar-expand-md navbar-dark bg-dark" id="sidenav-main">
|
||||
<div class="container-fluid">
|
||||
<!-- Toggler -->
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#sidenav-collapse-main" aria-controls="sidenav-main" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
||||
<!-- Brand -->
|
||||
<a class="navbar-brand pt-0" href="/">
|
||||
<img src="/static/assets/img/brand/uva_logo.png" class="navbar-brand-img" alt="Flask Argon Dashboard">
|
||||
</a>
|
||||
<!-- User -->
|
||||
<ul class="nav align-items-center d-md-none">
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link nav-link-icon" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<em class="ni ni-bell-55"></em>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-arrow dropdown-menu-right" aria-labelledby="navbar-default_dropdown_1">
|
||||
<a class="dropdown-item" href="#">Action</a>
|
||||
<a class="dropdown-item" href="#">Another action</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="#">Something else here</a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<div class="media align-items-center">
|
||||
<span class="avatar avatar-sm rounded-circle">
|
||||
<img alt="Image placeholder">
|
||||
</span>
|
||||
</div>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-arrow dropdown-menu-right">
|
||||
<div class=" dropdown-header noti-title">
|
||||
<h6 class="text-overflow m-0">Welcome!</h6>
|
||||
</div>
|
||||
<a href="/profile.html" class="dropdown-item">
|
||||
<i class="ni ni-single-02"></i>
|
||||
<span>My profile</span>
|
||||
</a>
|
||||
<a href="/profile.html" class="dropdown-item">
|
||||
<i class="ni ni-settings-gear-65"></i>
|
||||
<span>Settings</span>
|
||||
</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- Collapse -->
|
||||
<div class="collapse navbar-collapse" id="sidenav-collapse-main">
|
||||
<!-- Collapse header -->
|
||||
@ -57,12 +17,6 @@
|
||||
<img src="/static/assets/img/brand/uva_logo.png">
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-6 collapse-close">
|
||||
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#sidenav-collapse-main" aria-controls="sidenav-main" aria-expanded="false" aria-label="Toggle sidenav">
|
||||
<span></span>
|
||||
<span></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Navigation -->
|
||||
|
@ -44,16 +44,14 @@
|
||||
{{ form.csrf_token() }}
|
||||
<div class="card-header border-0">
|
||||
<div class="row align-items-center">
|
||||
<div class="col">
|
||||
<h3 class="mb-0">Search</h3>
|
||||
</div>
|
||||
|
||||
<div class="col text-right mr-2">
|
||||
<button class="btn btn-sm btn-primary"
|
||||
onclick="$('input[name=\'dateRange\']').val(getToday()+ ' - ' +getToday());submitform();">Search Today</button>
|
||||
</div>
|
||||
<div class="col text-right mr-2">
|
||||
<button class="btn btn-sm btn-primary"
|
||||
onclick="$('input[name=\'dateRange\']').val('01/01/2019 - ' + getToday());submitform();">Search All</button>
|
||||
onclick="$('input[name=\'dateRange\']').val('10/05/2020 - ' + getToday());submitform();">Search All</button>
|
||||
</div>
|
||||
<div class="col text-right mr-2">
|
||||
<button type="submit" class="btn btn-sm btn-primary">Run Search</button>
|
||||
@ -195,7 +193,7 @@
|
||||
datasets.map(dataset => {
|
||||
sum += dataset.data[ctx.dataIndex];
|
||||
});
|
||||
return sum.toFixed(2);
|
||||
return sum;
|
||||
}
|
||||
else {
|
||||
return '';
|
||||
@ -215,6 +213,7 @@
|
||||
return today
|
||||
}
|
||||
/////////////////////////////
|
||||
|
||||
var overall_charts = {};
|
||||
overall_charts.daily = dict2datasets(JSON.parse('{{overall_chart_data.daily | tojson }}'));
|
||||
overall_charts.hourly = dict2datasets(JSON.parse('{{overall_chart_data.hourly | tojson }}'));
|
||||
@ -247,7 +246,7 @@
|
||||
var per_weekday = new Chart(document.getElementById('week-chart').getContext('2d'), {
|
||||
type: 'horizontalBar',
|
||||
data: {
|
||||
labels: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday","Sunday"],
|
||||
labels: ["Sunday","Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
|
||||
datasets: overall_charts.weekday
|
||||
},
|
||||
options: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user