Readded Tiles

This commit is contained in:
Nile Walker 2021-01-14 09:20:55 -05:00
parent 38b17bca90
commit b65832b054
2 changed files with 26 additions and 7 deletions

View File

@ -233,8 +233,10 @@ def index():
table = SampleTable(group_columns(filtered_samples[(page - 1) * 10:((page - 1) * 10) + 10]))
return render_template('layouts/default.html',
base_href=BASE_HREF,
content=render_template(
base_href=BASE_HREF,
dates = important_dates,
overall_totals_data = overall_totals_data,
content=render_template(
'pages/index.html',
form = form,
dates = important_dates,
@ -247,7 +249,8 @@ def index():
daily_charts_data = daily_charts_data,
hourly_charts_data = hourly_charts_data,
weekday_charts_data = weekday_charts_data,
overall_totals_data = overall_totals_data,
location_stats_data = location_stats_data,
))

View File

@ -4,16 +4,29 @@ import pytz
from tests.base_test import BaseTest
from communicator import app
from communicator import db, app
from communicator.models import Sample
from communicator.services.graph_service import GraphService
from communicator.services.graph_service import GraphService, daterange
from datetime import date, timedelta
import json
class TestGraphService(BaseTest):
def populate_test_db(self):
days = 50
for day in daterange(date.today() - timedelta(days), date.today()):
_sample = Sample(barcode="000000111-202009091449-4321", location = 50, station = 30, student_id = "000000111",
computing_id = "abc12d")
_sample.date = day
db.session.add(_sample)
db.session.commit()
samples = db.session.query(Sample).all()
self.assertNotEqual(0, len(samples))
def test_get_totals_last_week(self):
graph = GraphService()
self.populate_test_db()
graph.update_search_filters({
"start_date": datetime.date(2020,11,1),
"end_date": datetime.date(2020,11,1),
@ -25,6 +38,7 @@ class TestGraphService(BaseTest):
def test_get_totals_by_hour(self):
graph = GraphService()
self.populate_test_db()
graph.update_search_filters({
"start_date": datetime.date(2020,11,1),
"end_date": datetime.date(2020,11,1),
@ -36,6 +50,7 @@ class TestGraphService(BaseTest):
def test_get_totals_by_day(self):
graph = GraphService()
self.populate_test_db()
graph.update_search_filters({
"start_date": datetime.date(2020,11,1),
"end_date": datetime.date(2020,11,1),
@ -47,13 +62,14 @@ class TestGraphService(BaseTest):
def test_get_totals_by_weekday(self):
graph = GraphService()
self.populate_test_db()
graph.update_search_filters({
"start_date": date.today() - timedelta(100),
"end_date": date.today(),
"location": "50"
})
result = graph.get_totals_by_weekday()
print(result)
self.assertTrue(20 not in result)
self.assertEqual(result[50][0][1],17)
self.assertEqual(result[50][10][1],16)