remove old example
This commit is contained in:
parent
c05f37ce61
commit
02b42c9529
55
src/due.php
55
src/due.php
@ -1,55 +0,0 @@
|
|||||||
#!/usr/bin/php
|
|
||||||
<?php
|
|
||||||
/**************************************************
|
|
||||||
* This will examine all issues, and add lables
|
|
||||||
* as the due date approaches!
|
|
||||||
**************************************************/
|
|
||||||
|
|
||||||
// load the config, create the connection and load the repo sepcified on the cmd line args
|
|
||||||
// we will then have $client and $repo available
|
|
||||||
require('setup.php');
|
|
||||||
|
|
||||||
//define the lebels we will use
|
|
||||||
$labels=['today'=>'today','this week'=>'this week','this month'=>'this month'];
|
|
||||||
|
|
||||||
/* load or create the labels */
|
|
||||||
foreach($labels as $k=>$v){
|
|
||||||
$label=$repo->getLabelByName($v);
|
|
||||||
if(!$label){
|
|
||||||
$label=$repo->createLabel([
|
|
||||||
'name'=>$v,
|
|
||||||
'color'=>'#00ffff',
|
|
||||||
'description'=>'Due $v'
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
$labels[$k]=$label;
|
|
||||||
}
|
|
||||||
|
|
||||||
// we are processing ALL issues, and not changing the state
|
|
||||||
// (see https://git.jhodges.co.uk/jhodges/GiteaBot/issues/1)
|
|
||||||
// so we can use forIssues() here to keep memory usage down
|
|
||||||
$repo->forIssues(function($issue) use ($labels) {
|
|
||||||
if($issue->due_date){
|
|
||||||
$day_today=date('U')/60/60/24;
|
|
||||||
$days_until_due=(date('U',strtotime($issue->due_date))/60/60/24)-$day_today;
|
|
||||||
echo "$issue->title : $days_until_due \n";
|
|
||||||
if($days_until_due<0){
|
|
||||||
$issue->addComment("NAG!");
|
|
||||||
}
|
|
||||||
if($days_until_due<1){
|
|
||||||
if(!$issue->hasLabel($labels['today'])){
|
|
||||||
$issue->addLabel($labels['today']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if($days_until_due<7){
|
|
||||||
if(!$issue->hasLabel($labels['this week'])){
|
|
||||||
$issue->addLabel($labels['this week']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if($days_until_due<30){
|
|
||||||
if(!$issue->hasLabel($labels['this month'])){
|
|
||||||
$issue->addLabel($labels['this month']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
Loading…
Reference in New Issue
Block a user