Private
Public Access
1
0

Merge branch 'release/bgchecks'

This commit is contained in:
Sander Roosendaal
2016-12-08 17:06:15 +01:00
5 changed files with 71 additions and 10 deletions
+35
View File
@@ -13,6 +13,7 @@ import itertools
from django.conf import settings from django.conf import settings
from sqlalchemy import create_engine from sqlalchemy import create_engine
import sqlalchemy as sa import sqlalchemy as sa
import sys
user = settings.DATABASES['default']['USER'] user = settings.DATABASES['default']['USER']
password = settings.DATABASES['default']['PASSWORD'] password = settings.DATABASES['default']['PASSWORD']
@@ -79,6 +80,40 @@ def timedeltaconv(x):
return dt return dt
def compare_data(id):
row = Workout.objects.get(id=id)
f1 = row.csvfilename
rowdata = rdata(f1)
try:
l1 = len(rowdata.df)
except AttributeError:
l1 = 0
engine = create_engine(database_url, echo=False)
query = sa.text('SELECT COUNT(*) FROM strokedata WHERE workoutid={id};'.format(
id=id,
))
with engine.connect() as conn, conn.begin():
try:
res = conn.execute(query)
l2 = res.fetchall()[0][0]
except:
print "Database Locked"
conn.close()
engine.dispose()
return l1==l2
def repair_data(verbose=False):
ws = Workout.objects.all()
for w in ws:
if verbose:
sys.stdout.write(".")
if not compare_data(w.id):
if verbose:
print w.id
rowdata = rdata(w.csvfilename)
update_strokedata(w.id,rowdata.df)
def rdata(file,rower=rrower()): def rdata(file,rower=rrower()):
try: try:
res = rrdata(file,rower=rower) res = rrdata(file,rower=rower)
+1 -3
View File
@@ -996,7 +996,7 @@ def interactive_flex_chart2(id=0,promember=0,
plot = Figure(x_axis_type=x_axis_type,y_axis_type=y_axis_type, plot = Figure(x_axis_type=x_axis_type,y_axis_type=y_axis_type,
tools=TOOLS, tools=TOOLS,
toolbar_sticky=False, toolbar_sticky=False
) )
x1means = Span(location=x1mean,dimension='height',line_color='green', x1means = Span(location=x1mean,dimension='height',line_color='green',
@@ -1235,8 +1235,6 @@ def interactive_flex_chart2(id=0,promember=0,
js_resources = INLINE.render_js() js_resources = INLINE.render_js()
css_resources = INLINE.render_css() css_resources = INLINE.render_css()
return [script,div,js_resources,css_resources] return [script,div,js_resources,css_resources]
@@ -0,0 +1,25 @@
#!/srv/venv/bin/python
import sys
import os
# If you find a solution that does not need the two paths, please comment!
sys.path.append('$path_to_root_of_project$')
sys.path.append('$path_to_root_of_project$/$project_name$')
os.environ['DJANGO_SETTINGS_MODULE'] = '$project_name$.settings'
from django.core.management.base import BaseCommand, CommandError
from django.conf import settings
#from rowers.mailprocessing import processattachments
import time
from django.conf import settings
from rowers.models import Workout, User, Rower, WorkoutForm,RowerForm,GraphImage,AdvancedWorkoutForm
from django.core.files.base import ContentFile
from rowsandall_app.settings import BASE_DIR
from rowers.dataprep import *
class Command(BaseCommand):
def handle(self, *args, **options):
repair_data(verbose=True)
self.stdout.write(self.style.SUCCESS('Successfully cleaned data'))
+5 -5
View File
@@ -2683,14 +2683,14 @@ def workout_flexchart3_view(request,*args,**kwargs):
workstrokesonly = False workstrokesonly = False
# create interactive plot # create interactive plot
res = interactive_flex_chart2(id,xparam=xparam,yparam1=yparam1, script,div,js_resources,css_resources = interactive_flex_chart2(id,xparam=xparam,yparam1=yparam1,
yparam2=yparam2, yparam2=yparam2,
promember=promember,plottype=plottype, promember=promember,plottype=plottype,
workstrokesonly=workstrokesonly) workstrokesonly=workstrokesonly)
script = res[0] # script = res[0]
div = res[1] # div = res[1]
js_resources = res[2] # js_resources = res[2]
css_resources = res[3] # css_resources = res[3]
if row.workouttype == 'water': if row.workouttype == 'water':
return render(request, return render(request,
+3
View File
@@ -60,6 +60,9 @@ AUTHENTICATION_BACKENDS = (
) )
MIDDLEWARE_CLASSES = [ MIDDLEWARE_CLASSES = [
'django.middleware.gzip.GZipMiddleware',
'htmlmin.middleware.HtmlMinifyMiddleware',
'htmlmin.middleware.MarkRequestMiddleware',
'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.security.SecurityMiddleware', 'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',