Skip to content

Commit

Permalink
fix progress task
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushgaud committed Nov 15, 2023
1 parent 4096cdb commit 07f45d9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
19 changes: 9 additions & 10 deletions resources/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12348,27 +12348,26 @@ wrike_ist.wrike.is_wrike_task_in_folder_QMARK_=function(a){return wrike_ist.wrik
cljs.core.chunk_first(l),n=cljs.core.count(m),p=cljs.core.chunk_buffer(n);a:for(var q=0;;)if(q<n){var r=cljs.core._nth(m,q);r=wrike_ist.wrike.fetch_folder_details(r,wrike_ist.wrike.folder_names);cljs.core.chunk_append(p,r);q+=1}else{m=!0;break a}return m?cljs.core.chunk_cons(cljs.core.chunk(p),k(cljs.core.chunk_rest(l))):cljs.core.chunk_cons(cljs.core.chunk(p),null)}p=cljs.core.first(l);p=wrike_ist.wrike.fetch_folder_details(p,wrike_ist.wrike.folder_names);return cljs.core.cons(p,k(cljs.core.rest(l)))}return null}},
null,null)}(f)}();Promise.all(b);return Promise.all(b).then(function(g){if(cljs.core.truth_(cljs.core.some(cljs.core.true_QMARK_,g)))return console.info("is-wrike-task-in-folder?: Matching folders found"),!0;console.info("is-wrike-task-in-folder?: Task is not a valid bug ticket of part of a planned release");return!1})})};
wrike_ist.wrike.check_valid_task=function(a,b){return new Promise(function(c,d){if(cljs.core.truth_(cljs.core.truth_(b)?clojure.string.starts_with_QMARK_(b,"release"):b))return console.info("check-valid-task: PR is targeted to release branch, checking if task is a valid bug ticket or part of planned releases"),wrike_ist.wrike.is_wrike_task_in_folder_QMARK_(a).then(function(e){if(cljs.core.truth_(e))return console.info("check-valid-task: Task is in the folder or an inherited folder: true"),c.cljs$core$IFn$_invoke$arity$1?
c.cljs$core$IFn$_invoke$arity$1(a):c.call(null,a);console.error("check-valid-task: Task not found in folder");e=Error("check-valid-task: Task not found in folder");return d.cljs$core$IFn$_invoke$arity$1?d.cljs$core$IFn$_invoke$arity$1(e):d.call(null,e)});console.info("check-valid-task: PR is not targeted to release branch, returning success");return c.cljs$core$IFn$_invoke$arity$1?c.cljs$core$IFn$_invoke$arity$1(a):c.call(null,a)})};
c.cljs$core$IFn$_invoke$arity$1(a):c.call(null,a);console.error("check-valid-task: Task not found in folder");e=Error("check-valid-task: Task not found in folder");return d.cljs$core$IFn$_invoke$arity$1?d.cljs$core$IFn$_invoke$arity$1(e):d.call(null,e)});console.info("check-valid-task: PR is not targeted to release branch, returning success");return c.cljs$core$IFn$_invoke$arity$1?c.cljs$core$IFn$_invoke$arity$1(!0):c.call(null,!0)})};
wrike_ist.wrike.link_pr=function(a){var b=cljs.core.__destructure_map(a),c=cljs.core.get.cljs$core$IFn$_invoke$arity$2(b,cljs$cst$206$pr_url);a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(b,cljs$cst$210$permalink);var d=cljs.core.get.cljs$core$IFn$_invoke$arity$2(b,cljs$cst$207$target_branch),e=wrike_ist.wrike.check_valid_task(a,d);return wrike_ist.wrike.find_task(a).then(function(f){f=cljs.core.__destructure_map(f);f=cljs.core.get.cljs$core$IFn$_invoke$arity$2(f,"id");var g=["https://www.wrike.com/api/v4/tasks/",
cljs.core.str.cljs$core$IFn$_invoke$arity$1(f),"/comments"].join("");return httpurr.client.node.get(g,new cljs.core.PersistentArrayMap(null,1,[cljs$cst$183$headers,wrike_ist.wrike.headers()],null)).then(function(h){return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(function(k,l){return cljs.core.truth_(cljs.core.get.cljs$core$IFn$_invoke$arity$2(l,"text").includes(c))?cljs.core.reduced(Promise.reject(cljs$cst$211$present)):k},Promise.resolve(),cljs.core.get.cljs$core$IFn$_invoke$arity$2(wrike_ist.wrike.parse_body(h),
"data"))}).then(function(){var h=function(l){l=wrike_ist.wrike.link_html(b);l=cljs.core.clj__GT_js(new cljs.core.PersistentArrayMap(null,2,[cljs$cst$212$text,l,cljs$cst$213$plainText,!1],null));return httpurr.client.node.post(g,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$183$headers,wrike_ist.wrike.headers(),cljs$cst$184$body,JSON.stringify(l)],null))},k=function(l){var m=null;if(0<arguments.length){m=0;for(var n=Array(arguments.length-0);m<n.length;)n[m]=arguments[m+0],++m;m=new cljs.core.IndexedSeq(n,
0,null)}return h.call(this,m)};k.cljs$lang$maxFixedArity=0;k.cljs$lang$applyTo=function(l){l=cljs.core.seq(l);return h(l)};k.cljs$core$IFn$_invoke$arity$variadic=h;return k}()).then(function(h){console.log("link-pr: PR link sent to task");return Promise.resolve()}).catch(function(h){return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(h,cljs$cst$211$present)?console.log("link-pr: PR link already in comments"):Promise.resolve(h)})}).then(function(f){return Promise.all(new cljs.core.PersistentVector(null,
2,5,cljs.core.PersistentVector.EMPTY_NODE,[e,e.then(function(g){return console.log(["check-valid-task-promise value: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(g)].join(""))})],null))}).catch(function(f){return Promise.reject(f)})};
2,5,cljs.core.PersistentVector.EMPTY_NODE,[e,e.then(function(g){return console.log(["check-valid-task-promise value: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(g)].join(""))})],null))}).catch(function(f){console.log(["link-pr: Rejected with reason: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(f)].join(""));return Promise.reject(f)})};
wrike_ist.wrike.folder_statuses=function(a){a=["https://www.wrike.com/api/v4/folders/",cljs.core.str.cljs$core$IFn$_invoke$arity$1(a)].join("");return httpurr.client.node.get(a,new cljs.core.PersistentArrayMap(null,1,[cljs$cst$183$headers,wrike_ist.wrike.headers()],null)).then(wrike_ist.wrike.parse_body).then(function(b){b=cljs.core.__destructure_map(b);b=cljs.core.get.cljs$core$IFn$_invoke$arity$2(b,"data");b=cljs.core.nth.cljs$core$IFn$_invoke$arity$3(b,0,null);b=cljs.core.__destructure_map(b);
var c=cljs.core.get.cljs$core$IFn$_invoke$arity$2(b,"workflowId");return httpurr.client.node.get("https://www.wrike.com/api/v4/workflows",new cljs.core.PersistentArrayMap(null,1,[cljs$cst$183$headers,wrike_ist.wrike.headers()],null)).then(wrike_ist.wrike.parse_body).then(function(d){d=cljs.core.__destructure_map(d);d=cljs.core.get.cljs$core$IFn$_invoke$arity$2(d,"data");return cljs.core.first(cljs.core.filter.cljs$core$IFn$_invoke$arity$2(function(e){return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs.core.get.cljs$core$IFn$_invoke$arity$2(e,
"id"),c)},d))})}).then(function(b){b=cljs.core.__destructure_map(b);b=cljs.core.get.cljs$core$IFn$_invoke$arity$2(b,"customStatuses");return cljs.core.filter.cljs$core$IFn$_invoke$arity$2(function(c){return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs.core.get.cljs$core$IFn$_invoke$arity$2(c,"hidden"),!1)},b)})};
var c=cljs.core.get.cljs$core$IFn$_invoke$arity$2(b,"workflowId");return Promise.resolve(httpurr.client.node.get("https://www.wrike.com/api/v4/workflows",new cljs.core.PersistentArrayMap(null,1,[cljs$cst$183$headers,wrike_ist.wrike.headers()],null)).then(wrike_ist.wrike.parse_body).then(function(d){d=cljs.core.__destructure_map(d);d=cljs.core.get.cljs$core$IFn$_invoke$arity$2(d,"data");return cljs.core.first(cljs.core.filter.cljs$core$IFn$_invoke$arity$2(function(e){return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs.core.get.cljs$core$IFn$_invoke$arity$2(e,
"id"),c)},d))}))}).then(function(b){b=cljs.core.__destructure_map(b);b=cljs.core.get.cljs$core$IFn$_invoke$arity$2(b,"customStatuses");return cljs.core.filter.cljs$core$IFn$_invoke$arity$2(function(c){return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs.core.get.cljs$core$IFn$_invoke$arity$2(c,"hidden"),!1)},b)})};
wrike_ist.wrike.find_status=function(a,b){b=cljs.core.__destructure_map(b);var c=cljs.core.get.cljs$core$IFn$_invoke$arity$2(b,cljs$cst$214$wanted_status),d=cljs.core.get.cljs$core$IFn$_invoke$arity$2(b,cljs$cst$215$wanted_group);return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(function(e,f){e=cljs.core.__destructure_map(e);var g=cljs.core.get.cljs$core$IFn$_invoke$arity$2(e,"group");f=cljs.core.__destructure_map(f);var h=cljs.core.get.cljs$core$IFn$_invoke$arity$2(f,"name"),k=cljs.core.get.cljs$core$IFn$_invoke$arity$2(f,
"group");return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(h,c)?cljs.core.reduced(f):cljs.core.truth_(d)?cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(g,d)?e:cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(k,d)?f:null:null},null,a)};wrike_ist.wrike.next_status=function(a,b){return wrike_ist.wrike.folder_statuses(a).then(function(c){c=wrike_ist.wrike.find_status(c,b);return cljs.core.truth_(c)?c:Promise.reject(["next-status: No appropriate status found",cljs.core.str.cljs$core$IFn$_invoke$arity$1(b)].join(""))})};
wrike_ist.wrike.update_task_status=function(a,b){a=cljs.core.__destructure_map(a);var c=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,"id");a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,"parentIds");a=cljs.core.nth.cljs$core$IFn$_invoke$arity$3(a,0,null);return wrike_ist.wrike.next_status(a,b).then(function(d){d=cljs.core.__destructure_map(d);var e=cljs.core.get.cljs$core$IFn$_invoke$arity$2(d,"id");d=["https://www.wrike.com/api/v4/tasks/",cljs.core.str.cljs$core$IFn$_invoke$arity$1(c)].join("");
e=cljs.core.clj__GT_js(new cljs.core.PersistentArrayMap(null,1,[cljs$cst$216$customStatus,e],null));return httpurr.client.node.put(d,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$183$headers,wrike_ist.wrike.headers(),cljs$cst$184$body,JSON.stringify(e)],null))})};
wrike_ist.wrike.progress_task=function(a,b){a=cljs.core.__destructure_map(a);a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,cljs$cst$210$permalink);return cljs.core.truth_(cljs.core.not_empty(b))?wrike_ist.wrike.find_task(a).then(function(c){return wrike_ist.wrike.update_task_status(c,new cljs.core.PersistentArrayMap(null,1,[cljs$cst$214$wanted_status,b],null))}):null};
wrike_ist.wrike.complete_task=function(a,b){a=cljs.core.__destructure_map(a);a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,cljs$cst$210$permalink);return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2("-",b)?console.log('complete-task: Skipping `merged` transition because it\'s set to "-"'):wrike_ist.wrike.find_task(a).then(function(c){return wrike_ist.wrike.update_task_status(c,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$214$wanted_status,b,cljs$cst$215$wanted_group,"Completed"],null))})};
wrike_ist.wrike.cancel_task=function(a,b){a=cljs.core.__destructure_map(a);a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,cljs$cst$210$permalink);return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2("-",b)?console.log('cancel-task: Skipping `closed` transition because it\'s set to "-"'):wrike_ist.wrike.find_task(a).then(function(c){return wrike_ist.wrike.update_task_status(c,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$214$wanted_status,b,cljs$cst$215$wanted_group,"Cancelled"],null))})};wrike_ist.core={};wrike_ist.core.find_links=function(a){return cljs.core.not_empty(cljs.core.re_seq(/\bhttps:\/\/www\.wrike\.com\/open\.htm\?id=\d+\b/,a))};
wrike_ist.wrike.progress_task=function(a,b){a=cljs.core.__destructure_map(a);a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,cljs$cst$210$permalink);if(cljs.core.truth_(cljs.core.not_empty(b)))return wrike_ist.wrike.find_task(a).then(function(c){return wrike_ist.wrike.update_task_status(c,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$214$wanted_status,b,cljs$cst$215$wanted_group,"In Progress"],null))});console.log('Skipping `open` transition because it\'s set to "-"');return Promise.resolve()};
wrike_ist.wrike.complete_task=function(a,b){a=cljs.core.__destructure_map(a);a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,cljs$cst$210$permalink);return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2("-",b)?(console.log('Skipping `merged` transition because it\'s set to "-"'),Promise.resolve()):wrike_ist.wrike.find_task(a).then(function(c){return wrike_ist.wrike.update_task_status(c,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$214$wanted_status,b,cljs$cst$215$wanted_group,"Completed"],null))})};
wrike_ist.wrike.cancel_task=function(a,b){a=cljs.core.__destructure_map(a);a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,cljs$cst$210$permalink);return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2("-",b)?(console.log('Skipping `closed` transition because it\'s set to "-"'),Promise.resolve()):wrike_ist.wrike.find_task(a).then(function(c){return wrike_ist.wrike.update_task_status(c,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$214$wanted_status,b,cljs$cst$215$wanted_group,"Cancelled"],null))})};wrike_ist.core={};wrike_ist.core.find_links=function(a){return cljs.core.not_empty(cljs.core.re_seq(/\bhttps:\/\/www\.wrike\.com\/open\.htm\?id=\d+\b/,a))};
wrike_ist.core.extract_details=function(a){var b=a.body;if(cljs.core.truth_(b)&&(b=wrike_ist.core.find_links(b),cljs.core.truth_(b))){var c=a.merged?cljs$cst$217$merged:cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(a.state,"closed")?cljs$cst$218$closed:a.draft?cljs$cst$219$draft:cljs$cst$220$open,d=a.html_url,e=a.title,f=a.number,g=a.base.ref,h=a.head.repo.name;return cljs.core.map.cljs$core$IFn$_invoke$arity$2(function(k){return new cljs.core.PersistentArrayMap(null,7,[cljs$cst$221$state,c,cljs$cst$210$permalink,
k,cljs$cst$206$pr_url,d,cljs$cst$205$id,f,cljs$cst$209$title,e,cljs$cst$207$target_branch,g,cljs$cst$208$repository_name,h],null)},b)}return null};
wrike_ist.core.main=function(){var a=shadow.js.shim.module$$actions$github.context.payload,b=a.pull_request;if(cljs.core.truth_(b))for(var c=wrike_ist.core.extract_details(b);;){var d=cljs.core.first(c);if(cljs.core.truth_(d)){var e=d,f=cljs.core.__destructure_map(e),g=f,h=cljs.core.get.cljs$core$IFn$_invoke$arity$2(f,cljs$cst$221$state);(function(){var k=h;switch(k instanceof cljs.core.Keyword?k.fqn:null){case "draft":return wrike_ist.wrike.link_pr(g);case "open":return Promise.all(new cljs.core.PersistentVector(null,
2,5,cljs.core.PersistentVector.EMPTY_NODE,[wrike_ist.wrike.link_pr(g),wrike_ist.wrike.progress_task(g,shadow.js.shim.module$$actions$core.getInput("opened"))],null));case "merged":return wrike_ist.wrike.complete_task(g,shadow.js.shim.module$$actions$core.getInput("merged"));case "closed":return wrike_ist.wrike.cancel_task(g,shadow.js.shim.module$$actions$core.getInput("closed"));default:return Promise.resolve()}})().catch(function(k,l,m,n,p,q,r,t,v){return function(x){return shadow.js.shim.module$$actions$core.setFailed(x.message)}}(c,
e,f,g,h,d,b,b,a));c=cljs.core.rest(c)}else return null}else return console.log("No pull_request in payload")};cljs.core.apply.cljs$core$IFn$_invoke$arity$2(wrike_ist.core.main,process.argv.slice(2));
wrike_ist.core.main=function(){var a=shadow.js.shim.module$$actions$github.context.payload,b=a.pull_request;if(cljs.core.truth_(b))for(var c=wrike_ist.core.extract_details(b);;){var d=cljs.core.first(c);if(cljs.core.truth_(d)){var e=d,f=cljs.core.__destructure_map(e),g=f,h=cljs.core.get.cljs$core$IFn$_invoke$arity$2(f,cljs$cst$221$state);(function(){var k=h;switch(k instanceof cljs.core.Keyword?k.fqn:null){case "draft":return wrike_ist.wrike.link_pr(g);case "open":return wrike_ist.wrike.link_pr(g);
case "merged":return wrike_ist.wrike.complete_task(g,shadow.js.shim.module$$actions$core.getInput("merged"));case "closed":return wrike_ist.wrike.cancel_task(g,shadow.js.shim.module$$actions$core.getInput("closed"));default:return Promise.resolve()}})().catch(function(k,l,m,n,p,q,r,t,v){return function(x){return shadow.js.shim.module$$actions$core.setFailed(x.message)}}(c,e,f,g,h,d,b,b,a));c=cljs.core.rest(c)}else return null}else return console.log("No pull_request in payload")};cljs.core.apply.cljs$core$IFn$_invoke$arity$2(wrike_ist.core.main,process.argv.slice(2));
})();

})();
Expand Down
Loading

0 comments on commit 07f45d9

Please sign in to comment.