From 6cdf7f293e5a5dd1fbb5fc335dec7dae5dce7007 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 29 Aug 2019 11:00:54 +0100 Subject: [PATCH] enable nagging and tidy a bit --- src/repeat.php | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/repeat.php b/src/repeat.php index 2145df7..a74fd9a 100755 --- a/src/repeat.php +++ b/src/repeat.php @@ -12,16 +12,18 @@ $terms=[ ]; /* create the labels */ -/* -foreach($terms as $k=>$vs){ - foreach($vs as $v){ - $label=$repo->getLabelByName($v); +foreach($terms as $group=>$names){ + foreach($names as $name){ + $label=$repo->getLabelByName($name); if(!$label){ - $label=$repo->createLabel(['name'=>$new_name,'color'=>'#ffff00','description'=>'Reopen this issue with the given frequency']); + $label=$repo->createLabel([ + 'name'=>$name, + 'color'=>'#ffff00', + 'description'=>'Reopen this issue with the given frequency' + ]); } } } -*/ //define the function to process each issue @@ -50,6 +52,16 @@ $monthly=function($issue) use ($terms){ //print_r(getRepeatTerms($issue,$terms)); //die(); if($month_closed!=$month_today){ + if($issue->state=="closed"){ + $issue->state='open'; + $issue->save(); + }else{ + $day_updated=date('z',strtotime($issue->updated_at)); + $day_today=date('z'); + if($day_updated!=$day_today){ + $issue->addComment("NAG!"); + } + } $issue->state='open'; $issue->save(); } @@ -97,8 +109,14 @@ function getRepeatTerms($issue,$terms){ $day_name=strtolower(date('l')); $month_name=strtolower(date('F')); -//$repo->forIssues($daily,['state'=>'open','labels'=>'daily/repeat']); -//die(); +// nag about open issues +$repo->forIssues($weekly,['labels'=>'weekly/repeat']); +$repo->forIssues($daily,['labels'=>'daily/repeat']); +$repo->forIssues($daily,['labels'=>$day_name.'/repeat']); +$repo->forIssues($monthly,['labels'=>'monthly/repeat']); +$repo->forIssues($monthly,['labels'=>$month_name.'/repeat']); + +// reopen closed issues $repo->forIssues($weekly,['state'=>'closed','labels'=>'weekly/repeat']); $repo->forIssues($daily,['state'=>'closed','labels'=>'daily/repeat']); $repo->forIssues($daily,['state'=>'closed','labels'=>$day_name.'/repeat']);