Fixed problems with canceled orders

This commit is contained in:
Luca Sorace "Stranck 2024-03-12 21:35:52 +01:00
parent c405a49366
commit f4ebc83a9b
2 changed files with 21 additions and 9 deletions

12
ext.py
View File

@ -35,16 +35,21 @@ class Order:
self.sponsorship = None
self.has_early = False
self.has_late = False
self.first_name = None
self.last_name = None
self.first_name = "None"
self.last_name = "None"
self.country = 'xx'
self.address = None
self.checked_in = False
self.room_type = None
self.daily = False
self.dailyDays = []
self.bed_in_room = -1
self.room_person_no = 0
self.answers = []
self.position_id = -1
self.position_positionid = -1
self.position_positiontypeid = -1
self.barcode = "None"
idata = data['invoice_address']
if idata:
@ -106,6 +111,9 @@ class Order:
self.phone = data['phone']
self.room_errors = []
self.loadAns()
if(self.bed_in_room < 0):
self.status = "canceled" # Must refer to the previous status assignment
def loadAns(self):
self.shirt_size = self.ans('shirt_size')
self.is_artist = True if self.ans('is_artist') != 'No' else False

View File

@ -1,6 +1,7 @@
from sanic.log import logger, logging
from logging import LogRecord
from config import *
import traceback
METRICS_REQ_NO = 0
METRICS_ERR_NO = 0 # Errors served to the clients
@ -47,7 +48,7 @@ def getMetricsText():
def getRoomCountersText(request):
out = []
try :
try:
daily = 0
counters = {}
counters_early = {}
@ -61,6 +62,8 @@ def getRoomCountersText(request):
if(order.daily):
daily += 1
else:
# Order.status must reflect the one in the Order() constructor inside ext.py
if(order.status in ["pending", "paid"] and hasattr(order, "bed_in_room") and order.bed_in_room in counters):
counters[order.bed_in_room] += 1
if(order.has_early):
counters_early[order.bed_in_room] += 1
@ -76,7 +79,8 @@ def getRoomCountersText(request):
out.append(f'webint_order_room_counter{{label="Daily"}} {daily}')
except Exception as e:
print(e)
print(traceback.format_exc())
logger.warning("Error in loading metrics rooms")
return "\n".join(out)