Skip to content

Commit

Permalink
Delete stale cards instead of archiving them (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
utkuufuk authored Jun 11, 2020
1 parent 50c7a94 commit 35ff956
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions cmd/entrello/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ func processActionables(ctx context.Context, client trello.Client, q CardQueue)
}
logger.Printf("created new card: %s", c.Name)
case c := <-q.del:
if err := client.ArchiveCard(c); err != nil {
logger.Errorf("could not archive card card: %v", err)
if err := client.DeleteCard(c); err != nil {
logger.Errorf("could not delete Trello card: %v", err)
break
}
logger.Printf("archived stale card: %s", c.Name)
logger.Printf("deleted stale card: %s", c.Name)
case err := <-q.err:
logger.Errorf("%v", err)
case <-ctx.Done():
Expand Down
7 changes: 4 additions & 3 deletions internal/trello/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"github.com/adlio/trello"
)

// ArchiveCard archives a Trello card using the the Trello API
func (c Client) ArchiveCard(card Card) error {
return (*trello.Card)(card).Update(trello.Arguments{"closed": "true"})
// DeleteCard deletes a Trello card using the the Trello API
func (c Client) DeleteCard(card Card) error {
path := fmt.Sprintf("cards/%s", card.ID)
return c.api.Delete(path, trello.Defaults(), card)
}

// CreateCard creates a Trello card using the the Trello API
Expand Down

0 comments on commit 35ff956

Please sign in to comment.