Compare commits

...

2 Commits

Author SHA1 Message Date
9fe8227c57 Default stale=false; specific staleness parameters 2023-05-03 20:32:16 -04:00
6a284e9b6b Fix stacked updates 2023-05-03 14:31:07 -04:00
3 changed files with 22 additions and 15 deletions

View File

@ -62,6 +62,12 @@
import Autocomplete from './Autocomplete.vue';
function clearTimeouts(timers) {
if(timers.length > 1) console.warn('Clearing multiple timeouts', timers.slice());
for(var i = 0; i < timers.length; ++i) window.clearTimeout(timers[i]);
timers.length = 0;
}
export default {
components: {
Autocomplete
@ -78,6 +84,7 @@
data() {
return {
appointments: [],
timers: [],
ts: null,
age: undefined,
filter: {}
@ -118,16 +125,17 @@
return true;
},
async update() {
clearTimeouts(this.timers);
try {
this.appointments = (await this.client.SDEC_CRSCHED(this.selection.join('|') + '|', strfdate_vista(this.date_begin), strfdate_vista(this.date_end) + '@2359')).sort((a, b) => (new Date(a.START_TIME)) - (new Date(b.START_TIME)));
var now = new Date();
this.ts = this.appointments._ts ? new Date(1000*this.appointments._ts) : now;
this.age = now - this.ts;
this.timer = window.setTimeout(this.update, Math.max(60000 - this.age, 10000));
this.timers.push(window.setTimeout(this.update, Math.max(60000 - this.age, 10000)));
} catch(ex) {
this.age = this.ts ? (new Date()) - this.ts : Infinity;
console.warn(ex);
this.timer = window.setTimeout(this.update, 30000);
this.timers.push(window.setTimeout(this.update, 30000));
}
}
},
@ -136,13 +144,12 @@
() => (this.client, this.selection, this.date_begin, this.date_end, {}),
debounce(async () => {
this.filter = {};
window.clearTimeout(this.timer);
this.update();
}, 500)
);
},
unmounted() {
window.clearTimeout(this.timer);
clearTimeouts(this.timers);
}
};
</script>

View File

@ -347,12 +347,12 @@ export function Client(cid, secret) {
this.XWB_IM_HERE = unwrapped(logged(() => this.call({ method: 'XWB_IM_HERE', ttl: 30, stale: false }), 'XWB_IM_HERE'));
this.XUS_INTRO_MSG = memoized(unwrapped(logged(() => this.callctx(['XUCOMMAND'], 'XUS_INTRO_MSG'), 'XUS_INTRO_MSG')));
this.XWB_GET_BROKER_INFO = memoized(unwrapped(logged(() => this.callctx(['XUCOMMAND'], 'XWB_GET_BROKER_INFO'), 'XWB_GET_BROKER_INFO')));
this.XUS_GET_USER_INFO = memoized(unwrapped(logged(() => this.call('XUS_GET_USER_INFO'), 'XUS_GET_USER_INFO')));
this.XWB_GET_BROKER_INFO = memoized(unwrapped(logged(() => this.call({ method: 'XWB_GET_BROKER_INFO', context: ['XUCOMMAND'], ttl: 0, stale: false }), 'XWB_GET_BROKER_INFO')));
this.XUS_GET_USER_INFO = memoized(unwrapped(logged(() => this.call({ method: 'XUS_GET_USER_INFO', ttl: 0, stale: false }), 'XUS_GET_USER_INFO')));
this.SDEC_RESOURCE = memoized(unwrapped(logged(() => this.call({ method: 'SDEC_RESOURCE', context: ['SDECRPC'], ttl: 2592000 }), 'SDEC_RESOURCE')));
this.SDEC_CLINLET = unwrapped(logged((...args) => this.call({ method: 'SDEC_CLINLET', context: ['SDECRPC'], ttl: 30 }, ...args), 'SDEC_CLINLET'));
this.SDEC_CRSCHED = unwrapped(logged((...args) => this.call({ method: 'SDEC_CRSCHED', context: ['SDECRPC'], ttl: 30 }, ...args), 'SDEC_CRSCHED'));
this.SDEC_RESOURCE = memoized(unwrapped(logged(() => this.call({ method: 'SDEC_RESOURCE', context: ['SDECRPC'], ttl: 2592000, stale: true }), 'SDEC_RESOURCE')));
this.SDEC_CLINLET = unwrapped(logged((...args) => this.call({ method: 'SDEC_CLINLET', context: ['SDECRPC'], ttl: 30, stale: false }, ...args), 'SDEC_CLINLET'));
this.SDEC_CRSCHED = unwrapped(logged((...args) => this.call({ method: 'SDEC_CRSCHED', context: ['SDECRPC'], ttl: 30, stale: false }, ...args), 'SDEC_CRSCHED'));
this.ORWPT_FULLSSN = memoized(caretseparated(unwrapped(logged((...args) => this.callctx(['OR CPRS GUI CHART'], 'ORWPT_FULLSSN', ...args), 'ORWPT_FULLSSN')), ['dfn', 'name', 'date', 'pid']));
this.ORWPT_LAST5 = memoized(caretseparated(unwrapped(logged((...args) => this.callctx(['OR CPRS GUI CHART'], 'ORWPT_LAST5', ...args), 'ORWPT_LAST5')), ['dfn', 'name', 'date', 'pid']));
@ -364,9 +364,9 @@ export function Client(cid, secret) {
this.ORQQVI_VITALS = memoized(caretseparated(unwrapped(logged((...args) => this.callctx(['OR CPRS GUI CHART'], 'ORQQVI_VITALS', ...args), 'ORQQVI_VITALS')), ['measurement_ien', 'type', 'value', 'datetime', 'value_american', 'value_metric']));
this.ORQQVI_VITALS_FOR_DATE_RANGE = memoized(caretseparated(unwrapped(logged((...args) => this.callctx(['OR CPRS GUI CHART'], 'ORQQVI_VITALS_FOR_DATE_RANGE', ...args), 'ORQQVI_VITALS_FOR_DATE_RANGE')), ['measurement_ien', 'type', 'value', 'datetime']));
this.GMV_EXTRACT_REC = async (dfn, oredt, orsdt) => measurement_parse(await unwrapped(logged((...args) => this.call({ method: 'GMV_EXTRACT_REC', context: ['OR CPRS GUI CHART'], ttl: 60}, args.join('^')), 'GMV_EXTRACT_REC'))(dfn, oredt, '', orsdt));
this.GMV_EXTRACT_REC = async (dfn, oredt, orsdt) => measurement_parse(await unwrapped(logged((...args) => this.call({ method: 'GMV_EXTRACT_REC', context: ['OR CPRS GUI CHART'], ttl: 60, stale: false }, args.join('^')), 'GMV_EXTRACT_REC'))(dfn, oredt, '', orsdt));
this.ORWLRR_INTERIM = labreportparsed(unwrapped(logged((...args) => this.call({ method: 'ORWLRR_INTERIM', context: ['OR CPRS GUI CHART'], ttl: 60 }, ...args), 'ORWLRR_INTERIM')));
this.ORWLRR_INTERIM = labreportparsed(unwrapped(logged((...args) => this.call({ method: 'ORWLRR_INTERIM', context: ['OR CPRS GUI CHART'], ttl: 60, stale: false }, ...args), 'ORWLRR_INTERIM')));
this.ORWLRR_INTERIM_RESULTS = async (...args) => lab_reparse_results(await this.ORWLRR_INTERIM(...args));
this.ORWORDG_ALLTREE = memoized(caretseparated(unwrapped(logged(() => this.callctx(['OR CPRS GUI CHART'], 'ORWORDG_ALLTREE'), 'ORWORDG_ALLTREE')), ['ien', 'name', 'parent', 'has_children']));
@ -374,8 +374,8 @@ export function Client(cid, secret) {
this.ORWORR_AGET = memoized(caretseparated(sliced(unwrapped(logged((...args) => this.callctx(['OR CPRS GUI CHART'], 'ORWORR_AGET', ...args), 'ORWORR_AGET')), 1), ['ifn', 'dgrp', 'time']));
this.ORWORR_GET4LST = memoized(parsed_orderinfo(unwrapped(logged((...args) => this.callctx(['OR CPRS GUI CHART'], 'ORWORR_GET4LST', ...args), 'ORWORR_GET4LST'))));
this.TIU_TEMPLATE_GETROOTS = caretseparated(unwrapped(logged((...args) => this.call({ method: 'TIU_TEMPLATE_GETROOTS', context: ['OR CPRS GUI CHART'], ttl: 86400 }, ...args), 'TIU_TEMPLATE_GETROOTS')), ['IEN', 'type', 'status', 'name', 'exclude_from_group_boilerplate', 'blank_lines', 'personal_owner', 'has_children_flag', 'dialog', 'display_only', 'first_line', 'one_item_only', 'hide_dialog_items', 'hide_tree_items', 'indent_items', 'reminder_dialog_ien', 'reminder_dialog_name', 'locked', 'com_object_pointer', 'com_object_parameter', 'link_pointer', 'reminder_dialog_patient_specific_value']);
this.TIU_TEMPLATE_GETPROOT = caretseparated(unwrapped(logged((...args) => this.call({ method: 'TIU_TEMPLATE_GETPROOT', context: ['OR CPRS GUI CHART'], ttl: 86400 }, ...args), 'TIU_TEMPLATE_GETPROOT')), ['IEN', 'type', 'status', 'name', 'exclude_from_group_boilerplate', 'blank_lines', 'personal_owner', 'has_children_flag', 'dialog', 'display_only', 'first_line', 'one_item_only', 'hide_dialog_items', 'hide_tree_items', 'indent_items', 'reminder_dialog_ien', 'reminder_dialog_name', 'locked', 'com_object_pointer', 'com_object_parameter', 'link_pointer', 'reminder_dialog_patient_specific_value']);
this.TIU_TEMPLATE_GETROOTS = caretseparated(unwrapped(logged((...args) => this.call({ method: 'TIU_TEMPLATE_GETROOTS', context: ['OR CPRS GUI CHART'], ttl: 86400, stale: true }, ...args), 'TIU_TEMPLATE_GETROOTS')), ['IEN', 'type', 'status', 'name', 'exclude_from_group_boilerplate', 'blank_lines', 'personal_owner', 'has_children_flag', 'dialog', 'display_only', 'first_line', 'one_item_only', 'hide_dialog_items', 'hide_tree_items', 'indent_items', 'reminder_dialog_ien', 'reminder_dialog_name', 'locked', 'com_object_pointer', 'com_object_parameter', 'link_pointer', 'reminder_dialog_patient_specific_value']);
this.TIU_TEMPLATE_GETPROOT = caretseparated(unwrapped(logged((...args) => this.call({ method: 'TIU_TEMPLATE_GETPROOT', context: ['OR CPRS GUI CHART'], ttl: 86400, stale: true }, ...args), 'TIU_TEMPLATE_GETPROOT')), ['IEN', 'type', 'status', 'name', 'exclude_from_group_boilerplate', 'blank_lines', 'personal_owner', 'has_children_flag', 'dialog', 'display_only', 'first_line', 'one_item_only', 'hide_dialog_items', 'hide_tree_items', 'indent_items', 'reminder_dialog_ien', 'reminder_dialog_name', 'locked', 'com_object_pointer', 'com_object_parameter', 'link_pointer', 'reminder_dialog_patient_specific_value']);
this.TIU_TEMPLATE_GETBOIL = parsed_text(unwrapped(logged((...args) => this.call({ method: 'TIU_TEMPLATE_GETBOIL', context: ['OR CPRS GUI CHART'], ttl: 0, stale: false }, ...args), 'TIU_TEMPLATE_GETBOIL')));
this.TIU_TEMPLATE_GETITEMS = caretseparated(parsed_nullarray(unwrapped(logged((...args) => this.call({ method: 'TIU_TEMPLATE_GETITEMS', context: ['OR CPRS GUI CHART'], ttl: 0, stale: false }, ...args), 'TIU_TEMPLATE_GETITEMS'))), ['IEN', 'type', 'status', 'name', 'exclude_from_group_boilerplate', 'blank_lines', 'personal_owner', 'has_children_flag', 'dialog', 'display_only', 'first_line', 'one_item_only', 'hide_dialog_items', 'hide_tree_items', 'indent_items', 'reminder_dialog_ien', 'reminder_dialog_name', 'locked', 'com_object_pointer', 'com_object_parameter', 'link_pointer', 'reminder_dialog_patient_specific_value']);
this.TIU_TEMPLATE_SET_ITEMS = unwrapped(logged((...args) => this.call({ method: 'TIU_TEMPLATE_SET_ITEMS', context: ['OR CPRS GUI CHART'], ttl: 0, stale: false }, ...args), 'TIU_TEMPLATE_SET_ITEMS'));

View File

@ -129,7 +129,7 @@ class CacheProxy(object):
with cache:
res = cache[_cache_key] = await value(*args, **kw)
return res
async def thunk(*args, _cache_ttl: float=ttl, _cache_stale: bool=True, **kw):
async def thunk(*args, _cache_ttl: float=ttl, _cache_stale: bool=False, **kw):
_cache_key = prefix + key + repr(args) + repr(kw)
try:
return cache[_cache_key:_cache_ttl]
@ -145,7 +145,7 @@ class CacheProxy(object):
with lock, cache:
res = cache[_cache_key] = value(*args, **kw)
return res
def thunk(*args, _cache_ttl: float=ttl, _cache_stale: bool=True, **kw):
def thunk(*args, _cache_ttl: float=ttl, _cache_stale: bool=False, **kw):
_cache_key = prefix + key + repr(args) + repr(kw)
try:
return cache[_cache_key:_cache_ttl]