Fixed problems with canceled orders
This commit is contained in:
parent
c405a49366
commit
f4ebc83a9b
12
ext.py
12
ext.py
|
@ -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
|
||||
|
|
18
metrics.py
18
metrics.py
|
@ -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,11 +62,13 @@ def getRoomCountersText(request):
|
|||
if(order.daily):
|
||||
daily += 1
|
||||
else:
|
||||
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
|
||||
# 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
|
||||
if(order.has_late):
|
||||
counters_late[order.bed_in_room] += 1
|
||||
|
||||
for id, count in counters.items():
|
||||
out.append(f'webint_order_room_counter{{days="normal", label="{ROOM_TYPE_NAMES[id]}"}} {count}')
|
||||
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue