Commit a447541d authored by Jérome Perrin's avatar Jérome Perrin

sql_browser: set a server timing header to publish query time

https://w3c.github.io/server-timing/#the-server-timing-header-field
parent 5435527d
from decimal import Decimal from decimal import Decimal
import datetime import datetime
import time
import json import json
from DateTime import DateTime from DateTime import DateTime
response = container.REQUEST.RESPONSE response = container.REQUEST.RESPONSE
start = time.time()
try: try:
results = context.manage_test(query) results = context.manage_test(query)
data = [ results.names() ] data = [ results.names() ]
...@@ -31,5 +32,6 @@ for line in data[1:]: ...@@ -31,5 +32,6 @@ for line in data[1:]:
new_line.append(v) new_line.append(v)
new_data.append(new_line) new_data.append(new_line)
response.setHeader("Server-Timing", "db=%s;" % (time.time() - start))
response.setHeader('Content-Type', 'application/json') response.setHeader('Content-Type', 'application/json')
return json.dumps(new_data, indent=2) return json.dumps(new_data, indent=2)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment