From dd704e858c6777caf29a26d96a737282f4adb8a7 Mon Sep 17 00:00:00 2001 From: James Date: Sat, 14 Sep 2019 12:27:22 +0100 Subject: [PATCH] remove the untested/unfinished "repeat" scripts --- README.md | 14 ------ src/repeat.php | 129 ------------------------------------------------- 2 files changed, 143 deletions(-) delete mode 100755 src/repeat.php diff --git a/README.md b/README.md index d54fc38..bdf7886 100644 --- a/README.md +++ b/README.md @@ -20,20 +20,6 @@ All examples include [src/setup.php](https://git.jhodges.co.uk/jhodges/GiteaBot- *************************************************/ ``` ---- -###[src/repeat.php](https://git.jhodges.co.uk/jhodges/GiteaBot-examples/src/branch/master/src/repeat.php) - -```plain -/*********************************************************************** -* This is designed to allow the use of labels to reopen recuring issues -* on a specific day, month or duration (daily/weekly/monthly etc) -* NOTE: This is not 100% implemented/tested. It's a WIP -* It will process any issue that is tagged with 'xxx/repeat' label -* The labels are grouped into days/months -* If an issue is closed then it will be reopened -* If an issue is already open the bot will comment "NAG!" about it -***********************************************************************/ -``` ----- ###[src/edit.php](https://git.jhodges.co.uk/jhodges/GiteaBot-examples/src/branch/master/src/edit.php) ```plain diff --git a/src/repeat.php b/src/repeat.php deleted file mode 100755 index a7de9d4..0000000 --- a/src/repeat.php +++ /dev/null @@ -1,129 +0,0 @@ -#!/usr/bin/php -['janurary','feburary','march','april','may','june','july','august','september','october','november','december'], - 'days'=>['monday','tuesday','wednesday','thursday','friday','saturday','sunday'], - 'generic'=>['daily','weekly','fortnightly','monthly','yearly'] -]; - -/* create the labels */ -foreach($terms as $group=>$names){ - foreach($names as $name){ - $name="{$name}/repeat"; - $label=$repo->getLabelByName($name); - if(!$label){ - $label=$repo->createLabel([ - 'name'=>$name, - 'color'=>'#ffff00', - 'description'=>'Reopen this issue with the given frequency' - ]); - } - } -} - -//define the function to process each issue -$daily=function($issue){ - $day_today=date('U')/60/60/24; - $days_closed_ago=$issue->closed_at?$day_today-(date('U',strtotime($issue->closed_at))/60/60/24):null; - $days_updated_ago=$day_today-(date('U',strtotime($issue->updated_at))/60/60/24); - echo "Daily: ". $issue->title." C:".$issue->closed_at." ($days_closed_ago) U:".$issue->updated_at." ($days_updated_ago) \n"; - if($days_closed_ago>1){ - if($issue->state=="closed"){ - $issue->state='open'; - $issue->save(); - }else{ - if($days_updated_ago>1){ - $issue->addComment("NAG!"); - } - } - } -}; - -$weekly=function($issue){ - $day_today=date('U')/60/60/24; - $days_closed_ago=$issue->closed_at?$day_today-(date('U',strtotime($issue->closed_at))/60/60/24):null; - $days_updated_ago=$day_today-(date('U',strtotime($issue->updated_at))/60/60/24); - echo "Weekly: ". $issue->title." C:".$issue->closed_at." ($days_closed_ago) U:".$issue->updated_at." ($days_updated_ago) \n"; - if( $days_closed_ago>7 ){ - if($issue->state=="closed"){ - $issue->state='open'; - $issue->save(); - }else{ - if($days_updated_ago>3){ - $issue->addComment("NAG!"); - } - } - } -}; - -$monthly=function($issue) use ($terms){ - $day_today=date('U')/60/60/24; - $days_closed_ago=$issue->closed_at?$day_today-(date('U',strtotime($issue->closed_at))/60/60/24):null; - $days_updated_ago=$day_today-(date('U',strtotime($issue->updated_at))/60/60/24); - $month_closed=date('m/Y',strtotime($issue->closed_at)); - $month_today=date('m/Y'); - echo "Monthly: ". $issue->title." [MC: $month_closed, MT: $month_today] C:".$issue->closed_at." ($days_closed_ago) U:".$issue->updated_at." ($days_updated_ago) \n"; - //print_r($issue->labels); - //print_r(getRepeatTerms($issue,$terms)); - //die(); - if($month_closed!=$month_today){ - if($issue->state=="closed"){ - $issue->state='open'; - $issue->save(); - }else{ - if($days_updated_ago>7){ - $issue->addComment("NAG!"); - } - } - } -}; - -function getRepeatTerms($issue,$terms){ - $labels=[]; - $found=[]; - foreach($issue->labels as $label){ - $labels[]=$label->name; - } - print_r($labels); - foreach($terms as $name=>$values){ - foreach($values as $value){ - if( in_array("$value/repeat",$labels) ){ - $found[$name][]=$value; - } - } - } - return $found; -} - -//prep the curent day/month names -$day_name=strtolower(date('l')); -$month_name=strtolower(date('F')); - -// 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']); -$repo->forIssues($monthly,['state'=>'closed','labels'=>'monthly/repeat']); -$repo->forIssues($monthly,['state'=>'closed','labels'=>$month_name.'/repeat']);