From df80b6063e0ac85d4cbe3f8ede8cd263bf0a8eb3 Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Thu, 28 Nov 2019 18:17:52 +0100 Subject: [PATCH] Show the number of starts since the change of language --- hugvey/central_command.py | 14 ++++++++++++++ hugvey/panopticon.py | 1 + www/index.html | 2 ++ www/js/hugvey_console.js | 2 ++ 4 files changed, 19 insertions(+) diff --git a/hugvey/central_command.py b/hugvey/central_command.py index f604028..0fd8456 100644 --- a/hugvey/central_command.py +++ b/hugvey/central_command.py @@ -241,6 +241,7 @@ class CentralCommand(object): 'hugveys': [], 'logbookId': None, 'logbook': [], + 'starts_since_lang_change': self.getHugveyStartsSinceLanguageChange() } #use this to test if any threads stay open @@ -258,6 +259,19 @@ class CentralCommand(object): return status + def getHugveyStartsSinceLanguageChange(self): + ''' + Some info on the nr. of hugveys since last change of language (using the change-all button in panopticon) + ''' + changeTime = self.timer.marks['languageChange'] if self.timer.hasMark('languageChange') else self.timer.marks['start'] + nrOfStarts = 0 + for hv in self.hugveys.values(): + if hv.story: + if hv.story.timer.hasMark('first_speech'): + if hv.story.timer.marks['first_speech'] > changeTime: + nrOfStarts += 1 + return nrOfStarts + def setLoopTime(self, secondsAgo: int): self.timer.setMark('start', time.time() - secondsAgo) diff --git a/hugvey/panopticon.py b/hugvey/panopticon.py index b0448b9..925ea98 100644 --- a/hugvey/panopticon.py +++ b/hugvey/panopticon.py @@ -150,6 +150,7 @@ def getWebSocketHandler(central_command): """ Set language for all future hugvey runs (so after a 'finish') """ + central_command.timer.setMark('languageChange') for hv_id in central_command.hugveys: if central_command.hugveys[hv_id].eventQueue: central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_language_if_available', 'lang_code': lang_code}) diff --git a/www/index.html b/www/index.html index af5395d..7993027 100644 --- a/www/index.html +++ b/www/index.html @@ -22,6 +22,8 @@ + {{starts_since_lang_change}} +