@corva/ui 0.27.0-6 → 0.27.0-7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"@babel/runtime/helpers/defineProperty";import"../../../constants/completion.js";import"../../../constants/alerts.js";import{get as
|
|
1
|
+
import t from"@babel/runtime/helpers/defineProperty";import"../../../constants/completion.js";import"../../../constants/alerts.js";import{get as e,sortBy as r,omit as n}from"lodash";import a from"@babel/runtime/helpers/slicedToArray";import"../../../constants/goals.js";import"../../../constants/segment.js";import"../../../constants/apps.js";import"../../../constants/drillstring.js";import{DRILLING_WELL_SUMMARY as s,COMPLETION_WELL_SUMMARY as i,DRILLOUT_WELL_SUMMARY as c}from"../../../constants/wellSummary.js";import{RIG_ACTIVITY_COLORS as o}from"../../../constants/rigActivity.js";import u from"@babel/runtime/regenerator";import p from"@babel/runtime/helpers/asyncToGenerator";import{useState as l,useEffect as f}from"react";import{getWell as m,getAppStorage as d}from"../../../clients/jsonApi/index.js";function v(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function h(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?v(Object(n),!0).forEach((function(r){t(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):v(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function b(t){return y.apply(this,arguments)}function y(){return(y=p(u.mark((function t(r){var n,a;return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all(r.map(function(){var t=p(u.mark((function t(r){var n;return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,d("corva","activities.summary-continuous",r,{fields:["data.activities","data.start_timestamp","data.end_timestamp"].join(","),limit:1,query:"{timestamp#lte#".concat(Math.floor(Date.now()/1e3),"}"),sort:"{timestamp:-1}"});case 3:return n=t.sent,t.abrupt("return",(e(n,"0.data.activities")||[]).map((function(t){return h(h({},t),{},{duration:(t.day||0)+(t.night||0),color:o[t.name]})})));case 7:t.prev=7,t.t0=t.catch(0),console.error(t.t0);case 10:return t.abrupt("return",[]);case 11:case"end":return t.stop()}}),t,null,[[0,7]])})));return function(e){return t.apply(this,arguments)}}()));case 2:return n=t.sent,a={},n.forEach((function(t,e){a[r[e]]=t})),t.abrupt("return",a);case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function g(t,e,r,n){return w.apply(this,arguments)}function w(){return(w=p(u.mark((function t(a,s,i,c){var o,p;return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,d("corva",s,a,{aggregate:JSON.stringify([{$match:{asset_id:a,timestamp:{$lte:i,$gte:i-86400}}},{$project:{_id:-1,stage_number:1,data:1,timestamp:1}},{$group:{_id:"$stage_number",timestamp:{$first:"$timestamp"},stage_number:{$last:"$stage_number"},first_data:{$first:"$data"},last_data:{$last:"$data"}}}])});case 3:return o=t.sent,p=0,r(o,"timestamp").forEach((function(t,r){if(0===r){var a=n(e(t,"first_data"),c),s=n(e(t,"last_data"),c);Object.keys(s).forEach((function(t){p+=s[t]-(a[t]||0)}))}else{var i=n(e(t,"last_data"),c);Object.keys(i).forEach((function(t){p+=i[t]}))}})),t.abrupt("return",p);case 9:t.prev=9,t.t0=t.catch(0),console.error(t.t0);case 12:return t.abrupt("return",0);case 13:case"end":return t.stop()}}),t,null,[[0,9]])})))).apply(this,arguments)}function j(t){return x.apply(this,arguments)}function x(){return(x=p(u.mark((function t(r){var n,s;return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all(r.map(function(){var t=p(u.mark((function t(r){var n,s,i,c,o,p,l,f,m,v,h;return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.t0=Promise,t.next=4,d("corva","completion.wits",r,{limit:1,fields:"timestamp"});case 4:return t.t1=t.sent,t.next=7,d("corva","wireline.wits",r,{limit:1,fields:"timestamp"});case 7:return t.t2=t.sent,t.t3=[t.t1,t.t2],t.next=11,t.t0.all.call(t.t0,t.t3);case 11:if(n=t.sent,s=a(n,2),i=s[0],c=s[1],o=e(i,"0.timestamp"),p=e(c,"0.timestamp"),l=null,o&&p?l=o>p?o:p:o?l=o:p&&(l=p),l){t.next=21;break}return t.abrupt("return",[]);case 21:return t.next=23,Promise.all([g(r,"completion.activity.summary-stage",l,["activities"]),g(r,"wireline.activity.summary-stage",l,["durations"])]);case 23:return f=t.sent,m=a(f,2),v=m[0],h=m[1],t.abrupt("return",[{name:"frac",duration:v,color:"#7177FF"},{name:"wireline",duration:h,color:"#FF9C00"}]);case 30:t.prev=30,t.t4=t.catch(0),console.error(t.t4);case 33:return t.abrupt("return",[]);case 34:case"end":return t.stop()}}),t,null,[[0,30]])})));return function(e){return t.apply(this,arguments)}}()));case 2:return n=t.sent,s={},n.forEach((function(t,e){s[r[e]]=t})),t.abrupt("return",s);case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function _(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=l(!0),o=a(n,2),v=o[0],y=o[1],g=l({}),w=a(g,2),x=w[0],_=w[1],O=l(!0),$=a(O,2),k=$[0],P=$[1],E=l({}),S=a(E,2),D=S[0],F=S[1],A="drilling"===e;return f((function(){function n(){return(n=p(u.mark((function e(){var n,a,o,p,l,f,v,b,g,w,j;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=(r||Object.values(A?s:h(h({},i),c))).filter((function(t){return t.dataSource&&t.dataSource.length})),a=[],n.forEach((function(t){t.dataSource.forEach((function(t){var e=t.provider,r=t.collection,n=t.fields;e&&r&&n&&n.length?n.forEach((function(t){return a.push("".concat(e,"#").concat(r,".").concat(t))})):r&&a.push(r)}))})),a.push("well_id"),e.prev=4,l={asset_id:{$in:t}},f=a.reduce((function(t,e){return t[e]=1,t}),{asset_id:1}),v={aggregate:JSON.stringify([{$match:l},{$project:f}])},e.next=10,d("corva","well_cache",null,v);case 10:return b=e.sent,e.next=13,m(b[0].well_id,{fields:"well.last_active_at"});case 13:g=e.sent,w=Date.parse(null===(o=g.data)||void 0===o||null===(p=o.attributes)||void 0===p?void 0:p.last_active_at)/1e3,j={},b.forEach((function(t){var e=t.asset_id;j[e]=t,j[e]["corva#wits"].timestamp=w})),_(j),e.next=23;break;case 20:e.prev=20,e.t0=e.catch(4),console.error(e.t0);case 23:y(!1);case 24:case"end":return e.stop()}}),e,null,[[4,20]])})))).apply(this,arguments)}function a(){return(a=p(u.mark((function r(){var n;return u.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(r.prev=0,"drilling"!==e){r.next=7;break}return r.next=4,b(t);case 4:r.t0=r.sent,r.next=10;break;case 7:return r.next=9,j(t);case 9:r.t0=r.sent;case 10:n=r.t0,F(n),r.next=17;break;case 14:r.prev=14,r.t1=r.catch(0),console.error(r.t1);case 17:P(!1);case 18:case"end":return r.stop()}}),r,null,[[0,14]])})))).apply(this,arguments)}y(!0),P(!0),function(){n.apply(this,arguments)}(),function(){a.apply(this,arguments)}()}),[]),[v||k,x,D]}export{_ as useWellSummaryData};
|