stuff
This commit is contained in:
parent
603509210c
commit
b314b942b9
4 changed files with 77 additions and 1 deletions
|
@ -12,9 +12,13 @@ Remove cards from the "Done" list which are older than 7 days
|
|||
## move-backlog-card-with-date
|
||||
Move all cards in the Backlog where the due date is in the past to the "ToDo" list and remove the due date
|
||||
|
||||
## unassign-cards
|
||||
Assign all card with have no assign user to the user how run the script
|
||||
|
||||
# Example Cron setup
|
||||
```
|
||||
*/5 * * * * /home/pi/trello-bot-pi move-backlog-card-with-date
|
||||
0 5 * * * /home/pi/trello-bot-pi reset-daily-tasks
|
||||
0 5 * * * /home/pi/trello-bot-pi remove-done-cards
|
||||
*/5 * * * * /home/pi/trello-bot-pi unassign-cards
|
||||
```
|
5
main.go
5
main.go
|
@ -38,6 +38,11 @@ func main() {
|
|||
Usage: "Move all cards from \"Backlog\" to \"ToDo\" where the End Date is in the past and remove the duedate",
|
||||
Action: moveBacklogCardWithDate,
|
||||
},
|
||||
{
|
||||
Name: "unassign-cards",
|
||||
Usage: "Assign all cards without member to current users",
|
||||
Action: unassignCards,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -68,11 +68,32 @@ func moveBacklogCardWithDate(cCtx *cli.Context) error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("cant add comment to card: %w", err)
|
||||
}
|
||||
card.Due = nil
|
||||
err = card.Update(trello.Arguments{"due": "null"})
|
||||
if err != nil {
|
||||
return fmt.Errorf("cant update card to remove due date: %w", err)
|
||||
}
|
||||
} else {
|
||||
msg := fmt.Sprintf("Saved for resubmission on %v", card.Due.Format(time.DateTime))
|
||||
comments, err := card.GetCommentActions()
|
||||
if err != nil {
|
||||
return fmt.Errorf("cant get last comments: %w", err)
|
||||
}
|
||||
|
||||
foundComment := false
|
||||
for _, comment := range comments {
|
||||
if comment.Data.Text == msg {
|
||||
foundComment = true
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if !foundComment {
|
||||
_, err = card.AddComment(msg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cant get comment to card: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
46
unassign-cards.go
Normal file
46
unassign-cards.go
Normal file
|
@ -0,0 +1,46 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/adlio/trello"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
func unassignCards(cCtx *cli.Context) error {
|
||||
client := getTrelloClient()
|
||||
board, err := client.GetBoard(trelloBordID, trello.Defaults())
|
||||
if err != nil {
|
||||
return fmt.Errorf("cant get bord: %w", err)
|
||||
}
|
||||
|
||||
log.Debug().Interface("bord", board).Msg("get bord")
|
||||
|
||||
me, err := client.GetMyMember(trello.Defaults())
|
||||
if err != nil {
|
||||
return fmt.Errorf("cant get member: %w", err)
|
||||
}
|
||||
|
||||
log.Debug().Str("name", me.FullName).Str("id", me.ID).Interface("me", me).Msg("Got User")
|
||||
|
||||
cards, err := board.GetCards(trello.Defaults())
|
||||
if err != nil {
|
||||
return fmt.Errorf("cant get cards from board: %w", err)
|
||||
}
|
||||
|
||||
for _, card := range cards {
|
||||
if len(card.IDMembers) > 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
log.Debug().Interface("card", card).Msg("Add Member to card")
|
||||
|
||||
_, err = card.AddMemberID(me.ID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cant add member to card: %w", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Reference in a new issue