Show the number of starts since the change of language

This commit is contained in:
Ruben van de Ven 2019-11-28 18:17:52 +01:00
parent fe0b67aed4
commit df80b6063e
4 changed files with 19 additions and 0 deletions

View file

@ -241,6 +241,7 @@ class CentralCommand(object):
'hugveys': [], 'hugveys': [],
'logbookId': None, 'logbookId': None,
'logbook': [], 'logbook': [],
'starts_since_lang_change': self.getHugveyStartsSinceLanguageChange()
} }
#use this to test if any threads stay open #use this to test if any threads stay open
@ -258,6 +259,19 @@ class CentralCommand(object):
return status 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): def setLoopTime(self, secondsAgo: int):
self.timer.setMark('start', time.time() - secondsAgo) self.timer.setMark('start', time.time() - secondsAgo)

View file

@ -150,6 +150,7 @@ def getWebSocketHandler(central_command):
""" """
Set language for all future hugvey runs (so after a 'finish') Set language for all future hugvey runs (so after a 'finish')
""" """
central_command.timer.setMark('languageChange')
for hv_id in central_command.hugveys: for hv_id in central_command.hugveys:
if central_command.hugveys[hv_id].eventQueue: if central_command.hugveys[hv_id].eventQueue:
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_language_if_available', 'lang_code': lang_code}) central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_language_if_available', 'lang_code': lang_code})

View file

@ -22,6 +22,8 @@
<input type="button" onclick="panopticon.change_loop_time(document.getElementById('loop_time_value').value)" value="set time"> <input type="button" onclick="panopticon.change_loop_time(document.getElementById('loop_time_value').value)" value="set time">
</div> </div>
<span title="Conversations started since last language change">{{starts_since_lang_change}}</span>
<ul id='languages'> <ul id='languages'>
<li v-for="lang in languages" :title="lang.file" <li v-for="lang in languages" :title="lang.file"

View file

@ -19,6 +19,7 @@ class Panopticon {
selectedLang: null, selectedLang: null,
blockedHugveys: 0, blockedHugveys: 0,
availableHugveys: 0, availableHugveys: 0,
starts_since_lang_change: 0,
}, },
methods: { methods: {
time_passed: function( hugvey, property ) { time_passed: function( hugvey, property ) {
@ -183,6 +184,7 @@ class Panopticon {
this.hugveys.hugveys = msg['hugveys']; this.hugveys.hugveys = msg['hugveys'];
this.hugveys.logbook = msg['logbook']; this.hugveys.logbook = msg['logbook'];
this.hugveys.logbookId = msg['logbookId']; this.hugveys.logbookId = msg['logbookId'];
this.hugveys.starts_since_lang_change = msg['starts_since_lang_change'];
if(this.hugveys.selectedId) { if(this.hugveys.selectedId) {
this.updateSelectedHugvey(); this.updateSelectedHugvey();
} }