diff --git a/Main.qml b/Main.qml index 0deb955..9fe9c3d 100644 --- a/Main.qml +++ b/Main.qml @@ -56,6 +56,16 @@ MainView { screenSaverEnabled: !Qt.application.active } + function stopwatch(seconds) { + var totalNumberOfSeconds = seconds; + var hours = parseInt( totalNumberOfSeconds / 3600 ); + var minutes = parseInt( (totalNumberOfSeconds - (hours * 3600)) / 60 ); + var seconds = Math.floor((totalNumberOfSeconds - ((hours * 3600) + (minutes * 60)))); + var hours2 = (hours == 0 ? "" : (hours < 10 ? "0" + hours +":" : hours+":")) + var result = hours2 + (minutes < 10 ? "0" + minutes : minutes) + ":" + (seconds < 10 ? "0" + seconds : seconds); + return result + } + ListModel { id: listModel } @@ -70,6 +80,7 @@ MainView { console.warn("STARTING GPX") listModel.clear() call('geepeeex.onetime_db_fix',[]) + call('geepeeex.onetime_db_fix_again_cus_im_dumb',[]) get_units(result) } addImportPath(Qt.resolvedUrl('py/')) @@ -87,9 +98,10 @@ MainView { // Load the received data into the list model listModel.clear() for (var i=0; i", "framework" : "ubuntu-sdk-15.04" } diff --git a/py/geepeeex.py b/py/geepeeex.py index 3ec470a..32d39d7 100644 --- a/py/geepeeex.py +++ b/py/geepeeex.py @@ -79,7 +79,7 @@ def add_run(gpx, name,act_type,filename,polyline): print(max_speed) #print('%sStopped distance: %sm' % stopped_distance) maxspeed = 'Max speed: {:.2f}km/h'.format(max_speed * 60. ** 2 / 1000. if max_speed else 0) - duration = 'Duration: {:.2f}min'.format(gpx.get_duration() / 60) + duration = '{:.2f}'.format(gpx.get_duration() / 60) print("-------------------------") print(name) @@ -162,6 +162,29 @@ def onetime_db_fix(): else: print("db already fixed") +def onetime_db_fix_again_cus_im_dumb(): + os.makedirs(filebase, exist_ok=True) + filename = "%s/%s" % (filebase,".dbfixed2") + if not os.path.exists(filename): + print("Fixing db again") + conn = sqlite3.connect('%s/activities.db' % filebase) + numonly = re.compile("(\d*\.\d*)") + cursor = conn.cursor() + a=get_runs() + sql="UPDATE activities SET speed=? WHERE id=?" + for i in a: + print(i["speed"]) + b=numonly.search(i["speed"]) + cursor.execute(sql, (b.group(0), i["id"])) + + conn.commit() + conn.close() + dotfile=open(filename, "w") + dotfile.write("db fixed") + dotfile.close + else: + print("db already fixed") + def rm_run(run): conn = sqlite3.connect('%s/activities.db' % filebase) cursor = conn.cursor() @@ -209,4 +232,5 @@ def stopwatchery(secs): else: hr = str(hr)+":" print(hr + mins+":"+sec) - return hr + mins+":"+sec \ No newline at end of file + return hr + mins+":"+sec +