make rrule responsable only for managing date. comments are done by other scripts
This commit is contained in:
parent
51a9bcb8f4
commit
f218d6528d
@ -3,9 +3,8 @@
|
|||||||
/*
|
/*
|
||||||
* This will find all issues with RRULE: in the body
|
* This will find all issues with RRULE: in the body
|
||||||
* 1. extract the RRULE string and calculate the recurring dates.
|
* 1. extract the RRULE string and calculate the recurring dates.
|
||||||
* 2. if the rule is due to occure today then:
|
* 2. if no due date then set the due date to the next occurance
|
||||||
* 2a. if the issue is closed then it will re-open it,
|
* 3. if the issue is closed then repoen it and set the due date to the next occurance
|
||||||
* 2b. and it will add a comment "Today!"
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// load the config, create the connection and load the repo sepcified on the cmd line args
|
// load the config, create the connection and load the repo sepcified on the cmd line args
|
||||||
@ -15,11 +14,7 @@ require('setup.php');
|
|||||||
use RRule\RRule;
|
use RRule\RRule;
|
||||||
|
|
||||||
//function to add/replace the tag with our text
|
//function to add/replace the tag with our text
|
||||||
/*
|
|
||||||
function updateIssueBody($issue,$text){
|
function updateIssueBody($issue,$text){
|
||||||
$issue->addComment($text);
|
|
||||||
return;
|
|
||||||
|
|
||||||
// add a tag to the body if to doesn't exist
|
// add a tag to the body if to doesn't exist
|
||||||
if( strpos($issue->body,'<!--BOT-->')===false ){
|
if( strpos($issue->body,'<!--BOT-->')===false ){
|
||||||
$issue->body.="\n<!--BOT--><hr/><!--ENDBOT-->";
|
$issue->body.="\n<!--BOT--><hr/><!--ENDBOT-->";
|
||||||
@ -28,7 +23,6 @@ function updateIssueBody($issue,$text){
|
|||||||
$issue->body=preg_replace("#<!--BOT-->.*?<!--ENDBOT-->#s",'<!--BOT--><hr/>'.$text.'<!--ENDBOT-->',$issue->body);
|
$issue->body=preg_replace("#<!--BOT-->.*?<!--ENDBOT-->#s",'<!--BOT--><hr/>'.$text.'<!--ENDBOT-->',$issue->body);
|
||||||
$issue->save();
|
$issue->save();
|
||||||
};
|
};
|
||||||
*/
|
|
||||||
|
|
||||||
//loop through each issue that has a RRULE
|
//loop through each issue that has a RRULE
|
||||||
$issues=array_merge(
|
$issues=array_merge(
|
||||||
@ -60,37 +54,24 @@ foreach($issues as $issue){
|
|||||||
$next_exc=$rrule->getOccurrencesAfter(date('Y-m-d'),$inclusive=false,$limit=1)[0];
|
$next_exc=$rrule->getOccurrencesAfter(date('Y-m-d'),$inclusive=false,$limit=1)[0];
|
||||||
$today=$next_inc->format('Y-m-d')==date('Y-m-d');
|
$today=$next_inc->format('Y-m-d')==date('Y-m-d');
|
||||||
|
|
||||||
if($debug){
|
$summary=$rrule->humanReadable().
|
||||||
echo $rrule->humanReadable().
|
|
||||||
"\n NOW: ".date('Y-m-d').
|
"\n NOW: ".date('Y-m-d').
|
||||||
"\n First: ".$rrule[0]->format('Y-m-d').
|
"\n First: ".$rrule[0]->format('Y-m-d').
|
||||||
"\n Second: ".$rrule[1]->format('Y-m-d').
|
"\n Second: ".$rrule[1]->format('Y-m-d').
|
||||||
|
"\n Third: ".$rrule[2]->format('Y-m-d').
|
||||||
"\n Today: ".($today?'Yes':'no').
|
"\n Today: ".($today?'Yes':'no').
|
||||||
"\n Next Inc: ".$next_inc->format('Y-m-d').
|
"\n Next Inc: ".$next_inc->format('Y-m-d').
|
||||||
"\n Next Exc: ".$next_exc->format('Y-m-d').
|
"\n Next Exc: ".$next_exc->format('Y-m-d').
|
||||||
"\n";
|
"\n";
|
||||||
|
updateIssueBody($issue,str_replace("\n","<br/>\n",$summary));
|
||||||
|
|
||||||
|
if( !$issue->due_date ){
|
||||||
|
$issue->setDueDate($next_inc>format('c'));
|
||||||
}
|
}
|
||||||
|
|
||||||
//is it today?
|
|
||||||
if($today){
|
|
||||||
echo "@Today\n";
|
|
||||||
if($issue->state=='closed'){
|
if($issue->state=='closed'){
|
||||||
|
$issue->due_date=$next_exc->format('c');
|
||||||
$issue->state='open';
|
$issue->state='open';
|
||||||
$issue->save();
|
$issue->save();
|
||||||
}
|
}
|
||||||
$issue->addComment("Today!!\n\nNext: ".$next_exc->format('Y-m-d'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// not working https://github.com/go-gitea/gitea/issues/8179
|
|
||||||
//$issue->due_date=$rrule[0]->format('c');
|
|
||||||
//$issue->save();
|
|
||||||
//if( date('Y-m-d',strtotime($issue->due_date)) != $next_exc->format('Y-m-d') ){
|
|
||||||
if( $issue->due_date ){
|
|
||||||
if( strtotime(date('Y-m-d',strtotime($issue->due_date))) < strtotime($next_exc->format('Y-m-d')) ){
|
|
||||||
echo "@Overdue\n";
|
|
||||||
$issue->addComment("Overdue!!\n\nNext: ".$next_exc->format('Y-m-d'));
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$issue->setDueDate($next_exc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user