From e152907a942e347754d21b653539884a97d73c03 Mon Sep 17 00:00:00 2001 From: Makito Katsube Date: Sun, 14 Jan 2018 01:06:20 +0900 Subject: [PATCH 1/4] #11 modify checkRedmine.js (remove tab) --- GoogleAppsScript/checkRedmine.js | 86 ++++++++++++++++---------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/GoogleAppsScript/checkRedmine.js b/GoogleAppsScript/checkRedmine.js index a23c140..5609e9d 100644 --- a/GoogleAppsScript/checkRedmine.js +++ b/GoogleAppsScript/checkRedmine.js @@ -50,17 +50,17 @@ var CONFIG = { }; // CONFIG var DEFINE = { - //チケット名が長い場合に省略する - 'trim': { - 'enable': true // falseにすると省略しない - , 'len': 25 // 最大文字数 - , 'char': '…' // 置き換える文字(空文字列でもOK) - } - //チャットワーク関連 - , 'chatwork':{ - 'max_strlen': 65534 - , 'min_strlen': 0 - } + //チケット名が長い場合に省略する + 'trim': { + 'enable': true // falseにすると省略しない + , 'len': 25 // 最大文字数 + , 'char': '…' // 置き換える文字(空文字列でもOK) + } + //チャットワーク関連 + , 'chatwork':{ + 'max_strlen': 65534 + , 'min_strlen': 0 + } }; // DEFINE @@ -93,8 +93,8 @@ function executeMe(){ function checkRedmineTicket(target){ //validation if( target in CONFIG === false){ - Logger.log("[checkRedmineTicket] Error: undefined CONFIG(" + target + ")"); - return(false); + Logger.log("[checkRedmineTicket] Error: undefined CONFIG(" + target + ")"); + return(false); } var conf = CONFIG[target]; @@ -114,24 +114,24 @@ function checkRedmineTicket(target){ var member = conf.Member[i]; // Redmineからメンバーのチケット情報を取得 - var buff = getRedmineTicket(conf.Redmine, member.rd); - var tickets = buff.issues; - var total = buff.total_count; + var buff = getRedmineTicket(conf.Redmine, member.rd); + var tickets = buff.issues; + var total = buff.total_count; var len_t = tickets.length; // 担当者の設定なしチケット if(member.name === null){ - if(len_t === 0){ - continue; - } - else{ - message = "担当者が未設定のチケットがあるよ。\n\n"; - } - } + if(len_t === 0){ + continue; + } + else{ + message = "担当者が未設定のチケットがあるよ。\n\n"; + } + } // 担当者の設定ありチケット else{ - // 担当者へTo - message = "[To:"+ member.cw +"] "+ member.name + " さん\n"; + // 担当者へTo + message = "[To:"+ member.cw +"] "+ member.name + " さん\n"; message += member.name + " さんの担当しているチケットは全"+ total +"件だよ\n\n"; } @@ -142,10 +142,10 @@ function checkRedmineTicket(target){ var priority = tickets[j].priority.name; //通常、重要、急いで... var subject = tickets[j].subject; //チケット名 - // チケット名が長い場合は省略する - if( DEFINE.trim.enable ){ - subject = strimwidth(subject, DEFINE.trim.len, DEFINE.trim.char); - } + // チケット名が長い場合は省略する + if( DEFINE.trim.enable ){ + subject = strimwidth(subject, DEFINE.trim.len, DEFINE.trim.char); + } message += j+1 + ". ["+tracher+"] " + subject + "("+priority+") " + conf.Redmine.issueurl+id + "\n"; } @@ -225,12 +225,12 @@ function sendMessage(token, room_id, msg) { * @access public */ function strimwidth(str, width, trimmarker){ - if( str.length > width ){ - return( str.substr(0, width) + trimmarker ); - } - else{ - return(str); - } + if( str.length > width ){ + return( str.substr(0, width) + trimmarker ); + } + else{ + return(str); + } } /** @@ -242,12 +242,12 @@ function strimwidth(str, width, trimmarker){ * @access public */ function bytes2(str) { - if(typeof str !== 'string'){ - return(null); - } - if(str === ""){ - return(0); - } - - return(encodeURIComponent(str).replace(/%../g,"x").length); + if(typeof str !== 'string'){ + return(null); + } + if(str === ""){ + return(0); + } + + return(encodeURIComponent(str).replace(/%../g,"x").length); } From c7a958bf50b66066a67fc4b25056714f13dd68cc Mon Sep 17 00:00:00 2001 From: Makito Katsube Date: Sun, 14 Jan 2018 15:27:01 +0900 Subject: [PATCH 2/4] #12 modify checkRedmine.js (change DEFINE.chatwork.min_strlen) --- GoogleAppsScript/checkRedmine.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GoogleAppsScript/checkRedmine.js b/GoogleAppsScript/checkRedmine.js index 5609e9d..a337f12 100644 --- a/GoogleAppsScript/checkRedmine.js +++ b/GoogleAppsScript/checkRedmine.js @@ -59,7 +59,7 @@ var DEFINE = { //チャットワーク関連 , 'chatwork':{ 'max_strlen': 65534 - , 'min_strlen': 0 + , 'min_strlen': 1 } }; // DEFINE From a51cc55991b3a36e6580886ca3328d5831ae4ef1 Mon Sep 17 00:00:00 2001 From: Makito Katsube Date: Sun, 14 Jan 2018 15:40:46 +0900 Subject: [PATCH 3/4] #13 modify checkRedmine.js (change CONFIG.Redmine.sort, add due_date) --- GoogleAppsScript/checkRedmine.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GoogleAppsScript/checkRedmine.js b/GoogleAppsScript/checkRedmine.js index a337f12..e0c8ec7 100644 --- a/GoogleAppsScript/checkRedmine.js +++ b/GoogleAppsScript/checkRedmine.js @@ -19,7 +19,7 @@ var CONFIG = { , 'endpoint': 'https://redmine.example.com/issues.json' //Redmine APIエンドポイント , 'project': 'foo' //Redmine ProjectID , 'limit': 50 //Redmine 取得件数 - , 'sort': 'priority:desc' //Redmine ソート順 + , 'sort': 'priority:desc,due_date' //Redmine ソート順 , 'issueurl': 'https://redmine.example.com/issues/' //Redmine チケットのURL } , 'Member':[ From 8bf1a91f7a9f2d82319b0ab48031acb451139ec9 Mon Sep 17 00:00:00 2001 From: Makito Katsube Date: Sun, 14 Jan 2018 15:50:56 +0900 Subject: [PATCH 4/4] #10 modify checkRedmine.js (remove CONFIG.Redmine.endpoint|issueurl, add CONFIG.Redmine.urlbase) --- GoogleAppsScript/checkRedmine.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/GoogleAppsScript/checkRedmine.js b/GoogleAppsScript/checkRedmine.js index e0c8ec7..7fa5f70 100644 --- a/GoogleAppsScript/checkRedmine.js +++ b/GoogleAppsScript/checkRedmine.js @@ -16,11 +16,10 @@ var CONFIG = { , 'CW_ROOMID': '12345678' //ルームID , 'Redmine':{ 'token': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' //Redmine APIトークン - , 'endpoint': 'https://redmine.example.com/issues.json' //Redmine APIエンドポイント + , 'urlbase': 'https://redmine.example.com' //Redmineを設置したURL(最後にスラッシュを付加しない) , 'project': 'foo' //Redmine ProjectID , 'limit': 50 //Redmine 取得件数 , 'sort': 'priority:desc,due_date' //Redmine ソート順 - , 'issueurl': 'https://redmine.example.com/issues/' //Redmine チケットのURL } , 'Member':[ {'name':'foo', 'rd':1, 'cw':100001} //ユーザー名、Redmineでのid、ChatworkでのIDをセット @@ -96,9 +95,7 @@ function checkRedmineTicket(target){ Logger.log("[checkRedmineTicket] Error: undefined CONFIG(" + target + ")"); return(false); } - var conf = CONFIG[target]; - var len = conf.Member.length; //-------------------------------------------------- // 起動メッセージ @@ -109,6 +106,8 @@ function checkRedmineTicket(target){ //-------------------------------------------------- // メンバー数分チェック //-------------------------------------------------- + var len = conf.Member.length; + var issueurl = conf.Redmine.urlbase + '/issues/'; for(var i=0; i