stranck-dev #23
12
ext.py
12
ext.py
|
@ -35,16 +35,21 @@ class Order:
|
||||||
self.sponsorship = None
|
self.sponsorship = None
|
||||||
self.has_early = False
|
self.has_early = False
|
||||||
self.has_late = False
|
self.has_late = False
|
||||||
self.first_name = None
|
self.first_name = "None"
|
||||||
self.last_name = None
|
self.last_name = "None"
|
||||||
self.country = 'xx'
|
self.country = 'xx'
|
||||||
self.address = None
|
self.address = None
|
||||||
self.checked_in = False
|
self.checked_in = False
|
||||||
self.room_type = None
|
self.room_type = None
|
||||||
self.daily = False
|
self.daily = False
|
||||||
self.dailyDays = []
|
self.dailyDays = []
|
||||||
|
self.bed_in_room = -1
|
||||||
self.room_person_no = 0
|
self.room_person_no = 0
|
||||||
self.answers = []
|
self.answers = []
|
||||||
|
self.position_id = -1
|
||||||
|
self.position_positionid = -1
|
||||||
|
self.position_positiontypeid = -1
|
||||||
|
self.barcode = "None"
|
||||||
|
|
||||||
idata = data['invoice_address']
|
idata = data['invoice_address']
|
||||||
if idata:
|
if idata:
|
||||||
|
@ -106,6 +111,9 @@ class Order:
|
||||||
self.phone = data['phone']
|
self.phone = data['phone']
|
||||||
self.room_errors = []
|
self.room_errors = []
|
||||||
self.loadAns()
|
self.loadAns()
|
||||||
|
|
||||||
|
if(self.bed_in_room < 0):
|
||||||
|
self.status = "canceled" # Must refer to the previous status assignment
|
||||||
def loadAns(self):
|
def loadAns(self):
|
||||||
self.shirt_size = self.ans('shirt_size')
|
self.shirt_size = self.ans('shirt_size')
|
||||||
self.is_artist = True if self.ans('is_artist') != 'No' else False
|
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 sanic.log import logger, logging
|
||||||
from logging import LogRecord
|
from logging import LogRecord
|
||||||
from config import *
|
from config import *
|
||||||
|
import traceback
|
||||||
|
|
||||||
METRICS_REQ_NO = 0
|
METRICS_REQ_NO = 0
|
||||||
METRICS_ERR_NO = 0 # Errors served to the clients
|
METRICS_ERR_NO = 0 # Errors served to the clients
|
||||||
|
@ -47,7 +48,7 @@ def getMetricsText():
|
||||||
|
|
||||||
def getRoomCountersText(request):
|
def getRoomCountersText(request):
|
||||||
out = []
|
out = []
|
||||||
try :
|
try:
|
||||||
daily = 0
|
daily = 0
|
||||||
counters = {}
|
counters = {}
|
||||||
counters_early = {}
|
counters_early = {}
|
||||||
|
@ -61,11 +62,13 @@ def getRoomCountersText(request):
|
||||||
if(order.daily):
|
if(order.daily):
|
||||||
daily += 1
|
daily += 1
|
||||||
else:
|
else:
|
||||||
counters[order.bed_in_room] += 1
|
# Order.status must reflect the one in the Order() constructor inside ext.py
|
||||||
if(order.has_early):
|
if(order.status in ["pending", "paid"] and hasattr(order, "bed_in_room") and order.bed_in_room in counters):
|
||||||
counters_early[order.bed_in_room] += 1
|
counters[order.bed_in_room] += 1
|
||||||
if(order.has_late):
|
if(order.has_early):
|
||||||
counters_late[order.bed_in_room] += 1
|
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{{days="normal", label="{ROOM_TYPE_NAMES[id]}"}} {count}')
|
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}')
|
out.append(f'webint_order_room_counter{{label="Daily"}} {daily}')
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(traceback.format_exc())
|
||||||
|
|
||||||
logger.warning("Error in loading metrics rooms")
|
logger.warning("Error in loading metrics rooms")
|
||||||
return "\n".join(out)
|
return "\n".join(out)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue