forked from duneanalytics/DuneQueryRepo
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path4974-9163be238c7cfc24.js.download
2 lines (2 loc) · 12.3 KB
/
4974-9163be238c7cfc24.js.download
1
2
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4974],{56446:function(e,r,n){n.d(r,{ec:function(){return l},Kj:function(){return h},u$:function(){return s},wX:function(){return c},UV:function(){return a},Sq:function(){return f.S},Y3:function(){return m},mB:function(){return d}});var t=n(31269),u=n(84512),o=n(40551);let a=["Minute","Hour","Day","Week"],i=["15 minutes","20 minutes","30 minutes","1 hour","2 hours","3 hours","4 hours","6 hours","8 hours","12 hours","Day","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];function s(e){switch(e){case"Minute":return["15 minutes","20 minutes","30 minutes"];case"Hour":return["1 hour","2 hours","3 hours","4 hours","6 hours","8 hours","12 hours"];case"Day":return["Day"];case"Week":return["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];default:(0,o.U)(e)}}function c(e){return/^\d+ \d+/.test(e)}function d(e){if(/^\d+ \d+ \* \* \*$/.test(e))return"Day";if(/^\d+ \d+ \* \* \d+$/.test(e)){let r=Number(e.split(" ").slice(-1)[0]),n=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][r];return n}return i.find(function(e){let r=(0,u.BU)(e);return n=>{let u=y(e,n);return(0,t.qP)(u).every(e=>{let[n,t]=e;return r[n]===t})}}(e))}function l(e,r){return(0,u.n1)(e)(y(e,r))}function y(e,r){let n=c(e)?{}:h();switch(r){case"15 minutes":return{minute:"*/15",hour:"*",weekday:"*"};case"20 minutes":return{minute:"*/20",hour:"*",weekday:"*"};case"30 minutes":return{minute:"*/30",hour:"*",weekday:"*"};case"1 hour":return{minute:"0",hour:"*",weekday:"*"};case"2 hours":return{minute:"0",hour:"*/2",weekday:"*"};case"3 hours":return{minute:"0",hour:"*/3",weekday:"*"};case"4 hours":return{minute:"0",hour:"*/4",weekday:"*"};case"6 hours":return{minute:"0",hour:"*/6",weekday:"*"};case"8 hours":return{minute:"0",hour:"*/8",weekday:"*"};case"12 hours":return{minute:"0",hour:"*/12",weekday:"*"};case"Day":return{weekday:"*",...n};case"Sunday":return{weekday:"0",...n};case"Monday":return{weekday:"1",...n};case"Tuesday":return{weekday:"2",...n};case"Wednesday":return{weekday:"3",...n};case"Thursday":return{weekday:"4",...n};case"Friday":return{weekday:"5",...n};case"Saturday":return{weekday:"6",...n}}}function h(){return{minute:30>new Date().getMinutes()?"0":"30",hour:"".concat(new Date().getHours())}}var f=n(44917);function m(e){switch(e){case"15 minutes":return"15 minutes";case"20 minutes":return"20 minutes";case"30 minutes":return"30 minutes";case"1 hour":return"hour";case"2 hours":return"2 hours";case"3 hours":return"3 hours";case"4 hours":return"4 hours";case"6 hours":return"6 hours";case"8 hours":return"8 hours";case"12 hours":return"12 hours";case"Day":return"day";case"Monday":return"Monday";case"Tuesday":return"Tuesday";case"Wednesday":return"Wednesday";case"Thursday":return"Thursday";case"Friday":return"Friday";case"Saturday":return"Saturday";case"Sunday":return"Sunday";default:(0,o.U)(e)}}},44917:function(e,r,n){n.d(r,{S:function(){return u}});var t=n(40551);function u(e){switch(e){case"15 minutes":return"15m";case"20 minutes":return"20m";case"30 minutes":return"30m";case"1 hour":return"1h";case"2 hours":return"2h";case"3 hours":return"3h";case"4 hours":return"4h";case"6 hours":return"6h";case"8 hours":return"8h";case"12 hours":return"12h";case"Day":return"Daily";case"Monday":return"Mondays";case"Tuesday":return"Tuesdays";case"Wednesday":return"Wednesdays";case"Thursday":return"Thursdays";case"Friday":return"Fridays";case"Saturday":return"Saturdays";case"Sunday":return"Sundays";default:(0,t.U)(e)}}},59085:function(e,r,n){n.d(r,{ph:function(){return C},e_:function(){return B},L5:function(){return E},Kv:function(){return P},kf:function(){return J},TC:function(){return b},K6:function(){return $},Z0:function(){return l},jA:function(){return f},ru:function(){return p},lp:function(){return w},nG:function(){return q},hc:function(){return j},kS:function(){return F},J0:function(){return K},SO:function(){return U},AE:function(){return W},Kl:function(){return L}});var t=n(82729),u=n(39137),o=n(40802),a=n(45172),i=n(84937),s=n(61575),c=n(56446);function d(){let e=(0,t._)(["\n mutation CreateQuerySchedule(\n $query_id: Int!\n $cron_expression: String!\n $performance: String!\n ) {\n createQuerySchedule(\n queryId: $query_id\n cronExpression: $cron_expression\n performance: $performance\n ) {\n queryId\n cronJob {\n id\n }\n }\n }\n"]);return d=function(){return e},e}function l(){let[e,r]=(0,i.P4R)();return[function(n,t,u){return new Promise((0,s.Yd)(n)||r.loading?()=>{}:r=>{e({context:{session:n},variables:{query_id:t,cron_expression:u.cronString,performance:u.performanceTier},refetchQueries:[$(n,t)]}).then(e=>{var n;let{data:o}=e;if(a.Z.trackEvent("Query Schedule Created",{query_id:t,interval:null!==(n=(0,c.mB)(u.cronString))&&void 0!==n?n:u.cronString,performance:u.performanceTier}),(0,s.C_)(o))r(o.createQuerySchedule.cronJob.id);else throw Error("Unable to retrieve query schedule after creation")},e=>{o.Tb("Failed to create query schedule: "+e.message)})})},r]}(0,u.Z)(d());var y=n(40551);function h(){let e=(0,t._)(["\n mutation DeleteQueryAlert($id: String!) {\n deleteAlert(id: $id) {\n ok\n }\n }\n"]);return h=function(){return e},e}function f(){let[e,r]=(0,i.xRS)();return[function(n,t,u){return new Promise((0,s.Yd)(n)||r.loading?()=>{}:r=>{e({context:{session:n},variables:{id:t},update:(e,r)=>{let{data:n}=r;function o(r){e.evict({id:e.identify({__typename:r,id:t})}),e.gc()}if((0,s.C_)(n)&&n.deleteAlert.ok)switch(u){case"email":o("QueryEmailAlert");break;case"slack":o("QuerySlackAlert");break;case"discord":o("QueryDiscordAlert");break;case"webhook":o("QueryWebhookAlert");break;default:(0,y.U)(u)}}}).then(()=>{r()},e=>{o.Tb("Failed to delete ".concat(u," query alert: ").concat(e.message))})})},r]}function m(){let e=(0,t._)(["\n mutation DeleteQuerySchedule($cron_job_id: String!) {\n deleteQuerySchedule(cronJobId: $cron_job_id) {\n cron_job_id: cronJobId\n }\n }\n"]);return m=function(){return e},e}function p(){let[e,r]=(0,i.CFe)();return[function(n,t){return new Promise((0,s.Yd)(n)||r.loading?()=>{}:r=>{e({context:{session:n},variables:{cron_job_id:t.scheduleId},refetchQueries:[$(n,t.queryId)]}).then(()=>{r()},e=>{e.message="Failed to delete query schedule: "+e.message,o.Tb(e)})})},r]}function k(){let e=(0,t._)(["\n query QueryAlerts($cronJobId: String!) {\n queryAlerts(cronJobId: $cronJobId) {\n email {\n id\n emails\n }\n slack {\n id\n url\n }\n discord {\n id\n url\n }\n webhook {\n id\n url\n dataFieldName\n httpHeaders\n jsonPayloadFields\n }\n }\n }\n"]);return k=function(){return e},e}(0,u.Z)(h()),(0,u.Z)(m());let b=(e,r)=>({query:i.J6b,variables:{cronJobId:r},context:{session:e}}),w=(e,r)=>{var n;let t=(0,i.V7j)({skip:(0,s.Yd)(r),...b(e,r)});return null===(n=t.data)||void 0===n?void 0:n.queryAlerts};(0,u.Z)(k());var _=n(76138),S=n(18172),g=n(84512),v=n(83267),Q=n(35560);function x(){let e=(0,t._)(["\n query QuerySchedules($query_id: Int!) {\n query(id: $query_id) {\n id\n schedules {\n id\n cronExpression\n performance\n nextExecutionTime\n ownedByCustomerId\n metadata {\n updatedAt\n }\n }\n }\n }\n"]);return x=function(){return e},e}function q(e,r,n){var t,u;let o=(0,i.EC8)({skip:!r,context:{session:r},variables:{query_id:e},fetchPolicy:null==n?void 0:n.fetchPolicy});if(o.loading)return{loading:!0};let a=null===(u=o.data)||void 0===u?void 0:null===(t=u.query.schedules)||void 0===t?void 0:t[0];return(0,s.C_)(a)&&(0,s.C_)(a.cronExpression)&&(0,g.fN)(a.cronExpression)&&(0,s.C_)(a.performance)&&(0,Q.U)(a.performance)&&(0,s.C_)(a.ownedByCustomerId)?{loading:!1,schedule:{id:a.id,cronString:a.cronExpression,performanceTier:a.performance,owner:v.Qc(a.ownedByCustomerId),updatedAt:a.metadata.updatedAt}}:{loading:!1}}function $(e,r){return{context:{session:e},query:i.xKO,variables:{query_id:r}}}function C(e){!function(e,r){let n=_.bj.cache.readQuery({query:i.xKO,variables:{query_id:e}});n&&_.bj.cache.writeQuery({query:i.xKO,variables:{query_id:e},data:(0,S.ZP)(n,r)})}(e,e=>{e.query.schedules=[]})}(0,u.Z)(x());var T=n(45466),A=n(38960);function j(e,r,n){let t=(0,T.gh)(e);return function(r){switch(r.type){case"user":return(0,A.r)(e);case"team":{let e=t.find(e=>e.id===r.id);if(!e)return;return(0,A.S)(e)}}}(r?r.owner:n)}function I(){let e=(0,t._)(["\n mutation UpdateQuerySchedule(\n $cron_job_id: String!\n $cron_expression: String!\n $performance: String!\n ) {\n updateQuerySchedule(\n cronJobId: $cron_job_id\n cronExpression: $cron_expression\n performance: $performance\n ) {\n query_id: queryId\n }\n }\n"]);return I=function(){return e},e}function F(){let[e,r]=(0,i.QaB)();return[function(n,t,u){return new Promise((0,s.Yd)(n)||r.loading?()=>{}:r=>{e({context:{session:n},variables:{cron_job_id:t.scheduleId,cron_expression:u.cronString,performance:u.performanceTier},refetchQueries:[$(n,t.queryId)]}).then(()=>{r()},e=>{e.message="Failed to update query schedule: "+e.message,o.Tb(e)})})},r]}function D(){let e=(0,t._)(["\n mutation UpsertQueryEmailAlert($input: UpsertQueryEmailAlertInput!) {\n upsertQueryEmailAlert(input: $input) {\n id\n }\n }\n"]);return D=function(){return e},e}(0,u.Z)(I());let E=e=>(0,s.C_)(e.alerts.emails);function U(){let[e,r]=(0,i.v0F)();return[function(n,t,u,a){return new Promise((0,s.Yd)(n)||r.loading?()=>{}:r=>{e({context:{session:n},variables:{input:{cronJobId:t,id:u,emails:a.alerts.emails}},refetchQueries:[b(n,t)]}).then(()=>{r()},e=>{o.Tb("Failed to upsert query email alert: "+e.message)})})},r]}function M(){let e=(0,t._)(["\n mutation UpsertQuerySlackAlert($input: UpsertQuerySlackAlertInput!) {\n upsertQuerySlackAlert(input: $input) {\n id\n }\n }\n"]);return M=function(){return e},e}(0,u.Z)(D());let P=e=>(0,s.C_)(e.alerts.slack);function W(){let[e,r]=(0,i.Q2r)();return[function(n,t,u,a){return new Promise((0,s.Yd)(n)||r.loading?()=>{}:r=>{e({context:{session:n},variables:{input:{cronJobId:t,id:u,url:a.alerts.slack}},refetchQueries:[b(n,t)]}).then(()=>{r()},e=>{o.Tb("Failed to upsert query Slack alert: "+e.message)})})},r]}function Z(){let e=(0,t._)(["\n mutation UpsertQueryWebhookAlert($input: UpsertQueryWebhookAlertInput!) {\n upsertQueryWebhookAlert(input: $input) {\n id\n }\n }\n"]);return Z=function(){return e},e}(0,u.Z)(M());let J=e=>(0,s.C_)(e.alerts.webhook);function L(){let[e,r]=(0,i.OB$)();return[function(n,t,u,a){return new Promise((0,s.Yd)(n)||r.loading?()=>{}:r=>{e({context:{session:n},variables:{input:{cronJobId:t,id:u,url:a.alerts.webhook,dataFieldName:"message",httpHeaders:{},jsonPayloadFields:{}}},refetchQueries:[b(n,t)]}).then(()=>{r()},e=>{o.Tb("Failed to upsert query webhook alert: "+e.message)})})},r]}function Y(){let e=(0,t._)(["\n mutation UpsertQueryDiscordAlert($input: UpsertQueryDiscordAlertInput!) {\n upsertQueryDiscordAlert(input: $input) {\n id\n }\n }\n"]);return Y=function(){return e},e}(0,u.Z)(Z());let B=e=>(0,s.C_)(e.alerts.discord);function K(){let[e,r]=(0,i.ziE)();return[function(n,t,u,a){return new Promise((0,s.Yd)(n)||r.loading?()=>{}:r=>{e({context:{session:n},variables:{input:{cronJobId:t,id:u,url:a.alerts.discord}},refetchQueries:[b(n,t)]}).then(()=>{r()},e=>{o.Tb("Failed to upsert query Discord alert: "+e.message)})})},r]}(0,u.Z)(Y())},5505:function(e,r,n){n.r(r),n.d(r,{IconClockHistory:function(){return u}});var t=n(85893);function u(){return(0,t.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,t.jsx)("path",{d:"M3.52779 4C4.62643 2.7725 6.223 2 8 2C11.3137 2 14 4.68629 14 8C14 9.52167 13.4335 10.911 12.5 11.9687",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:"2 2"}),(0,t.jsx)("path",{d:"M3.52779 4C2.57771 5.06151 2 6.46329 2 8C2 11.3137 4.68629 14 8 14C9.79204 14 11.4006 13.2144 12.5 11.9687",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8 5V8",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M10.6 9.5L8 8",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]})}},40551:function(e,r,n){n.d(r,{U:function(){return t}});function t(e){throw Error("Unreachable code reached")}}}]);
//# sourceMappingURL=4974-9163be238c7cfc24.js.map