Added metrics for early/late orders

This commit is contained in:
Luca Sorace "Stranck 2024-02-27 19:53:07 +01:00
parent 5d79052e59
commit 3919d512a1
1 changed files with 13 additions and 1 deletions

View File

@ -50,17 +50,29 @@ def getRoomCountersText(request):
try : try :
daily = 0 daily = 0
counters = {} counters = {}
counters_early = {}
counters_late = {}
for id in ROOM_TYPE_NAMES.keys(): for id in ROOM_TYPE_NAMES.keys():
counters[id] = 0 counters[id] = 0
counters_early[id] = 0
counters_late[id] = 0
for order in request.app.ctx.om.cache.values(): for order in request.app.ctx.om.cache.values():
if(order.daily): if(order.daily):
daily += 1 daily += 1
else: else:
counters[order.bed_in_room] += 1 counters[order.bed_in_room] += 1
if(order.has_early):
counters_early[order.bed_in_room] += 1
if(order.has_late):
counters_late[order.bed_in_room] += 1
for id, count in counters.items(): for id, count in counters.items():
out.append(f'webint_order_room_counter{{label="{ROOM_TYPE_NAMES[id]}"}} {count}') out.append(f'webint_order_room_counter{{days="normal", label="{ROOM_TYPE_NAMES[id]}"}} {count}')
for id, count in counters_early.items():
out.append(f'webint_order_room_counter{{days="early", label="{ROOM_TYPE_NAMES[id]}"}} {count}')
for id, count in counters_late.items():
out.append(f'webint_order_room_counter{{days="late", label="{ROOM_TYPE_NAMES[id]}"}} {count}')
out.append(f'webint_order_room_counter{{label="Daily"}} {daily}') out.append(f'webint_order_room_counter{{label="Daily"}} {daily}')
except Exception as e: except Exception as e: