|
|
|
@ -7,7 +7,7 @@ from .models import (Device,
|
|
|
|
|
DeviceType,
|
|
|
|
|
AccessLevel)
|
|
|
|
|
from itsdangerous import URLSafeSerializer
|
|
|
|
|
from app.core import app
|
|
|
|
|
from app.core import app, db
|
|
|
|
|
from app.jsonql import api as jsonql
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -335,7 +335,7 @@ def run_custom_query(device_id, request):
|
|
|
|
|
if not Device.exists(id=device_id):
|
|
|
|
|
raise ValueError("Device does not exist!")
|
|
|
|
|
|
|
|
|
|
def recording_field_provider(name):
|
|
|
|
|
def recording_field_provider(name, formatted=False):
|
|
|
|
|
if name == 'record_value':
|
|
|
|
|
return Recording.record_value
|
|
|
|
|
if name == 'record_type':
|
|
|
|
@ -343,8 +343,14 @@ def run_custom_query(device_id, request):
|
|
|
|
|
if name == 'device_id':
|
|
|
|
|
return Recording.device_id
|
|
|
|
|
if name == 'recorded_at':
|
|
|
|
|
if formatted:
|
|
|
|
|
return db.func.to_char(
|
|
|
|
|
Recording.recorded_at, 'YYYY-MM-DD"T"HH24:MI:SSOF')
|
|
|
|
|
return Recording.recorded_at
|
|
|
|
|
if name == 'received_at':
|
|
|
|
|
if formatted:
|
|
|
|
|
return db.func.to_char(
|
|
|
|
|
Recording.received_at, 'YYYY-MM-DD"T"HH24:MI:SSOF')
|
|
|
|
|
return Recording.received_at
|
|
|
|
|
|
|
|
|
|
resulting_query = jsonql.run_query_on(Recording.query.with_entities(),
|
|
|
|
|