Fix timestamp inconsistency

This commit is contained in:
Jiang Yio 2023-05-16 23:27:13 -04:00
parent d3673fc826
commit c7a541a9e3
2 changed files with 6 additions and 4 deletions

View File

@ -27,6 +27,7 @@ export const d_unwrap = data => {
if(data.error) throw new RPCError(data.error.type, ...data.error.args); if(data.error) throw new RPCError(data.error.type, ...data.error.args);
if(data.ts) try { if(data.ts) try {
data.result._ts = data.ts; data.result._ts = data.ts;
if(data.cached) data.result._cached = data.cached;
} catch(ex) {} } catch(ex) {}
return data.result; return data.result;
}; };
@ -172,18 +173,18 @@ export const d_parse_notifications_fastuser = data => d_split(data, '^', 'info',
export const d_parse_multireport = data => { export const d_parse_multireport = data => {
if(data.length < 1) return []; if(data.length < 1) return [];
var brk, max = 0, grp; var brk, max = 0, grp, _ts = data._ts;
for(var i = 0; i < data.length; ++i) { for(var i = 0; i < data.length; ++i) {
brk = (grp = data[i]).indexOf('^'); brk = (grp = data[i]).indexOf('^');
if(brk >= 0) { if(brk >= 0) {
grp = +grp.substring(0, brk); grp = +grp.substring(0, brk);
if(grp >= max) max = grp; if(grp >= max) max = grp;
else break; else break;
} else return [data]; } else return (data = [data], data._ts = _ts, data);
} }
var res = [], data = data.slice(), max = max + '^', grp = x => x.startsWith(max); var res = [], data = data.slice(), max = max + '^', grp = x => x.startsWith(max);
while(((brk = data.findIndex(grp)) >= 0) || (brk = data.length)) res.push(data.splice(0, brk + 1)); while(((brk = data.findIndex(grp)) >= 0) || (brk = data.length)) res.push(data.splice(0, brk + 1));
return res; return (res._ts = _ts, res);
}; };
export const d_parse_tiudocumentlist = data => d_split(data, '^', 'IEN', 'title', 'time', 'patient', 'author', 'location', 'status', 'visit').map(row => { export const d_parse_tiudocumentlist = data => d_split(data, '^', 'IEN', 'title', 'time', 'patient', 'author', 'location', 'status', 'visit').map(row => {

View File

@ -3,6 +3,7 @@
import json import json
import secrets import secrets
import string import string
import time
from flask import Flask, request, send_from_directory from flask import Flask, request, send_from_directory
from flask.json import jsonify from flask.json import jsonify
from flask.json.provider import DefaultJSONProvider from flask.json.provider import DefaultJSONProvider
@ -39,7 +40,7 @@ class CacheProxyRPC(util.CacheProxy):
self._cache(('SDEC_RESOURCE', 'ORWU1_NEWLOC', 'ORWLRR_ALLTESTS_ALL', 'ORWORDG_ALLTREE', 'ORWORDG_REVSTS', 'ORWDX_DGNM', 'ORWDX_ORDITM'), persistent, prefix=prefix, ttl=float('inf')) self._cache(('SDEC_RESOURCE', 'ORWU1_NEWLOC', 'ORWLRR_ALLTESTS_ALL', 'ORWORDG_ALLTREE', 'ORWORDG_REVSTS', 'ORWDX_DGNM', 'ORWDX_ORDITM'), persistent, prefix=prefix, ttl=float('inf'))
def jsonify_result(value, id=None): def jsonify_result(value, id=None):
return jsonify({ 'result': value._base, 'error': None, 'id': request.json.get('id'), 'ts': value._ts } if isinstance(value, util.Cached) else { 'result': value, 'error': None, 'id': request.json.get('id') }) return jsonify({ 'result': value._base, 'error': None, 'id': request.json.get('id'), 'ts': value._ts, 'cached': True } if isinstance(value, util.Cached) else { 'result': value, 'error': None, 'id': request.json.get('id'), 'ts': time.time() })
def jsonify_error(ex, id=None): def jsonify_error(ex, id=None):
return jsonify({ 'result': None, 'error': { 'type': ex.__class__.__name__, 'args': ex.args }, 'id': id }) return jsonify({ 'result': None, 'error': { 'type': ex.__class__.__name__, 'args': ex.args }, 'id': id })