add device_id to the metrics.api table for reporting
parent
b88ca3d221
commit
bbd5088a6a
|
@ -8,5 +8,6 @@ CREATE TABLE metrics.api (
|
|||
duration INTEGER NOT NULL,
|
||||
http_status CHAR(3) NOT NULL,
|
||||
account_id uuid,
|
||||
device_id uuid,
|
||||
UNIQUE (url, access_ts)
|
||||
)
|
||||
|
|
|
@ -62,13 +62,19 @@ def add_api_metric(http_status):
|
|||
else:
|
||||
account_id = None
|
||||
|
||||
if 'device_id' in global_context:
|
||||
device_id = global_context.device_id
|
||||
else:
|
||||
device_id = None
|
||||
|
||||
api_metric = ApiMetric(
|
||||
url=global_context.url,
|
||||
access_ts=datetime.utcnow(),
|
||||
api=api,
|
||||
duration=(datetime.utcnow() - global_context.start_ts).microseconds,
|
||||
account_id=account_id,
|
||||
http_status=int(http_status)
|
||||
api=api,
|
||||
device_id=device_id,
|
||||
duration=(datetime.utcnow() - global_context.start_ts).microseconds,
|
||||
http_status=int(http_status),
|
||||
url=global_context.url
|
||||
)
|
||||
metric_repository = ApiMetricsRepository(global_context.db)
|
||||
metric_repository.add(api_metric)
|
||||
|
|
|
@ -109,8 +109,9 @@ class PublicEndpoint(MethodView):
|
|||
if session is not None:
|
||||
if device_id is not None:
|
||||
session = json.loads(session)
|
||||
uuid = session['uuid']
|
||||
device_authenticated = (device_id == uuid)
|
||||
device_uuid = session['uuid']
|
||||
global_context.device_id = device_uuid
|
||||
device_authenticated = (device_id == device_uuid)
|
||||
else:
|
||||
device_authenticated = True
|
||||
if not device_authenticated:
|
||||
|
|
Loading…
Reference in New Issue