mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-09 03:36:48 +00:00
perf: the Logs and VM report downloads are written row by row
The workbook kept every cell as an object: a 100 000-row Logs download took some 400 MB in a web worker. openpyxl's write-only mode writes the rows as they come (85 MB for the same file, measured), and the Logs rows are read as tuples, not model objects. The bold, frozen, filtered header, the column widths and the text cells stay as they were.
This commit is contained in:
parent
d106a4f7ba
commit
d15842a250
3 changed files with 41 additions and 24 deletions
|
|
@ -306,9 +306,12 @@ def logs_export(request):
|
|||
rows, text, failed, _query = _logs(request)
|
||||
zone = timezone.get_current_timezone_name()
|
||||
header = [f"Date ({zone})", "User", "Host", "VM", "VM UUID", "Message", "Result", "IP"]
|
||||
logs = list(rows[:EXPORT_ROWS + 1])
|
||||
data = [[timezone.localtime(log.date).strftime("%Y-%m-%d %H:%M:%S"), log.user, log.host, log.instance,
|
||||
log.instance_uuid, log.message, str(_result(log.success)), log.ip or ""] for log in logs[:EXPORT_ROWS]]
|
||||
# tuples, not model objects: up to EXPORT_ROWS of them are held at once
|
||||
logs = list(rows.values_list("date", "user", "host", "instance", "instance_uuid", "message", "success", "ip")
|
||||
[:EXPORT_ROWS + 1])
|
||||
data = [[timezone.localtime(date).strftime("%Y-%m-%d %H:%M:%S"), user, host, instance, uuid, message,
|
||||
str(_result(success)), ip or ""]
|
||||
for date, user, host, instance, uuid, message, success, ip in logs[:EXPORT_ROWS]]
|
||||
notes = [f"Search: {text}" if text else "Search: none", "Failed only" if failed else "All results",
|
||||
f"Rows: {len(data)}", f"Times in {zone}"]
|
||||
if len(logs) > EXPORT_ROWS:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue