Private
Public Access
1
0

Merge branch 'release/v10.66'

This commit is contained in:
Sander Roosendaal
2019-12-07 13:54:14 +01:00
3 changed files with 90 additions and 23 deletions
+8 -2
View File
@@ -31,6 +31,7 @@ import dask.dataframe as dd
from dask.delayed import delayed from dask.delayed import delayed
import pyarrow.parquet as pq import pyarrow.parquet as pq
import pyarrow as pa import pyarrow as pa
from pyarrow.lib import ArrowInvalid
from django.utils import timezone from django.utils import timezone
from django.utils.timezone import get_current_timezone from django.utils.timezone import get_current_timezone
@@ -198,7 +199,12 @@ def get_video_data(w,groups=['basic'],mode='water'):
if dict(rowingmetrics)[c]['numtype'] == 'integer': if dict(rowingmetrics)[c]['numtype'] == 'integer':
data[c] = df2[c].astype(int).tolist() data[c] = df2[c].astype(int).tolist()
else: else:
data[c] = df2[c].values.tolist() sigfigs = dict(rowingmetrics)[c]['sigfigs']
if (c != 'pace'):
da = ((10**sigfigs)*df2[c]).astype(int)/(10**sigfigs)
else:
da = df2[c]
data[c] = da.values.tolist()
metrics[c] = { metrics[c] = {
'name': dict(rowingmetrics)[c]['verbose_name'], 'name': dict(rowingmetrics)[c]['verbose_name'],
'metric': c, 'metric': c,
@@ -1867,7 +1873,7 @@ def getsmallrowdata_db(columns, ids=[], doclean=True,workstrokesonly=True,comput
else: else:
try: try:
df = pd.read_parquet(csvfilenames[0],columns=columns) df = pd.read_parquet(csvfilenames[0],columns=columns)
except OSError: except (OSError,ArrowInvalid):
rowdata,row = getrowdata(id=ids[0]) rowdata,row = getrowdata(id=ids[0])
if rowdata and len(rowdata.df): if rowdata and len(rowdata.df):
data = dataprep(rowdata.df,id=ids[0],bands=True,otwpower=True,barchart=True) data = dataprep(rowdata.df,id=ids[0],bands=True,otwpower=True,barchart=True)
+27 -2
View File
@@ -56,7 +56,8 @@ rowingmetrics = (
'ax_max': 1e5, 'ax_max': 1e5,
'mode':'both', 'mode':'both',
'type': 'basic', 'type': 'basic',
'group':'basic'}), 'group':'basic',
'sigfigs': -1}),
('hr',{ ('hr',{
'numtype':'integer', 'numtype':'integer',
@@ -66,7 +67,8 @@ rowingmetrics = (
'ax_max': 200, 'ax_max': 200,
'mode':'both', 'mode':'both',
'type': 'basic', 'type': 'basic',
'group':'athlete'}), 'group':'athlete',
'sigfigs':0,}),
('pace',{ ('pace',{
'numtype':'float', 'numtype':'float',
@@ -76,6 +78,7 @@ rowingmetrics = (
'ax_max': 1.0e3*75, 'ax_max': 1.0e3*75,
'mode':'both', 'mode':'both',
'type': 'basic', 'type': 'basic',
'sigfigs': 1,
'group': 'basic'}), 'group': 'basic'}),
('velo',{ ('velo',{
@@ -86,6 +89,7 @@ rowingmetrics = (
'ax_max': 8, 'ax_max': 8,
'default': 0, 'default': 0,
'mode':'both', 'mode':'both',
'sigfigs': 1,
'type':'pro', 'type':'pro',
'group': 'basic'}), 'group': 'basic'}),
@@ -106,6 +110,7 @@ rowingmetrics = (
'ax_min': 15, 'ax_min': 15,
'ax_max': 45, 'ax_max': 45,
'mode':'both', 'mode':'both',
'sigfigs': 1,
'type': 'basic', 'type': 'basic',
'group':'basic'}), 'group':'basic'}),
@@ -116,6 +121,7 @@ rowingmetrics = (
'ax_min': 0, 'ax_min': 0,
'ax_max': 1000, 'ax_max': 1000,
'mode':'both', 'mode':'both',
'sigfigs': 0,
'type': 'pro', 'type': 'pro',
'group':'forcepower'}), 'group':'forcepower'}),
@@ -126,6 +132,7 @@ rowingmetrics = (
'ax_min': 0, 'ax_min': 0,
'ax_max': 600, 'ax_max': 600,
'mode':'both', 'mode':'both',
'sigfigs': 0,
'type': 'basic', 'type': 'basic',
'group':'forcepower'}), 'group':'forcepower'}),
@@ -136,6 +143,7 @@ rowingmetrics = (
'ax_min': 0, 'ax_min': 0,
'ax_max': 1200, 'ax_max': 1200,
'mode':'both', 'mode':'both',
'sigfigs': 0,
'type': 'pro', 'type': 'pro',
'group':'forcepower'}), 'group':'forcepower'}),
@@ -145,6 +153,7 @@ rowingmetrics = (
'verbose_name': 'Peak Drive Force (N)', 'verbose_name': 'Peak Drive Force (N)',
'ax_min': 0, 'ax_min': 0,
'ax_max': 1500, 'ax_max': 1500,
'sigfigs': 0,
'mode':'both', 'mode':'both',
'type': 'pro', 'type': 'pro',
'group':'forcepower'}), 'group':'forcepower'}),
@@ -156,6 +165,7 @@ rowingmetrics = (
'ax_min': 0, 'ax_min': 0,
'ax_max': 2.5, 'ax_max': 2.5,
'mode':'rower', 'mode':'rower',
'sigfigs': 2,
'type': 'pro', 'type': 'pro',
'group':'stroke'}), 'group':'stroke'}),
@@ -165,6 +175,7 @@ rowingmetrics = (
'verbose_name': 'Average/Peak Force Ratio', 'verbose_name': 'Average/Peak Force Ratio',
'ax_min': 0, 'ax_min': 0,
'ax_max': 1, 'ax_max': 1,
'sigfigs': 2,
'mode':'both', 'mode':'both',
'type': 'pro', 'type': 'pro',
'group': 'forcepower'}), 'group': 'forcepower'}),
@@ -175,6 +186,7 @@ rowingmetrics = (
'verbose_name': 'Interval Distance (m)', 'verbose_name': 'Interval Distance (m)',
'ax_min': 0, 'ax_min': 0,
'ax_max': 1e5, 'ax_max': 1e5,
'sigfigs': 0,
'mode':'both', 'mode':'both',
'type': 'basic', 'type': 'basic',
'group':'basic'}), 'group':'basic'}),
@@ -186,6 +198,7 @@ rowingmetrics = (
'ax_min': 0, 'ax_min': 0,
'ax_max': 1e5, 'ax_max': 1e5,
'mode':'both', 'mode':'both',
'sigfigs': 0,
'type': 'basic', 'type': 'basic',
'group':'basic'}), 'group':'basic'}),
@@ -196,10 +209,12 @@ rowingmetrics = (
'ax_min': 0, 'ax_min': 0,
'ax_max': 4, 'ax_max': 4,
'default': 0, 'default': 0,
'sigfigs': 2,
'mode':'both', 'mode':'both',
'type': 'pro', 'type': 'pro',
'group': 'stroke'}), 'group': 'stroke'}),
('catch',{ ('catch',{
'numtype':'float', 'numtype':'float',
'null':True, 'null':True,
@@ -207,6 +222,7 @@ rowingmetrics = (
'ax_min': -40, 'ax_min': -40,
'ax_max': -75, 'ax_max': -75,
'default': 0, 'default': 0,
'sigfigs': 0,
'mode':'water', 'mode':'water',
'type': 'pro', 'type': 'pro',
'group': 'stroke'}), 'group': 'stroke'}),
@@ -218,6 +234,7 @@ rowingmetrics = (
'ax_min': 0, 'ax_min': 0,
'ax_max': 20, 'ax_max': 20,
'default': 0, 'default': 0,
'sigfigs': 1,
'mode':'water', 'mode':'water',
'type': 'pro', 'type': 'pro',
'group': 'stroke'}), 'group': 'stroke'}),
@@ -229,6 +246,7 @@ rowingmetrics = (
'ax_min': 20, 'ax_min': 20,
'ax_max': 55, 'ax_max': 55,
'default': 0, 'default': 0,
'sigfigs': 0,
'mode':'water', 'mode':'water',
'type': 'pro', 'type': 'pro',
'group': 'stroke'}), 'group': 'stroke'}),
@@ -240,6 +258,7 @@ rowingmetrics = (
'ax_min': 0, 'ax_min': 0,
'ax_max': 30, 'ax_max': 30,
'default': 0, 'default': 0,
'sigfigs': 0,
'mode':'water', 'mode':'water',
'type': 'pro', 'type': 'pro',
'group': 'stroke'}), 'group': 'stroke'}),
@@ -251,6 +270,7 @@ rowingmetrics = (
'ax_min': -50, 'ax_min': -50,
'ax_max': 50, 'ax_max': 50,
'default': 0, 'default': 0,
'sigfigs': 0,
'mode':'water', 'mode':'water',
'type': 'pro', 'type': 'pro',
'group':'stroke'}), 'group':'stroke'}),
@@ -263,6 +283,7 @@ rowingmetrics = (
'ax_min': 40, 'ax_min': 40,
'ax_max': 140, 'ax_max': 140,
'default': 0, 'default': 0,
'sigfigs': 0,
'mode':'water', 'mode':'water',
'type': 'pro', 'type': 'pro',
'group':'stroke'}), 'group':'stroke'}),
@@ -275,6 +296,7 @@ rowingmetrics = (
'ax_min': 40, 'ax_min': 40,
'ax_max': 140, 'ax_max': 140,
'default': 0, 'default': 0,
'sigfigs': 0,
'mode':'water', 'mode':'water',
'type': 'pro', 'type': 'pro',
'group':'stroke'}), 'group':'stroke'}),
@@ -286,6 +308,7 @@ rowingmetrics = (
'ax_min': 20, 'ax_min': 20,
'ax_max': 55, 'ax_max': 55,
'default': 1.0, 'default': 1.0,
'sigfigs': 0,
'mode':'erg', 'mode':'erg',
'type': 'pro', 'type': 'pro',
'group':'stroke'}), 'group':'stroke'}),
@@ -297,6 +320,7 @@ rowingmetrics = (
'ax_min': 0, 'ax_min': 0,
'ax_max': 110, 'ax_max': 110,
'default': 0, 'default': 0,
'sigfigs': 0,
'mode':'water', 'mode':'water',
'type': 'pro', 'type': 'pro',
'group':'forcepower'}), 'group':'forcepower'}),
@@ -308,6 +332,7 @@ rowingmetrics = (
'ax_min': 0, 'ax_min': 0,
'ax_max': 15, 'ax_max': 15,
'default': 0, 'default': 0,
'sigfigs': 1,
'mode':'both', 'mode':'both',
'type': 'basic', 'type': 'basic',
'group':'basic'}), 'group':'basic'}),
+55 -19
View File
@@ -121,6 +121,7 @@
var player; var player;
var playing = false; var playing = false;
var dataplaying = false; var dataplaying = false;
var videotime = 0; var videotime = 0;
var data = JSON.parse('{{ data|safe }}'); var data = JSON.parse('{{ data|safe }}');
{% for id, metric in metrics.items %} {% for id, metric in metrics.items %}
@@ -229,6 +230,7 @@
} else { } else {
if (!dataplaying) { if (!dataplaying) {
output.value = Math.round(datatime)-Math.round(videotime); output.value = Math.round(datatime)-Math.round(videotime);
document.getElementById("time").innerHTML = Math.round(videotime);
} }
} }
@@ -241,10 +243,12 @@
// call this function when player state changes // call this function when player state changes
function onPlayerStateChange(event) { function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING) { if (event.data == YT.PlayerState.PLAYING && lock.checked) {
var dataplay = document.getElementById("dataplay").childNodes[0];
} else { dataplay.value = String.fromCharCode(10074,10074);
} else if (lock.checked) {
var dataplay = document.getElementById("dataplay").childNodes[0];
dataplay.value = String.fromCharCode(9658);
} }
} }
</script> </script>
@@ -314,15 +318,43 @@
</form> </form>
<script> <script>
$(document).ready( function() { $(document).ready( function() {
// cookie reader
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
// lock // lock
var lock = document.getElementById("lock"); var lock = document.getElementById("lock");
// lock.onchange nog doen
var output = document.getElementById("id_delay"); var output = document.getElementById("id_delay");
var cookie = readCookie("lock");
var delay = output.value;
if (cookie=="true") {
lock.checked = true;
output.disabled = true;
}
// lock.onchange nog doen
{% if locked %} {% if locked %}
lock.checked = true; lock.checked = true;
output.disabled = true; output.disabled = true;
{% endif %} {% endif %}
var delay = output.value;
// slider // slider
var slider = document.getElementById("myRange"); var slider = document.getElementById("myRange");
@@ -407,20 +439,18 @@
slider.value = this.value+Math.round(player.getCurrentTime()); slider.value = this.value+Math.round(player.getCurrentTime());
} }
// lock delay form field if checkbox checked
lock.oninput = function() {
if (this.checked) {
output.disabled = true;
} else {
output.disabled = false;
}
}
// Update the current slider value (each time the slider is changed) // Update the current slider value (each time the slider is changed)
slider.onchange = function() { slider.onchange = function() {
clearInterval(timeupdater) clearInterval(timeupdater)
if (lock.checked) { if (lock.checked) {
if (this.value-output.value > 0) { if (this.value-output.value > 0) {
player.seekTo(this.value-output.value); player.seekTo(this.value-output.value);
if (playing) {
player.playVideo();
} else {
player.pauseVideo();
}
} else { } else {
if (playing) { if (playing) {
player.seekTo(0); player.seekTo(0);
@@ -482,8 +512,10 @@
lock.oninput = function() { lock.oninput = function() {
if (this.checked) { if (this.checked) {
output.disabled = true; output.disabled = true;
createCookie("lock","true",0);
} else { } else {
output.disabled = false; output.disabled = false;
createCookie("lock","false",0);
} }
} }
// Slider start stop // Slider start stop
@@ -528,7 +560,11 @@ function clock() {
if (lock.checked) { if (lock.checked) {
player.seekTo(c+parseInt(output.value)); player.seekTo(c+parseInt(output.value));
} else {
delay = Math.round(slider.value)-Math.round(player.getCurrentTime());
output.value = Math.round(slider.value)-Math.round(player.getCurrentTime());
} }
if (c == latitude.length) { if (c == latitude.length) {
clearInterval(timer); clearInterval(timer);
c = 0; c = 0;
@@ -539,7 +575,7 @@ function clock() {
// onderstaande alleen als lock.checked // onderstaande alleen als lock.checked
var dataplay = document.createElement("input"); var dataplay = document.createElement("input");
dataplay.type = "button"; dataplay.type = "button";
dataplay.value = "Play"; dataplay.value = String.fromCharCode(9658);
document.getElementById("dataplay").appendChild(dataplay); document.getElementById("dataplay").appendChild(dataplay);
// var datastop = document.createElement("input"); // var datastop = document.createElement("input");
@@ -552,24 +588,24 @@ dataplay.onclick = function() {
dataplaying = false; dataplaying = false;
if (playing == false) { if (playing == false) {
player.playVideo(); player.playVideo();
dataplay.value = "Pause"; dataplay.value = String.fromCharCode(10074,10074);
playing = true; playing = true;
} else { } else {
player.pauseVideo(); player.pauseVideo();
dataplay.value = "Play"; dataplay.value = String.fromCharCode(9658);
playing = false; playing = false;
} }
} else { } else {
if (!dataplaying) { if (!dataplaying) {
clock(); clock();
dataplay.value = "Pause"; dataplay.value = String.fromCharCode(10074,10074);
dataplaying = true; dataplaying = true;
if (lock.checked) { if (lock.checked) {
playing = true; playing = true;
} }
} else { } else {
clearInterval(timer); clearInterval(timer);
dataplay.value = "Play"; dataplay.value = String.fromCharCode(9658);
dataplaying = false; dataplaying = false;
} }
} }