diff --git a/Pipfile b/Pipfile index 0677825..9dcd4e6 100644 --- a/Pipfile +++ b/Pipfile @@ -18,6 +18,7 @@ tqdm = "*" serial = "*" pyserial = "*" country-converter = "*" +svgpathtools = "*" [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock index de0fbb1..6410053 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -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", diff --git a/sorteerhoed/HITStore.py b/sorteerhoed/HITStore.py index 6d53470..be1ba52 100644 --- a/sorteerhoed/HITStore.py +++ b/sorteerhoed/HITStore.py @@ -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): diff --git a/www/worker_specs/fake_scan.jpg b/www/worker_specs/fake_scan.jpg index 3d60250..25ace8d 100644 Binary files a/www/worker_specs/fake_scan.jpg and b/www/worker_specs/fake_scan.jpg differ diff --git a/www/worker_specs/index.html b/www/worker_specs/index.html index 8e73951..7985d6c 100644 --- a/www/worker_specs/index.html +++ b/www/worker_specs/index.html @@ -30,8 +30,17 @@

task id

{{hit.hit_id}}

task description

-

Use the mouse to draw a copy of the image above

- +

Use the mouse to trace the image above

+
+
+

fee

+

$ {{formatPrice(hit.fee)}}

+
+

amazon markup

+

$ {{formatPrice(hit.fee*.2)}}

+
+
+ @@ -58,9 +67,9 @@

visiting from

-

{{hit.assignment.turk_country}}

- +

system

+

{{hit.assignment.turk_browser}} - {{hit.assignment.turk_os}}

@@ -71,9 +80,16 @@

worker input

-
- +
+
+

duration

+

{{duration(hit.assignment.submit_page_at, hit.assignment.created_at)}}

+ +
diff --git a/www/worker_specs/script.js b/www/worker_specs/script.js index 1af1efb..53479ce 100644 --- a/www/worker_specs/script.js +++ b/www/worker_specs/script.js @@ -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 diff --git a/www/worker_specs/style.css b/www/worker_specs/style.css index b77c6fb..2fa83d6 100644 --- a/www/worker_specs/style.css +++ b/www/worker_specs/style.css @@ -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; +} diff --git a/www/worker_specs/todo b/www/worker_specs/todo deleted file mode 100644 index 1660809..0000000 --- a/www/worker_specs/todo +++ /dev/null @@ -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 \ No newline at end of file