From e63e7100f0c89c248e2f5b54a113da0f165c0e28 Mon Sep 17 00:00:00 2001 From: inportb Date: Thu, 25 May 2023 06:19:21 -0400 Subject: [PATCH] Exponential expansion of reportloader_alpha --- htdocs/RoutePatientReports.vue | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/htdocs/RoutePatientReports.vue b/htdocs/RoutePatientReports.vue index 64e5d40..0b84a60 100644 --- a/htdocs/RoutePatientReports.vue +++ b/htdocs/RoutePatientReports.vue @@ -317,7 +317,7 @@ } function reportloader_alpha(dfn, rpt_id, fn_map, omega) { - var dt_omega = strptime_vista(omega), cursor = Math.floor(strftime_vista(new Date())) + 0.235959999, interval = 86400000*3650, data = [], dt_end, hasmore = true; + var dt_omega = strptime_vista(omega), cursor = Math.floor(strftime_vista(new Date())) + 0.235959999, interval = 86400000*365*2, data = [], dt_end, hasmore = true; async function fn(client, alpha) { var dt_alpha = strptime_vista(alpha); if(alpha !== undefined) { @@ -331,14 +331,17 @@ if((data.length > 0) && ((dt_alpha > dt_end) || (alpha === undefined)) && ((res.length < 1) || (res[res.length - 1] !== data[data.length - 1]))) res.next = strftime_vista(res.dt_next = dt_end); // lookahead else if(hasmore) { var count = data.length; - cursor = Math.floor(strftime_vista(new Date(strptime_vista(cursor) - interval))); - data = (await client.ORWRP_REPORT_TEXT(dfn, rpt_id, '', SZ_RANGE, '', cursor, -1)).map(fn_map).sort((a, b) => b.time - a.time); - if(data.length > count) res.next = strftime_vista(res.dt_next = dt_end = data_endtime(data)); - else { - data = (await client.ORWRP_REPORT_TEXT(dfn, rpt_id, '', SZ_RANGE, '', -1, -1)).map(fn_map).sort((a, b) => b.time - a.time); - cursor = Math.floor(res.next = strftime_vista(res.dt_next = dt_end = data_endtime(data))); - hasmore = false; + while(interval <= 86400000*365*8) { + cursor = Math.floor(strftime_vista(new Date(strptime_vista(cursor) - interval))); + data = (await client.ORWRP_REPORT_TEXT(dfn, rpt_id, '', SZ_RANGE, '', cursor, -1)).map(fn_map).sort((a, b) => b.time - a.time); + if(data.length > count) { + res.next = strftime_vista(res.dt_next = dt_end = data_endtime(data)); + return res; + } else interval *= 2; } + data = (await client.ORWRP_REPORT_TEXT(dfn, rpt_id, '', SZ_RANGE, '', -1, -1)).map(fn_map).sort((a, b) => b.time - a.time); + cursor = Math.floor(res.next = strftime_vista(res.dt_next = dt_end = data_endtime(data))); + hasmore = false; } return res; }