fix: a handled "O pedido mudou" no longer reaches Sentry (DTF-WEB-7, DTF-WEB-K), and the 90-day chart is readable on a phone
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 7m35s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 59s
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 7m35s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 59s
saveFinalFiles and pullMove answer a stale-version 409 by reloading and trying once more, but api() had already reported it. The first call now expects the 409; one they cannot answer is still reported (reportRefusal), and any other status is reported by api() as before, once. Past a month the chart's gap is 1 px (90 bars were under 1 px each on a 375 px phone), and the last date ends at the chart's edge instead of being cut. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -606,8 +606,9 @@ async function loadOlderFinished(){
|
|||||||
const fresh=page.orders.filter(o=>!known.has(o.id));
|
const fresh=page.orders.filter(o=>!known.has(o.id));
|
||||||
olderFinished.push(...fresh);board.orders.push(...fresh);finishedMore=page.has_more;renderBoard();
|
olderFinished.push(...fresh);board.orders.push(...fresh);finishedMore=page.has_more;renderBoard();
|
||||||
}
|
}
|
||||||
async function move(order,state,reason='',machine=null){
|
// `options` goes to api(): pullMove expects the 409 it answers itself.
|
||||||
await api('/orders/'+order.id+'/move',{state,version:order.version,reason,...(machine?{machine_id:machine}:{})});
|
async function move(order,state,reason='',machine=null,options={}){
|
||||||
|
await api('/orders/'+order.id+'/move',{state,version:order.version,reason,...(machine?{machine_id:machine}:{})},options);
|
||||||
await load();
|
await load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -356,6 +356,9 @@ function statsChart(box,daily){
|
|||||||
if(avg>0){const a=node('span',undefined,'avg');a.style.bottom=100*avg/ceiling+'%';plot.append(a);}
|
if(avg>0){const a=node('span',undefined,'avg');a.style.bottom=100*avg/ceiling+'%';plot.append(a);}
|
||||||
const bars=node('div',undefined,'bars'),axis=node('div',undefined,'axis');axis.setAttribute('aria-hidden','true');
|
const bars=node('div',undefined,'bars'),axis=node('div',undefined,'axis');axis.setAttribute('aria-hidden','true');
|
||||||
bars.style.gridTemplateColumns=axis.style.gridTemplateColumns='repeat('+daily.length+',minmax(0,1fr))';
|
bars.style.gridTemplateColumns=axis.style.gridTemplateColumns='repeat('+daily.length+',minmax(0,1fr))';
|
||||||
|
// 90 days on a phone left the gaps no room for the bars (under 1 px each):
|
||||||
|
// past a month the gap is 1 px.
|
||||||
|
bars.classList.toggle('dense',daily.length>31);axis.classList.toggle('dense',daily.length>31);
|
||||||
// A phone has room for fewer dates under the bars.
|
// A phone has room for fewer dates under the bars.
|
||||||
const every=Math.ceil(daily.length/(PHONE.matches?5:10));
|
const every=Math.ceil(daily.length/(PHONE.matches?5:10));
|
||||||
daily.forEach((d,i)=>{
|
daily.forEach((d,i)=>{
|
||||||
@@ -363,7 +366,8 @@ function statsChart(box,daily){
|
|||||||
b.style.animationDelay=Math.min(i*12,400)+'ms';
|
b.style.animationDelay=Math.min(i*12,400)+'ms';
|
||||||
b.dataset.tip=shortDay(d.day)+': '+metres(d.metres)+', '+plural(d.orders,'pedido','pedidos');
|
b.dataset.tip=shortDay(d.day)+': '+metres(d.metres)+', '+plural(d.orders,'pedido','pedidos');
|
||||||
if(i<3)b.classList.add('tip-r');else if(i>daily.length-4)b.classList.add('tip-l');
|
if(i<3)b.classList.add('tip-r');else if(i>daily.length-4)b.classList.add('tip-l');
|
||||||
bars.append(b);axis.append(node('span',(daily.length-1-i)%every===0?shortDay(d.day):''));
|
// The last date ends at the chart's edge instead of running past it.
|
||||||
|
bars.append(b);axis.append(node('span',(daily.length-1-i)%every===0?shortDay(d.day):'',i===daily.length-1?'end':undefined));
|
||||||
});
|
});
|
||||||
plot.append(bars,axis);
|
plot.append(bars,axis);
|
||||||
plot.setAttribute('role','img');plot.setAttribute('aria-label','Metros vendidos por dia, '+daily.length+' dias, média de '+metres(avg));
|
plot.setAttribute('role','img');plot.setAttribute('aria-label','Metros vendidos por dia, '+daily.length+' dias, média de '+metres(avg));
|
||||||
|
|||||||
@@ -588,11 +588,14 @@ function readyFinals(order){
|
|||||||
// form dialog then closes itself. Anything else is still an error, and the
|
// form dialog then closes itself. Anything else is still an error, and the
|
||||||
// version is never resent blindly.
|
// version is never resent blindly.
|
||||||
async function saveFinalFiles(order, files, note){
|
async function saveFinalFiles(order, files, note){
|
||||||
|
const path='/orders/'+order.id+'/final-files';
|
||||||
try{
|
try{
|
||||||
await api('/orders/'+order.id+'/final-files',{version:order.version,files,note});
|
// The first 409 is expected: it is answered below, so it is not reported;
|
||||||
|
// one this function does not answer is (reportRefusal).
|
||||||
|
await api(path,{version:order.version,files,note},{expected:[409]});
|
||||||
return false;
|
return false;
|
||||||
}catch(error){
|
}catch(error){
|
||||||
if(error.status!==409||!String(error.message).startsWith('O pedido mudou'))throw error;
|
if(error.status!==409||!String(error.message).startsWith('O pedido mudou'))throw reportRefusal(path,error);
|
||||||
await load();
|
await load();
|
||||||
const fresh=(board.orders||[]).find(row=>row.id===order.id);
|
const fresh=(board.orders||[]).find(row=>row.id===order.id);
|
||||||
if(fresh&&(finalDone(fresh)||!['rec','cor'].includes(fresh.state))){
|
if(fresh&&(finalDone(fresh)||!['rec','cor'].includes(fresh.state))){
|
||||||
@@ -603,10 +606,10 @@ async function saveFinalFiles(order, files, note){
|
|||||||
// these finals: the person already confirmed them, so try once more with
|
// these finals: the person already confirmed them, so try once more with
|
||||||
// the fresh version; the server checks everything again (Sentry DTF-WEB-7).
|
// the fresh version; the server checks everything again (Sentry DTF-WEB-7).
|
||||||
if(fresh&&!fresh.cancelled_at){
|
if(fresh&&!fresh.cancelled_at){
|
||||||
await api('/orders/'+order.id+'/final-files',{version:fresh.version,files,note});
|
await api(path,{version:fresh.version,files,note});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
throw error;
|
throw reportRefusal(path,error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// A customer's correction or an original may not be the transparent 300 DPI
|
// A customer's correction or an original may not be the transparent 300 DPI
|
||||||
|
|||||||
@@ -716,14 +716,16 @@ async function pullTo(order, machineId){
|
|||||||
// it still waits in Arte conferida, pull once more with the fresh version;
|
// it still waits in Arte conferida, pull once more with the fresh version;
|
||||||
// the server checks everything again (Sentry DTF-WEB-K, as DTF-WEB-7).
|
// the server checks everything again (Sentry DTF-WEB-K, as DTF-WEB-7).
|
||||||
async function pullMove(order,target){
|
async function pullMove(order,target){
|
||||||
|
const path='/orders/'+order.id+'/move';
|
||||||
try{
|
try{
|
||||||
await move(order,'imp','',target);
|
// The first 409 is answered below, so it is not reported (as saveFinalFiles).
|
||||||
|
await move(order,'imp','',target,{expected:[409]});
|
||||||
}catch(error){
|
}catch(error){
|
||||||
if(error.status!==409||!String(error.message).startsWith('O pedido mudou'))throw error;
|
if(error.status!==409||!String(error.message).startsWith('O pedido mudou'))throw reportRefusal(path,error);
|
||||||
await load();
|
await load();
|
||||||
const fresh=(board.orders||[]).find(row=>row.id===order.id);
|
const fresh=(board.orders||[]).find(row=>row.id===order.id);
|
||||||
if(fresh?.state==='imp'&&fresh.machine?.id===target){say('O pedido já estava imprimindo nesta máquina.');return;}
|
if(fresh?.state==='imp'&&fresh.machine?.id===target){say('O pedido já estava imprimindo nesta máquina.');return;}
|
||||||
if(!fresh||fresh.cancelled_at||fresh.state!=='tra')throw error;
|
if(!fresh||fresh.cancelled_at||fresh.state!=='tra')throw reportRefusal(path,error);
|
||||||
await move(fresh,'imp','',target);
|
await move(fresh,'imp','',target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -894,6 +894,10 @@ select.inp{appearance:none;-webkit-appearance:none;padding-right:32px;background
|
|||||||
.gl{position:absolute;left:0;right:0;border-top:1px solid var(--ln2)}
|
.gl{position:absolute;left:0;right:0;border-top:1px solid var(--ln2)}
|
||||||
.avg{position:absolute;left:0;right:0;border-top:1.5px dashed var(--tx2);z-index:1;pointer-events:none}
|
.avg{position:absolute;left:0;right:0;border-top:1.5px dashed var(--tx2);z-index:1;pointer-events:none}
|
||||||
.axis{position:absolute;left:0;right:0;top:100%;display:grid;gap:4px;margin-top:8px;font-size:11.5px;color:var(--tx3);text-align:center;white-space:nowrap}
|
.axis{position:absolute;left:0;right:0;top:100%;display:grid;gap:4px;margin-top:8px;font-size:11.5px;color:var(--tx3);text-align:center;white-space:nowrap}
|
||||||
|
/* A date wider than its bar stays centred under it; the last one ends at the edge. */
|
||||||
|
.axis span{display:flex;justify-content:center}
|
||||||
|
.axis span.end{justify-content:flex-end}
|
||||||
|
.bars.dense,.axis.dense{gap:1px}
|
||||||
.charttable{padding:0 20px 16px;font-size:13px;color:var(--tx2)}
|
.charttable{padding:0 20px 16px;font-size:13px;color:var(--tx2)}
|
||||||
.charttable summary{cursor:pointer;width:max-content}
|
.charttable summary{cursor:pointer;width:max-content}
|
||||||
.charttable .table{margin-top:8px}
|
.charttable .table{margin-top:8px}
|
||||||
|
|||||||
@@ -265,6 +265,13 @@ async function api(path,body,options={}){
|
|||||||
}
|
}
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
// A 409 a caller expected (api's options.expected: [409]) and then could not
|
||||||
|
// answer is still reported, as api() would have; any other status api()
|
||||||
|
// already reported. Returns the error to rethrow.
|
||||||
|
function reportRefusal(path,error){
|
||||||
|
if(error?.status===409)window.dtfObservability?.apiError?.(path,error.status,error.message);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
function download(uid,orderId){return async()=>{
|
function download(uid,orderId){return async()=>{
|
||||||
const result=await api('/uploads/'+uid+'/download'+(orderId?'?order_id='+encodeURIComponent(orderId):''));
|
const result=await api('/uploads/'+uid+'/download'+(orderId?'?order_id='+encodeURIComponent(orderId):''));
|
||||||
const link=node('a');link.href=result.url;link.referrerPolicy='no-referrer';link.download=result.name;link.click();
|
const link=node('a');link.href=result.url;link.referrerPolicy='no-referrer';link.download=result.name;link.click();
|
||||||
|
|||||||
Reference in New Issue
Block a user