Distance traveled in worker specs

This commit is contained in:
Ruben van de Ven 2020-01-22 16:04:13 +01:00
parent 54bb2787bc
commit c97ac4b05d
8 changed files with 84 additions and 24 deletions

View file

@ -18,6 +18,7 @@ tqdm = "*"
serial = "*"
pyserial = "*"
country-converter = "*"
svgpathtools = "*"
[dev-packages]

24
Pipfile.lock generated
View file

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "0bb22632889d5e728609ae67e478ff7bdeb7e56b7bb0b2be0f3b5db36ca129c5"
"sha256": "d1d2c21498d8c771cdd3233e304f260e7fe6020dfb6a1529286e85e8ead0f34f"
},
"pipfile-spec": 6,
"requires": {
@ -244,6 +244,13 @@
"index": "pypi",
"version": "==7.0.0"
},
"pyparsing": {
"hashes": [
"sha256:4c830582a84fb022400b85429791bc551f1f4871c33f23e44f353119e92f969f",
"sha256:c342dccb5250c08d45fd6f8b4a559613ca603b57498511740e65cd11a2e7dcec"
],
"version": "==2.4.6"
},
"pyserial": {
"hashes": [
"sha256:6e2d401fdee0eab996cf734e67773a0143b932772ca8b42451440cfed942c627",
@ -327,6 +334,21 @@
"index": "pypi",
"version": "==1.3.12"
},
"svgpathtools": {
"hashes": [
"sha256:7f7bdafe2c03b312178460104705e1d554d8cf36c898bec41bdce9fed3504746",
"sha256:e4b3784ae41b725fbce6a33a8981210967b16d0b557cb5d98c0ed0c81f0f89b9"
],
"index": "pypi",
"version": "==1.3.3"
},
"svgwrite": {
"hashes": [
"sha256:11e47749b159ed7004721e11d380b4642a26154b8cb2f7b0102fea9c71a3dfa1",
"sha256:50fec23dc3fd49103808f0d672124f8c573ec5899da5686df734f856b8d3b737"
],
"version": "==1.3.1"
},
"tornado": {
"hashes": [
"sha256:349884248c36801afa19e342a77cc4458caca694b0eda633f5878e458a44cb2c",

View file

@ -10,6 +10,7 @@ from contextlib import contextmanager
import uuid
import os
import country_converter
from svgpathtools import svg2paths
mainLogger = logging.getLogger("sorteerhoed")
logger = mainLogger.getChild("store")
@ -100,6 +101,14 @@ class HIT(Base):
'turk_country': 'the Netherlands',
'turk_country_code': 'NL'
})
if not values['svg_image'] or not os.path.exists(self.getSvgImagePath()):
values['path_length'] = None
else:
try:
paths, _ = svg2paths(self.getSvgImagePath())
values['path_length'] = round(paths[0].length())
except:
values['path_length'] = None
return values
def delete(self):

Binary file not shown.

Before

Width:  |  Height:  |  Size: 369 KiB

After

Width:  |  Height:  |  Size: 131 B

View file

@ -30,8 +30,17 @@
<p class="descriptor">task id</p>
<p>{{hit.hit_id}}</p>
<p class="descriptor">task description</p>
<p>Use the mouse to draw a copy of the image above</p>
<p>Use the mouse to trace the image above</p>
<div class='columns'>
<div class='column'>
<p class="descriptor">fee</p>
<p>$ {{formatPrice(hit.fee)}}</p>
</div><div class='column'>
<p class="descriptor">amazon markup</p>
<p>$ {{formatPrice(hit.fee*.2)}}</p>
</div>
</div>
<!-- TASK FEE en FEE voor amazon (task fee * .2) -->
</div>
@ -58,9 +67,9 @@
<p class="descriptor">visiting from</p>
<!-- {{hit.assignment.turk_browser}} / / {{hit.assignment.turk_os}} ({{hit.assignment.turk_ip}}) -->
<p>{{hit.assignment.turk_country}}</p>
<p class="descriptor">system</p>
<p>{{hit.assignment.turk_browser}} - {{hit.assignment.turk_os}}</p>
</div>
@ -71,9 +80,16 @@
<div class='state' v-if="hit.assignment.submit_page_at">
<h2>worker input</h2>
<div class="svgcrop" style="height: 140px; overflow: hidden">
<img :src="hit.svg_image" style="margin-top: -60px">
<div class="svgcrop" style="height: 110px; overflow: hidden">
<object :data="hit.svg_image" style="margin-top: -60px" type="image/svg+xml"></object>
</div>
<p class="descriptor">duration</p>
<p>{{duration(hit.assignment.submit_page_at, hit.assignment.created_at)}}</p>
<template v-if="hit.path_length">
<p class="descriptor">drawing distance</p>
<p>{{hit.path_length}} pixels</p>
</template>
<!-- DURATION en afstand lijntekening -->
</div>

View file

@ -9,6 +9,24 @@ var app = new Vue({
}
},
methods: {
formatPrice(value) {
let val = (value/1).toFixed(2).replace('.', ',')
return val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".")
},
duration(date1, date2){
let s1 = Date.parse(date1) / 1000;
let s2 = Date.parse(date2) / 1000;
let interval = s1 - s2;
let minutes = Math.floor(interval / 60);
let seconds = interval % 60;
let o = `${seconds}`;
if( minutes > 0) {
o = `${minutes}` + o;
}
return o;
}
}
// watch: {
// hits: {
// deep: true

View file

@ -147,7 +147,7 @@ html, body{
}
to {
max-height: 200px;
max-height: 600px;
}
}
@ -193,3 +193,13 @@ html, body{
top: 5px;
}
*/
.columns{
display: flex;
flex-direction: row;
}
.columns .column{
flex-grow: 1;
}

View file

@ -1,16 +0,0 @@
server starten volgens readme
http://localhost:8888/draw?id=3&assignmentId=test
# id= moet overeenkomen met hit id in console
http://localhost:8888/worker_specs/index.html
TODO
worker_specs
misschien svg croppen ivm veel lege ruimte
misschien tussen digital drawing en analog drawing nog een stap? digital > glas > analog